1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 02:19:08 -05:00

Refactor entites (#86)

This commit is contained in:
Mikołaj Pich 2018-04-24 22:05:46 +02:00 committed by Rafał Borcz
parent 6fcf09e2b7
commit 119e38254a
55 changed files with 1447 additions and 940 deletions

View File

@ -4,8 +4,6 @@ public class Diary implements ParamItem {
private String id = ""; private String id = "";
private String studentId = "";
private String name = ""; private String name = "";
private boolean current = false; private boolean current = false;
@ -19,16 +17,6 @@ public class Diary implements ParamItem {
return this; return this;
} }
public String getStudentId() {
return studentId;
}
@Override
public Diary setStudentId(String studentId) {
this.studentId = studentId;
return this;
}
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -4,8 +4,6 @@ interface ParamItem {
ParamItem setId(String id); ParamItem setId(String id);
ParamItem setStudentId(String id);
ParamItem setName(String name); ParamItem setName(String name);
ParamItem setCurrent(boolean isCurrent); ParamItem setCurrent(boolean isCurrent);

View File

@ -4,8 +4,6 @@ public class Semester implements ParamItem {
private String id = ""; private String id = "";
private String studentId = "";
private String name = ""; private String name = "";
private boolean current = false; private boolean current = false;
@ -19,16 +17,6 @@ public class Semester implements ParamItem {
return this; return this;
} }
public String getStudentId() {
return studentId;
}
@Override
public Semester setStudentId(String studentId) {
this.studentId = studentId;
return this;
}
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -17,15 +17,6 @@ public class Student implements ParamItem {
return this; return this;
} }
public String getStudentId() {
return getId();
}
@Override
public Student setStudentId(String studentId) {
return setId(studentId);
}
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -140,8 +140,8 @@ public class StudentAndParent implements SnP {
for (Element e : semesterOptions) { for (Element e : semesterOptions) {
Semester semester = new Semester() Semester semester = new Semester()
.setId(e.text()) .setId(e.attr("value"))
.setName(e.attr("value")); .setName(e.text());
if (isCurrent(e)) { if (isCurrent(e)) {
semester.setCurrent(true); semester.setCurrent(true);
@ -167,9 +167,6 @@ public class StudentAndParent implements SnP {
if (isCurrent(e)) { if (isCurrent(e)) {
item.setCurrent(true); item.setCurrent(true);
} }
if (item instanceof Diary) {
item.setStudentId(getStudentID());
}
list.add((T) item); list.add((T) item);
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -18,8 +18,6 @@ public class Grade {
private String teacher = ""; private String teacher = "";
private String semester = "";
public String getSubject() { public String getSubject() {
return subject; return subject;
} }
@ -99,14 +97,4 @@ public class Grade {
return this; return this;
} }
public String getSemester() {
return semester;
}
public Grade setSemester(String semester) {
this.semester = semester;
return this;
}
} }

View File

@ -14,7 +14,6 @@ import java.util.Locale;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import io.github.wulkanowy.api.Semester;
import io.github.wulkanowy.api.SnP; import io.github.wulkanowy.api.SnP;
import io.github.wulkanowy.api.VulcanException; import io.github.wulkanowy.api.VulcanException;
@ -42,24 +41,18 @@ public class GradesList {
Document gradesPage = snp.getSnPPageDocument(getGradesPageUrl() + semester); Document gradesPage = snp.getSnPPageDocument(getGradesPageUrl() + semester);
Elements gradesRows = gradesPage.select(".ocenySzczegoly-table > tbody > tr"); Elements gradesRows = gradesPage.select(".ocenySzczegoly-table > tbody > tr");
if ("".equals(semester)) {
List<Semester> semesterList = snp.getSemesters(gradesPage);
Semester currentSemester = snp.getCurrent(semesterList);
semester = currentSemester.getName();
}
for (Element row : gradesRows) { for (Element row : gradesRows) {
if ("Brak ocen".equals(row.select("td:nth-child(2)").text())) { if ("Brak ocen".equals(row.select("td:nth-child(2)").text())) {
continue; continue;
} }
grades.add(getGrade(row, semester)); grades.add(getGrade(row));
} }
return grades; return grades;
} }
private Grade getGrade(Element row, String semester) throws ParseException { private Grade getGrade(Element row) throws ParseException {
String descriptions = row.select("td:nth-child(3)").text(); String descriptions = row.select("td:nth-child(3)").text();
String symbol = descriptions.split(", ")[0]; String symbol = descriptions.split(", ")[0];
@ -75,8 +68,7 @@ public class GradesList {
.setDescription(description) .setDescription(description)
.setWeight(row.select("td:nth-child(4)").text()) .setWeight(row.select("td:nth-child(4)").text())
.setDate(date) .setDate(date)
.setTeacher(row.select("td:nth-child(6)").text()) .setTeacher(row.select("td:nth-child(6)").text());
.setSemester(semester);
} }
private String getColor(String styleAttr) { private String getColor(String styleAttr) {

View File

@ -13,16 +13,21 @@ import io.github.wulkanowy.api.VulcanException;
public class SubjectsList { public class SubjectsList {
private static final String SUBJECTS_PAGE_URL = "Oceny/Wszystkie?details=1"; private static final String SUBJECTS_PAGE_URL = "Oceny/Wszystkie?details=1&okres=";
private SnP snp = null; private SnP snp;
public SubjectsList(SnP snp) { public SubjectsList(SnP snp) {
this.snp = snp; this.snp = snp;
} }
public List<Subject> getAll() throws IOException, VulcanException { public List<Subject> getAll() throws IOException, VulcanException {
Document subjectPage = snp.getSnPPageDocument(SUBJECTS_PAGE_URL); return getAll("");
}
public List<Subject> getAll(String semester) throws IOException, VulcanException {
Document subjectPage = snp.getSnPPageDocument(SUBJECTS_PAGE_URL + semester);
Elements rows = subjectPage.select(".ocenyZwykle-table > tbody > tr"); Elements rows = subjectPage.select(".ocenyZwykle-table > tbody > tr");

View File

@ -96,12 +96,12 @@ public class StudentAndParentTest {
Assert.assertEquals(2, semesters.size()); Assert.assertEquals(2, semesters.size());
Assert.assertEquals("1", semesters.get(0).getId()); Assert.assertEquals("1", semesters.get(0).getName());
Assert.assertEquals("1234", semesters.get(0).getName()); Assert.assertEquals("1234", semesters.get(0).getId());
Assert.assertFalse(semesters.get(0).isCurrent()); Assert.assertFalse(semesters.get(0).isCurrent());
Assert.assertEquals("2", semesters.get(1).getId()); Assert.assertEquals("2", semesters.get(1).getName());
Assert.assertEquals("1235", semesters.get(1).getName()); Assert.assertEquals("1235", semesters.get(1).getId());
Assert.assertTrue(semesters.get(1).isCurrent()); Assert.assertTrue(semesters.get(1).isCurrent());
} }
@ -150,9 +150,7 @@ public class StudentAndParentTest {
Assert.assertFalse(snp.getDiaries().get(1).isCurrent()); Assert.assertFalse(snp.getDiaries().get(1).isCurrent());
Assert.assertFalse(snp.getDiaries().get(2).isCurrent()); Assert.assertFalse(snp.getDiaries().get(2).isCurrent());
Assert.assertEquals("100", snp.getDiaries().get(0).getStudentId());
Assert.assertEquals("Jan Kowal", snp.getStudents().get(0).getName()); Assert.assertEquals("Jan Kowal", snp.getStudents().get(0).getName());
Assert.assertEquals("100", snp.getStudents().get(0).getStudentId()); Assert.assertEquals("100", snp.getStudents().get(0).getId());
} }
} }

View File

@ -101,14 +101,4 @@ public class GradesListTest extends StudentAndParentTestCase {
Assert.assertEquals("Klaudia Dziedzic", list.get(4).getTeacher()); Assert.assertEquals("Klaudia Dziedzic", list.get(4).getTeacher());
Assert.assertEquals("Amelia Stępień", list.get(5).getTeacher()); Assert.assertEquals("Amelia Stępień", list.get(5).getTeacher());
} }
@Test
public void getSemesterTest() throws Exception {
List<Grade> list = filled.getAll();
Assert.assertEquals("7654321", list.get(0).getSemester());
Assert.assertEquals("7654321", list.get(3).getSemester());
Assert.assertEquals("7654321", list.get(4).getSemester());
Assert.assertEquals("7654321", list.get(5).getSemester());
}
} }

View File

@ -62,7 +62,7 @@ android {
} }
greendao { greendao {
schemaVersion 23 schemaVersion 24
generateTests = true generateTests = true
} }

View File

@ -12,13 +12,13 @@ public class AttendanceLessonTest extends AbstractDaoTestLongPk<AttendanceLesson
protected AttendanceLesson createEntity(Long key) { protected AttendanceLesson createEntity(Long key) {
AttendanceLesson entity = new AttendanceLesson(); AttendanceLesson entity = new AttendanceLesson();
entity.setId(key); entity.setId(key);
entity.setIsPresence(false); entity.setPresence(false);
entity.setIsAbsenceUnexcused(false); entity.setAbsenceUnexcused(false);
entity.setIsAbsenceExcused(false); entity.setAbsenceExcused(false);
entity.setIsUnexcusedLateness(false); entity.setUnexcusedLateness(false);
entity.setIsAbsenceForSchoolReasons(false); entity.setAbsenceForSchoolReasons(false);
entity.setIsExcusedLateness(false); entity.setExcusedLateness(false);
entity.setIsExemption(false); entity.setExemption(false);
return entity; return entity;
} }

View File

@ -12,7 +12,7 @@ public class DayTest extends AbstractDaoTestLongPk<DayDao, Day> {
protected Day createEntity(Long key) { protected Day createEntity(Long key) {
Day entity = new Day(); Day entity = new Day();
entity.setId(key); entity.setId(key);
entity.setIsFreeDay(false); entity.setFreeDay(false);
return entity; return entity;
} }

View File

@ -12,7 +12,7 @@ public class DiaryTest extends AbstractDaoTestLongPk<DiaryDao, Diary> {
protected Diary createEntity(Long key) { protected Diary createEntity(Long key) {
Diary entity = new Diary(); Diary entity = new Diary();
entity.setId(key); entity.setId(key);
entity.setIsCurrent(false); entity.setCurrent(false);
return entity; return entity;
} }

View File

@ -0,0 +1,21 @@
package io.github.wulkanowy.data.db.dao.entities;
import org.greenrobot.greendao.test.AbstractDaoTestLongPk;
import io.github.wulkanowy.data.db.dao.entities.Semester;
import io.github.wulkanowy.data.db.dao.entities.SemesterDao;
public class SemesterTest extends AbstractDaoTestLongPk<SemesterDao, Semester> {
public SemesterTest() {
super(SemesterDao.class);
}
@Override
protected Semester createEntity(Long key) {
Semester entity = new Semester();
entity.setId(key);
return entity;
}
}

View File

@ -0,0 +1,21 @@
package io.github.wulkanowy.data.db.dao.entities;
import org.greenrobot.greendao.test.AbstractDaoTestLongPk;
import io.github.wulkanowy.data.db.dao.entities.Student;
import io.github.wulkanowy.data.db.dao.entities.StudentDao;
public class StudentTest extends AbstractDaoTestLongPk<StudentDao, Student> {
public StudentTest() {
super(StudentDao.class);
}
@Override
protected Student createEntity(Long key) {
Student entity = new Student();
entity.setId(key);
return entity;
}
}

View File

@ -0,0 +1,21 @@
package io.github.wulkanowy.data.db.dao.entities;
import org.greenrobot.greendao.test.AbstractDaoTestLongPk;
import io.github.wulkanowy.data.db.dao.entities.Symbol;
import io.github.wulkanowy.data.db.dao.entities.SymbolDao;
public class SymbolTest extends AbstractDaoTestLongPk<SymbolDao, Symbol> {
public SymbolTest() {
super(SymbolDao.class);
}
@Override
protected Symbol createEntity(Long key) {
Symbol entity = new Symbol();
entity.setId(key);
return entity;
}
}

View File

@ -12,12 +12,12 @@ public class TimetableLessonTest extends AbstractDaoTestLongPk<TimetableLessonDa
protected TimetableLesson createEntity(Long key) { protected TimetableLesson createEntity(Long key) {
TimetableLesson entity = new TimetableLesson(); TimetableLesson entity = new TimetableLesson();
entity.setId(key); entity.setId(key);
entity.setIsEmpty(false); entity.setEmpty(false);
entity.setIsDivisionIntoGroups(false); entity.setDivisionIntoGroups(false);
entity.setIsPlanning(false); entity.setPlanning(false);
entity.setIsRealized(false); entity.setRealized(false);
entity.setIsMovedOrCanceled(false); entity.setMovedOrCanceled(false);
entity.setIsNewMovedInOrChanged(false); entity.setNewMovedInOrChanged(false);
return entity; return entity;
} }

View File

@ -11,8 +11,13 @@ import io.github.wulkanowy.api.VulcanException;
import io.github.wulkanowy.data.db.dao.entities.Account; import io.github.wulkanowy.data.db.dao.entities.Account;
import io.github.wulkanowy.data.db.dao.entities.AttendanceLesson; import io.github.wulkanowy.data.db.dao.entities.AttendanceLesson;
import io.github.wulkanowy.data.db.dao.entities.DaoSession; import io.github.wulkanowy.data.db.dao.entities.DaoSession;
import io.github.wulkanowy.data.db.dao.entities.DiaryDao;
import io.github.wulkanowy.data.db.dao.entities.Grade; import io.github.wulkanowy.data.db.dao.entities.Grade;
import io.github.wulkanowy.data.db.dao.entities.GradeDao; import io.github.wulkanowy.data.db.dao.entities.GradeDao;
import io.github.wulkanowy.data.db.dao.entities.SemesterDao;
import io.github.wulkanowy.data.db.dao.entities.StudentDao;
import io.github.wulkanowy.data.db.dao.entities.Subject;
import io.github.wulkanowy.data.db.dao.entities.SymbolDao;
import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.data.db.dao.entities.Week;
import io.github.wulkanowy.data.db.dao.entities.WeekDao; import io.github.wulkanowy.data.db.dao.entities.WeekDao;
import io.github.wulkanowy.data.db.resources.ResourcesContract; import io.github.wulkanowy.data.db.resources.ResourcesContract;
@ -136,32 +141,32 @@ public class Repository implements RepositoryContract {
@Override @Override
public void syncGrades() throws VulcanException, IOException, ParseException { public void syncGrades() throws VulcanException, IOException, ParseException {
gradeSync.sync(); gradeSync.sync(getCurrentSemesterId());
} }
@Override @Override
public void syncSubjects() throws VulcanException, IOException, ParseException { public void syncSubjects() throws VulcanException, IOException, ParseException {
subjectSync.sync(); subjectSync.sync(getCurrentSemesterId());
} }
@Override @Override
public void syncAttendance() throws ParseException, IOException, VulcanException { public void syncAttendance() throws ParseException, IOException, VulcanException {
attendanceSync.syncAttendance(); attendanceSync.syncAttendance(getCurrentDiaryId());
} }
@Override @Override
public void syncAttendance(String date) throws ParseException, IOException, VulcanException { public void syncAttendance(String date) throws ParseException, IOException, VulcanException {
attendanceSync.syncAttendance(date); attendanceSync.syncAttendance(getCurrentDiaryId(), date);
} }
@Override @Override
public void syncTimetable() throws VulcanException, IOException, ParseException { public void syncTimetable() throws VulcanException, IOException, ParseException {
timetableSync.syncTimetable(); timetableSync.syncTimetable(getCurrentDiaryId());
} }
@Override @Override
public void syncTimetable(String date) throws VulcanException, IOException, ParseException { public void syncTimetable(String date) throws VulcanException, IOException, ParseException {
timetableSync.syncTimetable(date); timetableSync.syncTimetable(getCurrentDiaryId(), date);
} }
@Override @Override
@ -179,16 +184,52 @@ public class Repository implements RepositoryContract {
@Override @Override
public Week getWeek(String date) { public Week getWeek(String date) {
return daoSession.getWeekDao().queryBuilder() return daoSession.getWeekDao().queryBuilder().where(
.where(WeekDao.Properties.StartDayDate.eq(date), WeekDao.Properties.StartDayDate.eq(date),
WeekDao.Properties.UserId.eq(getCurrentUserId())) WeekDao.Properties.DiaryId.eq(getCurrentDiaryId())
.unique(); ).unique();
}
public List<Subject> getSubjectList() {
return daoSession.getSemesterDao().load(getCurrentSemesterId()).getSubjectList();
} }
@Override @Override
public List<Grade> getNewGrades() { public List<Grade> getNewGrades() {
return daoSession.getGradeDao().queryBuilder() return daoSession.getGradeDao().queryBuilder().where(
.where(GradeDao.Properties.IsNew.eq(1)) GradeDao.Properties.IsNew.eq(1),
.list(); GradeDao.Properties.SemesterId.eq(getCurrentSemesterId())
).list();
}
@Override
public long getCurrentSymbolId() {
return daoSession.getSymbolDao().queryBuilder().where(
SymbolDao.Properties.UserId.eq(getCurrentUserId())
).unique().getId();
}
@Override
public long getCurrentStudentId() {
return daoSession.getStudentDao().queryBuilder().where(
StudentDao.Properties.SymbolId.eq(getCurrentSymbolId()),
StudentDao.Properties.Current.eq(true)
).unique().getId();
}
@Override
public long getCurrentDiaryId() {
return daoSession.getDiaryDao().queryBuilder().where(
DiaryDao.Properties.StudentId.eq(getCurrentStudentId()),
DiaryDao.Properties.Current.eq(true)
).unique().getId();
}
@Override
public long getCurrentSemesterId() {
return daoSession.getSemesterDao().queryBuilder().where(
SemesterDao.Properties.DiaryId.eq(getCurrentDiaryId()),
SemesterDao.Properties.Current.eq(true)
).unique().getId();
} }
} }

View File

@ -9,15 +9,13 @@ import javax.inject.Singleton;
import io.github.wulkanowy.api.VulcanException; import io.github.wulkanowy.api.VulcanException;
import io.github.wulkanowy.data.db.dao.entities.Account; import io.github.wulkanowy.data.db.dao.entities.Account;
import io.github.wulkanowy.data.db.dao.entities.Grade; import io.github.wulkanowy.data.db.dao.entities.Grade;
import io.github.wulkanowy.data.db.dao.entities.Subject;
import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.data.db.dao.entities.Week;
import io.github.wulkanowy.data.db.resources.ResourcesContract; import io.github.wulkanowy.data.db.resources.ResourcesContract;
import io.github.wulkanowy.data.sync.account.AccountSyncContract; import io.github.wulkanowy.data.sync.account.AccountSyncContract;
import io.github.wulkanowy.data.sync.attendance.AttendanceSyncContract;
import io.github.wulkanowy.data.sync.timetable.TimetableSyncContract;
@Singleton @Singleton
public interface RepositoryContract extends ResourcesContract, AccountSyncContract, public interface RepositoryContract extends ResourcesContract, AccountSyncContract {
AttendanceSyncContract, TimetableSyncContract {
long getCurrentUserId(); long getCurrentUserId();
@ -39,11 +37,29 @@ public interface RepositoryContract extends ResourcesContract, AccountSyncContra
void syncSubjects() throws VulcanException, IOException, ParseException; void syncSubjects() throws VulcanException, IOException, ParseException;
void syncAttendance() throws ParseException, IOException, VulcanException;
void syncAttendance(String date) throws ParseException, IOException, VulcanException;
void syncTimetable() throws VulcanException, IOException, ParseException;
void syncTimetable(String date) throws VulcanException, IOException, ParseException;
void syncAll() throws VulcanException, IOException, ParseException; void syncAll() throws VulcanException, IOException, ParseException;
Account getCurrentUser(); Account getCurrentUser();
Week getWeek(String date); Week getWeek(String date);
List<Subject> getSubjectList();
List<Grade> getNewGrades(); List<Grade> getNewGrades();
long getCurrentStudentId();
long getCurrentSymbolId();
long getCurrentDiaryId();
long getCurrentSemesterId();
} }

View File

@ -17,6 +17,7 @@ import javax.inject.Singleton;
import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.data.db.dao.entities.DaoMaster; import io.github.wulkanowy.data.db.dao.entities.DaoMaster;
import io.github.wulkanowy.data.db.dao.migrations.Migration23; import io.github.wulkanowy.data.db.dao.migrations.Migration23;
import io.github.wulkanowy.data.db.dao.migrations.Migration24;
import io.github.wulkanowy.data.db.shared.SharedPrefContract; import io.github.wulkanowy.data.db.shared.SharedPrefContract;
import io.github.wulkanowy.di.annotations.ApplicationContext; import io.github.wulkanowy.di.annotations.ApplicationContext;
import io.github.wulkanowy.di.annotations.DatabaseInfo; import io.github.wulkanowy.di.annotations.DatabaseInfo;
@ -39,11 +40,9 @@ public class DbHelper extends DaoMaster.OpenHelper {
@Override @Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Database database = new StandardDatabase(db);
DaoMaster.dropAllTables(database, true);
onCreate(database);
sharedPref.setCurrentUserId(0);
LogUtils.info("Cleaning user data oldVersion=" + oldVersion + " newVersion=" + newVersion); LogUtils.info("Cleaning user data oldVersion=" + oldVersion + " newVersion=" + newVersion);
Database database = new StandardDatabase(db);
recreateDatabase(database);
} }
@Override @Override
@ -59,17 +58,23 @@ public class DbHelper extends DaoMaster.OpenHelper {
LogUtils.info("Migration " + migration.getVersion() + " complete"); LogUtils.info("Migration " + migration.getVersion() + " complete");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
DaoMaster.dropAllTables(db, true); recreateDatabase(db);
sharedPref.setCurrentUserId(0);
break; break;
} }
} }
} }
} }
private void recreateDatabase(Database db) {
sharedPref.setCurrentUserId(0);
DaoMaster.dropAllTables(db, true);
onCreate(db);
}
private List<Migration> getMigrations() { private List<Migration> getMigrations() {
List<Migration> migrations = new ArrayList<>(); List<Migration> migrations = new ArrayList<>();
migrations.add(new Migration23()); migrations.add(new Migration23());
migrations.add(new Migration24());
// Sorting just to be safe, in case other people add migrations in the wrong order. // Sorting just to be safe, in case other people add migrations in the wrong order.
Comparator<Migration> migrationComparator = new Comparator<Migration>() { Comparator<Migration> migrationComparator = new Comparator<Migration>() {

View File

@ -4,10 +4,9 @@ import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity; import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated; import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index;
import org.greenrobot.greendao.annotation.JoinProperty;
import org.greenrobot.greendao.annotation.Property; import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany; import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.Unique;
import java.util.List; import java.util.List;
@ -20,38 +19,15 @@ public class Account {
@Id(autoincrement = true) @Id(autoincrement = true)
private Long id; private Long id;
@Index(unique = true) @Unique
@Property(nameInDb = "REAL_ID") @Property(nameInDb = "email")
private String realId;
@Property(nameInDb = "SYMBOL")
private String symbol;
@Property(nameInDb = "SCHOOL_ID")
private String schoolId;
@Property(nameInDb = "NAME")
private String name;
@Property(nameInDb = "E_MAIL")
private String email; private String email;
@Property(nameInDb = "PASSWORD") @Property(nameInDb = "password")
private String password; private String password;
@ToMany(joinProperties = {
@JoinProperty(name = "realId", referencedName = "studentId")
})
private List<Diary> diaryList;
@ToMany(referencedJoinProperty = "userId") @ToMany(referencedJoinProperty = "userId")
private List<Subject> subjectList; private List<Symbol> symbolList;
@ToMany(referencedJoinProperty = "userId")
private List<Grade> gradeList;
@ToMany(referencedJoinProperty = "userId")
private List<Day> dayList;
/** /**
* Used to resolve relations * Used to resolve relations
@ -65,14 +41,9 @@ public class Account {
@Generated(hash = 335469827) @Generated(hash = 335469827)
private transient AccountDao myDao; private transient AccountDao myDao;
@Generated(hash = 727721142) @Generated(hash = 1104194311)
public Account(Long id, String realId, String symbol, String schoolId, String name, public Account(Long id, String email, String password) {
String email, String password) {
this.id = id; this.id = id;
this.realId = realId;
this.symbol = symbol;
this.schoolId = schoolId;
this.name = name;
this.email = email; this.email = email;
this.password = password; this.password = password;
} }
@ -82,34 +53,15 @@ public class Account {
} }
public Long getId() { public Long getId() {
return id; return this.id;
} }
public Account setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
return this;
}
public String getRealId() {
return realId;
}
public Account setRealId(String realId) {
this.realId = realId;
return this;
}
public String getName() {
return name;
}
public Account setName(String name) {
this.name = name;
return this;
} }
public String getEmail() { public String getEmail() {
return email; return this.email;
} }
public Account setEmail(String email) { public Account setEmail(String email) {
@ -118,7 +70,7 @@ public class Account {
} }
public String getPassword() { public String getPassword() {
return password; return this.password;
} }
public Account setPassword(String password) { public Account setPassword(String password) {
@ -126,180 +78,34 @@ public class Account {
return this; return this;
} }
public String getSymbol() {
return symbol;
}
public Account setSymbol(String symbol) {
this.symbol = symbol;
return this;
}
public String getSchoolId() {
return schoolId;
}
public Account setSchoolId(String schoolId) {
this.schoolId = schoolId;
return this;
}
public Account setDiaryList(List<Diary> diaryList) {
this.diaryList = diaryList;
return this;
}
public Account setSubjectList(List<Subject> subjectList) {
this.subjectList = subjectList;
return this;
}
public Account setGradeList(List<Grade> gradeList) {
this.gradeList = gradeList;
return this;
}
public Account setDayList(List<Day> dayList) {
this.dayList = dayList;
return this;
}
public DaoSession getDaoSession() {
return daoSession;
}
public Account setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
return this;
}
public AccountDao getMyDao() {
return myDao;
}
public Account setMyDao(AccountDao myDao) {
this.myDao = myDao;
return this;
}
/** /**
* To-many relationship, resolved on first access (and after reset). * To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity. * Changes to to-many relations are not persisted, make changes to the target entity.
*/ */
@Generated(hash = 1472214466) @Generated(hash = 822972496)
public List<Diary> getDiaryList() { public List<Symbol> getSymbolList() {
if (diaryList == null) { if (symbolList == null) {
final DaoSession daoSession = this.daoSession; final DaoSession daoSession = this.daoSession;
if (daoSession == null) { if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context"); throw new DaoException("Entity is detached from DAO context");
} }
DiaryDao targetDao = daoSession.getDiaryDao(); SymbolDao targetDao = daoSession.getSymbolDao();
List<Diary> diaryListNew = targetDao._queryAccount_DiaryList(realId); List<Symbol> symbolListNew = targetDao._queryAccount_SymbolList(id);
synchronized (this) { synchronized (this) {
if (diaryList == null) { if (symbolList == null) {
diaryList = diaryListNew; symbolList = symbolListNew;
} }
} }
} }
return diaryList; return symbolList;
} }
/** /**
* Resets a to-many relationship, making the next get call to query for a fresh result. * Resets a to-many relationship, making the next get call to query for a fresh result.
*/ */
@Generated(hash = 1078514341) @Generated(hash = 1716801695)
public synchronized void resetDiaryList() { public synchronized void resetSymbolList() {
diaryList = null; symbolList = null;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 1800750450)
public List<Subject> getSubjectList() {
if (subjectList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
SubjectDao targetDao = daoSession.getSubjectDao();
List<Subject> subjectListNew = targetDao._queryAccount_SubjectList(id);
synchronized (this) {
if (subjectList == null) {
subjectList = subjectListNew;
}
}
}
return subjectList;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 594294258)
public synchronized void resetSubjectList() {
subjectList = null;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 1040074549)
public List<Grade> getGradeList() {
if (gradeList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
GradeDao targetDao = daoSession.getGradeDao();
List<Grade> gradeListNew = targetDao._queryAccount_GradeList(id);
synchronized (this) {
if (gradeList == null) {
gradeList = gradeListNew;
}
}
}
return gradeList;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1939990047)
public synchronized void resetGradeList() {
gradeList = null;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 300459794)
public List<Day> getDayList() {
if (dayList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
DayDao targetDao = daoSession.getDayDao();
List<Day> dayListNew = targetDao._queryAccount_DayList(id);
synchronized (this) {
if (dayList == null) {
dayList = dayListNew;
}
}
}
return dayList;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1010399236)
public synchronized void resetDayList() {
dayList = null;
} }
/** /**

View File

@ -20,38 +20,38 @@ public class AttendanceLesson implements Serializable {
@Id(autoincrement = true) @Id(autoincrement = true)
private Long id; private Long id;
@Property(nameInDb = "DAY_ID") @Property(nameInDb = "day_id")
private Long dayId; private Long dayId;
@Property(nameInDb = "DATE") @Property(nameInDb = "date")
private String date = ""; private String date = "";
@Property(nameInDb = "NUMBER_OF_LESSON") @Property(nameInDb = "number_of_lesson")
private int number = 0; private int number = 0;
@Property(nameInDb = "SUBJECT_NAME") @Property(nameInDb = "subject")
private String subject = ""; private String subject = "";
@Property(nameInDb = "IS_PRESENCE") @Property(nameInDb = "presence")
private boolean isPresence = false; private boolean presence = false;
@Property(nameInDb = "IS_ABSENCE_UNEXCUSED") @Property(nameInDb = "absence_unexcused")
private boolean isAbsenceUnexcused = false; private boolean absenceUnexcused = false;
@Property(nameInDb = "IS_ABSENCE_EXCUSED") @Property(nameInDb = "absence_excused")
private boolean isAbsenceExcused = false; private boolean absenceExcused = false;
@Property(nameInDb = "IS_UNEXCUSED_LATENESS") @Property(nameInDb = "unexcused_lateness")
private boolean isUnexcusedLateness = false; private boolean unexcusedLateness = false;
@Property(nameInDb = "IS_ABSENCE_FOR_SCHOOL_REASONS") @Property(nameInDb = "absence_for_school_reasons")
private boolean isAbsenceForSchoolReasons = false; private boolean absenceForSchoolReasons = false;
@Property(nameInDb = "IS_EXCUSED_LATENESS") @Property(nameInDb = "excused_lateness")
private boolean isExcusedLateness = false; private boolean excusedLateness = false;
@Property(nameInDb = "IS_EXEMPTION") @Property(nameInDb = "exemption")
private boolean isExemption = false; private boolean exemption = false;
@Transient @Transient
private String description = ""; private String description = "";
@ -70,24 +70,24 @@ public class AttendanceLesson implements Serializable {
@Generated(hash = 1936953859) @Generated(hash = 1936953859)
private transient AttendanceLessonDao myDao; private transient AttendanceLessonDao myDao;
@Generated(hash = 1428129046) @Generated(hash = 1741231228)
public AttendanceLesson(Long id, Long dayId, String date, int number, public AttendanceLesson(Long id, Long dayId, String date, int number,
String subject, boolean isPresence, boolean isAbsenceUnexcused, String subject, boolean presence, boolean absenceUnexcused,
boolean isAbsenceExcused, boolean isUnexcusedLateness, boolean absenceExcused, boolean unexcusedLateness,
boolean isAbsenceForSchoolReasons, boolean isExcusedLateness, boolean absenceForSchoolReasons, boolean excusedLateness,
boolean isExemption) { boolean exemption) {
this.id = id; this.id = id;
this.dayId = dayId; this.dayId = dayId;
this.date = date; this.date = date;
this.number = number; this.number = number;
this.subject = subject; this.subject = subject;
this.isPresence = isPresence; this.presence = presence;
this.isAbsenceUnexcused = isAbsenceUnexcused; this.absenceUnexcused = absenceUnexcused;
this.isAbsenceExcused = isAbsenceExcused; this.absenceExcused = absenceExcused;
this.isUnexcusedLateness = isUnexcusedLateness; this.unexcusedLateness = unexcusedLateness;
this.isAbsenceForSchoolReasons = isAbsenceForSchoolReasons; this.absenceForSchoolReasons = absenceForSchoolReasons;
this.isExcusedLateness = isExcusedLateness; this.excusedLateness = excusedLateness;
this.isExemption = isExemption; this.exemption = exemption;
} }
@Generated(hash = 921806575) @Generated(hash = 921806575)
@ -137,66 +137,66 @@ public class AttendanceLesson implements Serializable {
return this; return this;
} }
public boolean getIsPresence() { public boolean getPresence() {
return this.isPresence; return this.presence;
} }
public AttendanceLesson setIsPresence(boolean isPresence) { public AttendanceLesson setPresence(boolean presence) {
this.isPresence = isPresence; this.presence = presence;
return this; return this;
} }
public boolean getIsAbsenceUnexcused() { public boolean getAbsenceUnexcused() {
return this.isAbsenceUnexcused; return this.absenceUnexcused;
} }
public AttendanceLesson setIsAbsenceUnexcused(boolean isAbsenceUnexcused) { public AttendanceLesson setAbsenceUnexcused(boolean absenceUnexcused) {
this.isAbsenceUnexcused = isAbsenceUnexcused; this.absenceUnexcused = absenceUnexcused;
return this; return this;
} }
public boolean getIsAbsenceExcused() { public boolean getAbsenceExcused() {
return this.isAbsenceExcused; return this.absenceExcused;
} }
public AttendanceLesson setIsAbsenceExcused(boolean isAbsenceExcused) { public AttendanceLesson setAbsenceExcused(boolean absenceExcused) {
this.isAbsenceExcused = isAbsenceExcused; this.absenceExcused = absenceExcused;
return this; return this;
} }
public boolean getIsUnexcusedLateness() { public boolean getUnexcusedLateness() {
return this.isUnexcusedLateness; return this.unexcusedLateness;
} }
public AttendanceLesson setIsUnexcusedLateness(boolean isUnexcusedLateness) { public AttendanceLesson setUnexcusedLateness(boolean unexcusedLateness) {
this.isUnexcusedLateness = isUnexcusedLateness; this.unexcusedLateness = unexcusedLateness;
return this; return this;
} }
public boolean getIsAbsenceForSchoolReasons() { public boolean getAbsenceForSchoolReasons() {
return this.isAbsenceForSchoolReasons; return this.absenceForSchoolReasons;
} }
public AttendanceLesson setIsAbsenceForSchoolReasons(boolean isAbsenceForSchoolReasons) { public AttendanceLesson setAbsenceForSchoolReasons(boolean absenceForSchoolReasons) {
this.isAbsenceForSchoolReasons = isAbsenceForSchoolReasons; this.absenceForSchoolReasons = absenceForSchoolReasons;
return this; return this;
} }
public boolean getIsExcusedLateness() { public boolean getExcusedLateness() {
return this.isExcusedLateness; return this.excusedLateness;
} }
public AttendanceLesson setIsExcusedLateness(boolean isExcusedLateness) { public AttendanceLesson setExcusedLateness(boolean excusedLateness) {
this.isExcusedLateness = isExcusedLateness; this.excusedLateness = excusedLateness;
return this; return this;
} }
public boolean getIsExemption() { public boolean getExemption() {
return this.isExemption; return this.exemption;
} }
public AttendanceLesson setIsExemption(boolean isExemption) { public AttendanceLesson setExemption(boolean exemption) {
this.isExemption = isExemption; this.exemption = exemption;
return this; return this;
} }

View File

@ -5,7 +5,6 @@ import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated; import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index; import org.greenrobot.greendao.annotation.Index;
import org.greenrobot.greendao.annotation.OrderBy;
import org.greenrobot.greendao.annotation.Property; import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany; import org.greenrobot.greendao.annotation.ToMany;
@ -14,36 +13,32 @@ import java.util.List;
@Entity( @Entity(
nameInDb = "Days", nameInDb = "Days",
active = true, active = true,
indexes = {@Index(value = "userId,weekId,date", unique = true)} indexes = {@Index(value = "weekId,date", unique = true)}
) )
public class Day { public class Day {
@Id(autoincrement = true) @Id(autoincrement = true)
private Long id; private Long id;
@Property(nameInDb = "USER_ID") @Property(nameInDb = "week_id")
private Long userId;
@Property(nameInDb = "WEEK_ID")
private Long weekId; private Long weekId;
@Property(nameInDb = "DATE") @Property(nameInDb = "date")
private String date = ""; private String date = "";
@Property(nameInDb = "DAY_NAME") @Property(nameInDb = "day_name")
private String dayName = ""; private String dayName = "";
@Property(nameInDb = "IS_FREE_DAY") @Property(nameInDb = "free_day")
private boolean isFreeDay = false; private boolean freeDay = false;
@Property(nameInDb = "FREE_DAY_NAME") @Property(nameInDb = "free_day_name")
private String freeDayName = ""; private String freeDayName = "";
@ToMany(referencedJoinProperty = "dayId") @ToMany(referencedJoinProperty = "dayId")
private List<TimetableLesson> timetableLessons; private List<TimetableLesson> timetableLessons;
@ToMany(referencedJoinProperty = "dayId") @ToMany(referencedJoinProperty = "dayId")
@OrderBy("number ASC")
private List<AttendanceLesson> attendanceLessons; private List<AttendanceLesson> attendanceLessons;
/** /**
@ -58,15 +53,14 @@ public class Day {
@Generated(hash = 312167767) @Generated(hash = 312167767)
private transient DayDao myDao; private transient DayDao myDao;
@Generated(hash = 723729681) @Generated(hash = 523139020)
public Day(Long id, Long userId, Long weekId, String date, String dayName, public Day(Long id, Long weekId, String date, String dayName, boolean freeDay,
boolean isFreeDay, String freeDayName) { String freeDayName) {
this.id = id; this.id = id;
this.userId = userId;
this.weekId = weekId; this.weekId = weekId;
this.date = date; this.date = date;
this.dayName = dayName; this.dayName = dayName;
this.isFreeDay = isFreeDay; this.freeDay = freeDay;
this.freeDayName = freeDayName; this.freeDayName = freeDayName;
} }
@ -82,26 +76,16 @@ public class Day {
this.id = id; this.id = id;
} }
public Long getUserId() {
return userId;
}
public Long getWeekId() { public Long getWeekId() {
return weekId; return this.weekId;
} }
public Day setWeekId(Long weekId) { public void setWeekId(Long weekId) {
this.weekId = weekId; this.weekId = weekId;
return this;
}
public Day setUserId(Long userId) {
this.userId = userId;
return this;
} }
public String getDate() { public String getDate() {
return date; return this.date;
} }
public Day setDate(String date) { public Day setDate(String date) {
@ -110,7 +94,7 @@ public class Day {
} }
public String getDayName() { public String getDayName() {
return dayName; return this.dayName;
} }
public Day setDayName(String dayName) { public Day setDayName(String dayName) {
@ -118,17 +102,17 @@ public class Day {
return this; return this;
} }
public boolean getIsFreeDay() { public boolean getFreeDay() {
return this.isFreeDay; return this.freeDay;
} }
public Day setIsFreeDay(boolean isFreeDay) { public Day setFreeDay(boolean freeDay) {
this.isFreeDay = isFreeDay; this.freeDay = freeDay;
return this; return this;
} }
public String getFreeDayName() { public String getFreeDayName() {
return freeDayName; return this.freeDayName;
} }
public Day setFreeDayName(String freeDayName) { public Day setFreeDayName(String freeDayName) {
@ -159,7 +143,9 @@ public class Day {
return timetableLessons; return timetableLessons;
} }
/** Resets a to-many relationship, making the next get call to query for a fresh result. */ /**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1687683740) @Generated(hash = 1687683740)
public synchronized void resetTimetableLessons() { public synchronized void resetTimetableLessons() {
timetableLessons = null; timetableLessons = null;
@ -188,7 +174,9 @@ public class Day {
return attendanceLessons; return attendanceLessons;
} }
/** Resets a to-many relationship, making the next get call to query for a fresh result. */ /**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1343075564) @Generated(hash = 1343075564)
public synchronized void resetAttendanceLessons() { public synchronized void resetAttendanceLessons() {
attendanceLessons = null; attendanceLessons = null;

View File

@ -5,6 +5,9 @@ import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated; import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property; import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany;
import java.util.List;
@Entity( @Entity(
nameInDb = "Diaries", nameInDb = "Diaries",
@ -15,17 +18,20 @@ public class Diary {
@Id(autoincrement = true) @Id(autoincrement = true)
private Long id; private Long id;
@Property(nameInDb = "STUDENT_ID") @Property(nameInDb = "student_id")
private String studentId; private Long studentId;
@Property(nameInDb = "NAME") @Property(nameInDb = "current")
private boolean current;
@Property(nameInDb = "name")
private String name; private String name;
@Property(nameInDb = "VALUE") @Property(nameInDb = "value")
private String value; private String value;
@Property(nameInDb = "IS_CURRENT") @ToMany(referencedJoinProperty = "diaryId")
private boolean isCurrent; private List<Semester> semesterList;
/** /**
* Used to resolve relations * Used to resolve relations
@ -39,14 +45,13 @@ public class Diary {
@Generated(hash = 21166549) @Generated(hash = 21166549)
private transient DiaryDao myDao; private transient DiaryDao myDao;
@Generated(hash = 459332202) @Generated(hash = 277096196)
public Diary(Long id, String studentId, String name, String value, public Diary(Long id, Long studentId, boolean current, String name, String value) {
boolean isCurrent) {
this.id = id; this.id = id;
this.studentId = studentId; this.studentId = studentId;
this.current = current;
this.name = name; this.name = name;
this.value = value; this.value = value;
this.isCurrent = isCurrent;
} }
@Generated(hash = 112123061) @Generated(hash = 112123061)
@ -54,25 +59,24 @@ public class Diary {
} }
public Long getId() { public Long getId() {
return id; return this.id;
} }
public Diary setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
return this;
} }
public String getStudentId() { public Long getStudentId() {
return studentId; return this.studentId;
} }
public Diary setStudentId(String studentId) { public Diary setStudentId(Long studentId) {
this.studentId = studentId; this.studentId = studentId;
return this; return this;
} }
public String getName() { public String getName() {
return name; return this.name;
} }
public Diary setName(String name) { public Diary setName(String name) {
@ -81,7 +85,7 @@ public class Diary {
} }
public String getValue() { public String getValue() {
return value; return this.value;
} }
public Diary setValue(String value) { public Diary setValue(String value) {
@ -89,31 +93,43 @@ public class Diary {
return this; return this;
} }
public boolean getIsCurrent() { public boolean getCurrent() {
return isCurrent; return this.current;
} }
public Diary setIsCurrent(boolean current) { public Diary setCurrent(boolean current) {
isCurrent = current; this.current = current;
return this; return this;
} }
public DaoSession getDaoSession() { /**
return daoSession; * To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 1738383053)
public List<Semester> getSemesterList() {
if (semesterList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
SemesterDao targetDao = daoSession.getSemesterDao();
List<Semester> semesterListNew = targetDao._queryDiary_SemesterList(id);
synchronized (this) {
if (semesterList == null) {
semesterList = semesterListNew;
}
}
}
return semesterList;
} }
public Diary setDaoSession(DaoSession daoSession) { /**
this.daoSession = daoSession; * Resets a to-many relationship, making the next get call to query for a fresh result.
return this; */
} @Generated(hash = 995060657)
public synchronized void resetSemesterList() {
public DiaryDao getMyDao() { semesterList = null;
return myDao;
}
public Diary setMyDao(DiaryDao myDao) {
this.myDao = myDao;
return this;
} }
/** /**

View File

@ -21,72 +21,44 @@ public class Grade implements Serializable {
@Id(autoincrement = true) @Id(autoincrement = true)
protected Long id; protected Long id;
@Property(nameInDb = "SUBJECT_ID") @Property(nameInDb = "semester_id")
private Long semesterId;
@Property(nameInDb = "subject_id")
private Long subjectId; private Long subjectId;
@Property(nameInDb = "USER_ID") @Property(nameInDb = "subject")
private Long userId;
@Property(nameInDb = "SUBJECT")
private String subject = ""; private String subject = "";
@Property(nameInDb = "VALUE") @Property(nameInDb = "value")
protected String value = ""; protected String value = "";
@Property(nameInDb = "COLOR") @Property(nameInDb = "weight")
private String color = "";
@Property(nameInDb = "SYMBOL")
private String symbol = "";
@Property(nameInDb = "DESCRIPTION")
private String description = "";
@Property(nameInDb = "WEIGHT")
private String weight = ""; private String weight = "";
@Property(nameInDb = "DATE") @Property(nameInDb = "date")
private String date = ""; private String date = "";
@Property(nameInDb = "TEACHER") @Property(nameInDb = "symbol")
private String symbol = "";
@Property(nameInDb = "color")
private String color = "";
@Property(nameInDb = "description")
private String description = "";
@Property(nameInDb = "teacher")
private String teacher = ""; private String teacher = "";
@Property(nameInDb = "SEMESTER") @Property(nameInDb = "is_new")
private String semester = "";
@Property(nameInDb = "IS_NEW")
private boolean isNew = false; private boolean isNew = false;
@Property(nameInDb = "READ") @Property(nameInDb = "read")
private boolean read = true; private boolean read = true;
private static final long serialVersionUID = 42L; private static final long serialVersionUID = 42L;
@Generated(hash = 568899968)
public Grade(Long id, Long subjectId, Long userId, String subject, String value,
String color, String symbol, String description, String weight,
String date, String teacher, String semester, boolean isNew,
boolean read) {
this.id = id;
this.subjectId = subjectId;
this.userId = userId;
this.subject = subject;
this.value = value;
this.color = color;
this.symbol = symbol;
this.description = description;
this.weight = weight;
this.date = date;
this.teacher = teacher;
this.semester = semester;
this.isNew = isNew;
this.read = read;
}
@Generated(hash = 2042976393)
public Grade() {
}
/** /**
* Used to resolve relations * Used to resolve relations
*/ */
@ -99,6 +71,29 @@ public class Grade implements Serializable {
@Generated(hash = 681281562) @Generated(hash = 681281562)
private transient GradeDao myDao; private transient GradeDao myDao;
@Generated(hash = 2042976393)
public Grade() {
}
@Generated(hash = 619853992)
public Grade(Long id, Long semesterId, Long subjectId, String subject, String value,
String weight, String date, String symbol, String color, String description,
String teacher, boolean isNew, boolean read) {
this.id = id;
this.semesterId = semesterId;
this.subjectId = subjectId;
this.subject = subject;
this.value = value;
this.weight = weight;
this.date = date;
this.symbol = symbol;
this.color = color;
this.description = description;
this.teacher = teacher;
this.isNew = isNew;
this.read = read;
}
public int getValueColor() { public int getValueColor() {
String replacedString = value.replaceAll("[^0-9]", ""); String replacedString = value.replaceAll("[^0-9]", "");
@ -133,6 +128,7 @@ public class Grade implements Serializable {
Grade grade = (Grade) o; Grade grade = (Grade) o;
return new EqualsBuilder() return new EqualsBuilder()
.append(semesterId, grade.semesterId)
.append(subject, grade.subject) .append(subject, grade.subject)
.append(value, grade.value) .append(value, grade.value)
.append(color, grade.color) .append(color, grade.color)
@ -141,13 +137,13 @@ public class Grade implements Serializable {
.append(weight, grade.weight) .append(weight, grade.weight)
.append(date, grade.date) .append(date, grade.date)
.append(teacher, grade.teacher) .append(teacher, grade.teacher)
.append(semester, grade.semester)
.isEquals(); .isEquals();
} }
@Override @Override
public int hashCode() { public int hashCode() {
return new HashCodeBuilder(17, 37) return new HashCodeBuilder(17, 37)
.append(semesterId)
.append(subject) .append(subject)
.append(value) .append(value)
.append(color) .append(color)
@ -156,48 +152,19 @@ public class Grade implements Serializable {
.append(weight) .append(weight)
.append(date) .append(date)
.append(teacher) .append(teacher)
.append(semester)
.toHashCode(); .toHashCode();
} }
public Long getId() { public Long getId() {
return id; return this.id;
} }
public Grade setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
return this;
}
public Long getSubjectId() {
return subjectId;
}
public Grade setSubjectId(Long subjectId) {
this.subjectId = subjectId;
return this;
}
public Long getUserId() {
return userId;
}
public Grade setUserId(Long userId) {
this.userId = userId;
return this;
}
public String getSubject() {
return subject;
}
public Grade setSubject(String subject) {
this.subject = subject;
return this;
} }
public String getValue() { public String getValue() {
return value; return this.value;
} }
public Grade setValue(String value) { public Grade setValue(String value) {
@ -205,8 +172,26 @@ public class Grade implements Serializable {
return this; return this;
} }
public Long getSemesterId() {
return this.semesterId;
}
public Grade setSemesterId(Long semesterId) {
this.semesterId = semesterId;
return this;
}
public String getSubject() {
return this.subject;
}
public Grade setSubject(String subject) {
this.subject = subject;
return this;
}
public String getColor() { public String getColor() {
return color; return this.color;
} }
public Grade setColor(String color) { public Grade setColor(String color) {
@ -215,7 +200,7 @@ public class Grade implements Serializable {
} }
public String getSymbol() { public String getSymbol() {
return symbol; return this.symbol;
} }
public Grade setSymbol(String symbol) { public Grade setSymbol(String symbol) {
@ -224,7 +209,7 @@ public class Grade implements Serializable {
} }
public String getDescription() { public String getDescription() {
return description; return this.description;
} }
public Grade setDescription(String description) { public Grade setDescription(String description) {
@ -233,7 +218,7 @@ public class Grade implements Serializable {
} }
public String getWeight() { public String getWeight() {
return weight; return this.weight;
} }
public Grade setWeight(String weight) { public Grade setWeight(String weight) {
@ -242,7 +227,7 @@ public class Grade implements Serializable {
} }
public String getDate() { public String getDate() {
return date; return this.date;
} }
public Grade setDate(String date) { public Grade setDate(String date) {
@ -251,7 +236,7 @@ public class Grade implements Serializable {
} }
public String getTeacher() { public String getTeacher() {
return teacher; return this.teacher;
} }
public Grade setTeacher(String teacher) { public Grade setTeacher(String teacher) {
@ -259,22 +244,12 @@ public class Grade implements Serializable {
return this; return this;
} }
public String getSemester() {
return semester;
}
public Grade setSemester(String semester) {
this.semester = semester;
return this;
}
public boolean getIsNew() { public boolean getIsNew() {
return this.isNew; return this.isNew;
} }
public Grade setIsNew(boolean isNew) { public void setIsNew(boolean isNew) {
this.isNew = isNew; this.isNew = isNew;
return this;
} }
public boolean getRead() { public boolean getRead() {
@ -286,6 +261,17 @@ public class Grade implements Serializable {
return this; return this;
} }
public Long getSubjectId() {
return this.subjectId;
}
public void setSubjectId(Long subjectId) {
this.subjectId = subjectId;
}
/** /**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}. * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context. * Entity must attached to an entity context.
@ -298,6 +284,7 @@ public class Grade implements Serializable {
myDao.delete(this); myDao.delete(this);
} }
/** /**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}. * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context. * Entity must attached to an entity context.
@ -310,6 +297,7 @@ public class Grade implements Serializable {
myDao.refresh(this); myDao.refresh(this);
} }
/** /**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}. * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context. * Entity must attached to an entity context.
@ -322,6 +310,7 @@ public class Grade implements Serializable {
myDao.update(this); myDao.update(this);
} }
/** called by internal mechanisms, do not call yourself. */ /** called by internal mechanisms, do not call yourself. */
@Generated(hash = 1187286414) @Generated(hash = 1187286414)
public void __setDaoSession(DaoSession daoSession) { public void __setDaoSession(DaoSession daoSession) {

View File

@ -0,0 +1,208 @@
package io.github.wulkanowy.data.db.dao.entities;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany;
import java.util.List;
@Entity(
nameInDb = "Semesters",
active = true
)
public class Semester {
@Id(autoincrement = true)
private Long id;
@Property(nameInDb = "diary_id")
private Long diaryId;
@Property(nameInDb = "current")
private boolean current;
@Property(nameInDb = "name")
private String name;
@Property(nameInDb = "value")
private String value;
@ToMany(referencedJoinProperty = "semesterId")
private List<Subject> subjectList;
@ToMany(referencedJoinProperty = "semesterId")
private List<Grade> gradeList;
/**
* Used to resolve relations
*/
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/**
* Used for active entity operations.
*/
@Generated(hash = 282930393)
private transient SemesterDao myDao;
@Generated(hash = 1661077309)
public Semester(Long id, Long diaryId, boolean current, String name, String value) {
this.id = id;
this.diaryId = diaryId;
this.current = current;
this.name = name;
this.value = value;
}
@Generated(hash = 58335877)
public Semester() {
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Long getDiaryId() {
return this.diaryId;
}
public Semester setDiaryId(Long diaryId) {
this.diaryId = diaryId;
return this;
}
public String getName() {
return this.name;
}
public Semester setName(String name) {
this.name = name;
return this;
}
public String getValue() {
return this.value;
}
public Semester setValue(String value) {
this.value = value;
return this;
}
public boolean getCurrent() {
return this.current;
}
public Semester setCurrent(boolean current) {
this.current = current;
return this;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 723353662)
public List<Subject> getSubjectList() {
if (subjectList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
SubjectDao targetDao = daoSession.getSubjectDao();
List<Subject> subjectListNew = targetDao._querySemester_SubjectList(id);
synchronized (this) {
if (subjectList == null) {
subjectList = subjectListNew;
}
}
}
return subjectList;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 594294258)
public synchronized void resetSubjectList() {
subjectList = null;
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 390330007)
public List<Grade> getGradeList() {
if (gradeList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
GradeDao targetDao = daoSession.getGradeDao();
List<Grade> gradeListNew = targetDao._querySemester_GradeList(id);
synchronized (this) {
if (gradeList == null) {
gradeList = gradeListNew;
}
}
}
return gradeList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
@Generated(hash = 1939990047)
public synchronized void resetGradeList() {
gradeList = null;
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 676204164)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getSemesterDao() : null;
}
}

View File

@ -0,0 +1,178 @@
package io.github.wulkanowy.data.db.dao.entities;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany;
import java.util.List;
@Entity(
nameInDb = "Students",
active = true
)
public class Student {
@Id(autoincrement = true)
private Long id;
@Property(nameInDb = "symbol_id")
private Long symbolId;
@Property(nameInDb = "current")
private boolean current;
@Property(nameInDb = "real_id")
private String realId;
@Property(nameInDb = "name")
private String name;
@ToMany(referencedJoinProperty = "studentId")
private List<Diary> diaryList;
/**
* Used to resolve relations
*/
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/**
* Used for active entity operations.
*/
@Generated(hash = 1943931642)
private transient StudentDao myDao;
@Generated(hash = 1334215952)
public Student(Long id, Long symbolId, boolean current, String realId, String name) {
this.id = id;
this.symbolId = symbolId;
this.current = current;
this.realId = realId;
this.name = name;
}
@Generated(hash = 1556870573)
public Student() {
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Long getSymbolId() {
return this.symbolId;
}
public Student setSymbolId(Long symbolId) {
this.symbolId = symbolId;
return this;
}
public String getRealId() {
return this.realId;
}
public Student setRealId(String realId) {
this.realId = realId;
return this;
}
public String getName() {
return this.name;
}
public Student setName(String name) {
this.name = name;
return this;
}
public boolean getCurrent() {
return this.current;
}
public Student setCurrent(boolean current) {
this.current = current;
return this;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 508305571)
public List<Diary> getDiaryList() {
if (diaryList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
DiaryDao targetDao = daoSession.getDiaryDao();
List<Diary> diaryListNew = targetDao._queryStudent_DiaryList(id);
synchronized (this) {
if (diaryList == null) {
diaryList = diaryListNew;
}
}
}
return diaryList;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1078514341)
public synchronized void resetDiaryList() {
diaryList = null;
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 1701634981)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getStudentDao() : null;
}
}

View File

@ -18,21 +18,18 @@ public class Subject {
@Id(autoincrement = true) @Id(autoincrement = true)
private Long id; private Long id;
@Property(nameInDb = "USER_ID") @Property(nameInDb = "semester_id")
private Long userId; private Long semesterId;
@Property(nameInDb = "NAME") @Property(nameInDb = "name")
private String name; private String name;
@Property(nameInDb = "PREDICTED_RATING") @Property(nameInDb = "predicted_rating")
private String predictedRating; private String predictedRating;
@Property(nameInDb = "FINAL_RATING") @Property(nameInDb = "final_rating")
private String finalRating; private String finalRating;
@Property(nameInDb = "SEMESTER")
private String semester;
@ToMany(referencedJoinProperty = "subjectId") @ToMany(referencedJoinProperty = "subjectId")
private List<Grade> gradeList; private List<Grade> gradeList;
@ -48,15 +45,14 @@ public class Subject {
@Generated(hash = 1644932788) @Generated(hash = 1644932788)
private transient SubjectDao myDao; private transient SubjectDao myDao;
@Generated(hash = 396325764) @Generated(hash = 1817932538)
public Subject(Long id, Long userId, String name, String predictedRating, public Subject(Long id, Long semesterId, String name, String predictedRating,
String finalRating, String semester) { String finalRating) {
this.id = id; this.id = id;
this.userId = userId; this.semesterId = semesterId;
this.name = name; this.name = name;
this.predictedRating = predictedRating; this.predictedRating = predictedRating;
this.finalRating = finalRating; this.finalRating = finalRating;
this.semester = semester;
} }
@Generated(hash = 1617906264) @Generated(hash = 1617906264)
@ -64,25 +60,24 @@ public class Subject {
} }
public Long getId() { public Long getId() {
return id; return this.id;
} }
public Subject setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
return this;
} }
public Long getUserId() { public Long getSemesterId() {
return userId; return this.semesterId;
} }
public Subject setUserId(Long userId) { public Subject setSemesterId(Long semesterId) {
this.userId = userId; this.semesterId = semesterId;
return this; return this;
} }
public String getName() { public String getName() {
return name; return this.name;
} }
public Subject setName(String name) { public Subject setName(String name) {
@ -91,7 +86,7 @@ public class Subject {
} }
public String getPredictedRating() { public String getPredictedRating() {
return predictedRating; return this.predictedRating;
} }
public Subject setPredictedRating(String predictedRating) { public Subject setPredictedRating(String predictedRating) {
@ -100,7 +95,7 @@ public class Subject {
} }
public String getFinalRating() { public String getFinalRating() {
return finalRating; return this.finalRating;
} }
public Subject setFinalRating(String finalRating) { public Subject setFinalRating(String finalRating) {
@ -108,45 +103,6 @@ public class Subject {
return this; return this;
} }
public String getSemester() {
return semester;
}
public Subject setSemester(String semester) {
this.semester = semester;
return this;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 1358847893)
public List<Grade> getGradeList() {
if (gradeList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
GradeDao targetDao = daoSession.getGradeDao();
List<Grade> gradeListNew = targetDao._querySubject_GradeList(id);
synchronized (this) {
if (gradeList == null) {
gradeList = gradeListNew;
}
}
}
return gradeList;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1939990047)
public synchronized void resetGradeList() {
gradeList = null;
}
/** /**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}. * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context. * Entity must attached to an entity context.
@ -183,6 +139,34 @@ public class Subject {
myDao.update(this); myDao.update(this);
} }
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 1358847893)
public List<Grade> getGradeList() {
if (gradeList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
GradeDao targetDao = daoSession.getGradeDao();
List<Grade> gradeListNew = targetDao._querySubject_GradeList(id);
synchronized (this) {
if (gradeList == null) {
gradeList = gradeListNew;
}
}
}
return gradeList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
@Generated(hash = 1939990047)
public synchronized void resetGradeList() {
gradeList = null;
}
/** called by internal mechanisms, do not call yourself. */ /** called by internal mechanisms, do not call yourself. */
@Generated(hash = 937984622) @Generated(hash = 937984622)
public void __setDaoSession(DaoSession daoSession) { public void __setDaoSession(DaoSession daoSession) {

View File

@ -0,0 +1,191 @@
package io.github.wulkanowy.data.db.dao.entities;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany;
import java.util.List;
@Entity(
nameInDb = "Symbols",
active = true
)
public class Symbol {
@Id(autoincrement = true)
private Long id;
@Property(nameInDb = "user_id")
private Long userId;
@Property(nameInDb = "host")
private String host;
@Property(nameInDb = "school_id")
private String schoolId;
@Property(nameInDb = "symbol")
private String symbol;
@Property(nameInDb = "type")
private String type;
@ToMany(referencedJoinProperty = "symbolId")
private List<Student> studentList;
/**
* Used to resolve relations
*/
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/**
* Used for active entity operations.
*/
@Generated(hash = 684907977)
private transient SymbolDao myDao;
@Generated(hash = 242774339)
public Symbol(Long id, Long userId, String host, String schoolId, String symbol,
String type) {
this.id = id;
this.userId = userId;
this.host = host;
this.schoolId = schoolId;
this.symbol = symbol;
this.type = type;
}
@Generated(hash = 460475327)
public Symbol() {
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return this.userId;
}
public Symbol setUserId(Long userId) {
this.userId = userId;
return this;
}
public String getHost() {
return this.host;
}
public Symbol setHost(String host) {
this.host = host;
return this;
}
public String getSchoolId() {
return this.schoolId;
}
public Symbol setSchoolId(String schoolId) {
this.schoolId = schoolId;
return this;
}
public String getSymbol() {
return this.symbol;
}
public Symbol setSymbol(String symbol) {
this.symbol = symbol;
return this;
}
public String getType() {
return this.type;
}
public Symbol setType(String type) {
this.type = type;
return this;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 604366458)
public List<Student> getStudentList() {
if (studentList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
StudentDao targetDao = daoSession.getStudentDao();
List<Student> studentListNew = targetDao._querySymbol_StudentList(id);
synchronized (this) {
if (studentList == null) {
studentList = studentListNew;
}
}
}
return studentList;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1628625923)
public synchronized void resetStudentList() {
studentList = null;
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 632145708)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getSymbolDao() : null;
}
}

View File

@ -16,58 +16,58 @@ import java.io.Serializable;
) )
public class TimetableLesson implements Serializable { public class TimetableLesson implements Serializable {
private static final long serialVersionUID = 42L;
@Id(autoincrement = true) @Id(autoincrement = true)
private Long id; private Long id;
@Property(nameInDb = "DAY_ID") @Property(nameInDb = "day_id")
private Long dayId; private Long dayId;
@Property(nameInDb = "NUMBER_OF_LESSON") @Property(nameInDb = "number")
private String number; private String number;
@Property(nameInDb = "SUBJECT_NAME") @Property(nameInDb = "subject")
private String subject = ""; private String subject = "";
@Property(nameInDb = "TEACHER") @Property(nameInDb = "teacher")
private String teacher = ""; private String teacher = "";
@Property(nameInDb = "ROOM") @Property(nameInDb = "room")
private String room = ""; private String room = "";
@Property(nameInDb = "DESCRIPTION") @Property(nameInDb = "description")
private String description = ""; private String description = "";
@Property(nameInDb = "GROUP_NAME") @Property(nameInDb = "group")
private String groupName = ""; private String group = "";
@Property(nameInDb = "START_TIME") @Property(nameInDb = "start_time")
private String startTime = ""; private String startTime = "";
@Property(nameInDb = "END_TIME") @Property(nameInDb = "end_time")
private String endTime = ""; private String endTime = "";
@Property(nameInDb = "DATE") @Property(nameInDb = "date")
private String date = ""; private String date = "";
@Property(nameInDb = "IS_EMPTY") @Property(nameInDb = "empty")
private boolean isEmpty = false; private boolean empty = false;
@Property(nameInDb = "IS_DIVISION_INTO_GROUP") @Property(nameInDb = "division_into_groups")
private boolean isDivisionIntoGroups = false; private boolean divisionIntoGroups = false;
@Property(nameInDb = "IS_PLANNING") @Property(nameInDb = "planning")
private boolean isPlanning = false; private boolean planning = false;
@Property(nameInDb = "IS_REALIZED") @Property(nameInDb = "realized")
private boolean isRealized = false; private boolean realized = false;
@Property(nameInDb = "IS_MOVED_CANCELED") @Property(nameInDb = "moved_canceled")
private boolean isMovedOrCanceled = false; private boolean movedOrCanceled = false;
@Property(nameInDb = "IS_NEW_MOVED_IN_CANCELED") @Property(nameInDb = "new_moved_in_canceled")
private boolean isNewMovedInOrChanged = false; private boolean newMovedInOrChanged = false;
private static final long serialVersionUID = 42L;
/** /**
* Used to resolve relations * Used to resolve relations
@ -81,12 +81,12 @@ public class TimetableLesson implements Serializable {
@Generated(hash = 1119360138) @Generated(hash = 1119360138)
private transient TimetableLessonDao myDao; private transient TimetableLessonDao myDao;
@Generated(hash = 627457324) @Generated(hash = 1955911128)
public TimetableLesson(Long id, Long dayId, String number, String subject, public TimetableLesson(Long id, Long dayId, String number, String subject,
String teacher, String room, String description, String groupName, String teacher, String room, String description, String group,
String startTime, String endTime, String date, boolean isEmpty, String startTime, String endTime, String date, boolean empty,
boolean isDivisionIntoGroups, boolean isPlanning, boolean isRealized, boolean divisionIntoGroups, boolean planning, boolean realized,
boolean isMovedOrCanceled, boolean isNewMovedInOrChanged) { boolean movedOrCanceled, boolean newMovedInOrChanged) {
this.id = id; this.id = id;
this.dayId = dayId; this.dayId = dayId;
this.number = number; this.number = number;
@ -94,16 +94,16 @@ public class TimetableLesson implements Serializable {
this.teacher = teacher; this.teacher = teacher;
this.room = room; this.room = room;
this.description = description; this.description = description;
this.groupName = groupName; this.group = group;
this.startTime = startTime; this.startTime = startTime;
this.endTime = endTime; this.endTime = endTime;
this.date = date; this.date = date;
this.isEmpty = isEmpty; this.empty = empty;
this.isDivisionIntoGroups = isDivisionIntoGroups; this.divisionIntoGroups = divisionIntoGroups;
this.isPlanning = isPlanning; this.planning = planning;
this.isRealized = isRealized; this.realized = realized;
this.isMovedOrCanceled = isMovedOrCanceled; this.movedOrCanceled = movedOrCanceled;
this.isNewMovedInOrChanged = isNewMovedInOrChanged; this.newMovedInOrChanged = newMovedInOrChanged;
} }
@Generated(hash = 1878030142) @Generated(hash = 1878030142)
@ -122,8 +122,9 @@ public class TimetableLesson implements Serializable {
return this.dayId; return this.dayId;
} }
public void setDayId(Long dayId) { public TimetableLesson setDayId(Long dayId) {
this.dayId = dayId; this.dayId = dayId;
return this;
} }
public String getNumber() { public String getNumber() {
@ -171,12 +172,12 @@ public class TimetableLesson implements Serializable {
return this; return this;
} }
public String getGroupName() { public String getGroup() {
return this.groupName; return this.group;
} }
public TimetableLesson setGroupName(String groupName) { public TimetableLesson setGroup(String group) {
this.groupName = groupName; this.group = group;
return this; return this;
} }
@ -207,57 +208,57 @@ public class TimetableLesson implements Serializable {
return this; return this;
} }
public boolean getIsEmpty() { public boolean getEmpty() {
return this.isEmpty; return this.empty;
} }
public TimetableLesson setEmpty(boolean isEmpty) { public TimetableLesson setEmpty(boolean empty) {
this.isEmpty = isEmpty; this.empty = empty;
return this; return this;
} }
public boolean getIsDivisionIntoGroups() { public boolean getDivisionIntoGroups() {
return this.isDivisionIntoGroups; return this.divisionIntoGroups;
} }
public TimetableLesson setDivisionIntoGroups(boolean isDivisionIntoGroups) { public TimetableLesson setDivisionIntoGroups(boolean divisionIntoGroups) {
this.isDivisionIntoGroups = isDivisionIntoGroups; this.divisionIntoGroups = divisionIntoGroups;
return this; return this;
} }
public boolean getIsPlanning() { public boolean getPlanning() {
return this.isPlanning; return this.planning;
} }
public TimetableLesson setPlanning(boolean isPlanning) { public TimetableLesson setPlanning(boolean planning) {
this.isPlanning = isPlanning; this.planning = planning;
return this; return this;
} }
public boolean getIsRealized() { public boolean getRealized() {
return this.isRealized; return this.realized;
} }
public TimetableLesson setRealized(boolean isRealized) { public TimetableLesson setRealized(boolean realized) {
this.isRealized = isRealized; this.realized = realized;
return this; return this;
} }
public boolean getIsMovedOrCanceled() { public boolean getMovedOrCanceled() {
return this.isMovedOrCanceled; return this.movedOrCanceled;
} }
public TimetableLesson setMovedOrCanceled(boolean isMovedOrCanceled) { public TimetableLesson setMovedOrCanceled(boolean movedOrCanceled) {
this.isMovedOrCanceled = isMovedOrCanceled; this.movedOrCanceled = movedOrCanceled;
return this; return this;
} }
public boolean getIsNewMovedInOrChanged() { public boolean getNewMovedInOrChanged() {
return this.isNewMovedInOrChanged; return this.newMovedInOrChanged;
} }
public TimetableLesson setNewMovedInOrChanged(boolean isNewMovedInOrChanged) { public TimetableLesson setNewMovedInOrChanged(boolean newMovedInOrChanged) {
this.isNewMovedInOrChanged = isNewMovedInOrChanged; this.newMovedInOrChanged = newMovedInOrChanged;
return this; return this;
} }
@ -297,30 +298,6 @@ public class TimetableLesson implements Serializable {
myDao.update(this); myDao.update(this);
} }
public void setIsEmpty(boolean isEmpty) {
this.isEmpty = isEmpty;
}
public void setIsDivisionIntoGroups(boolean isDivisionIntoGroups) {
this.isDivisionIntoGroups = isDivisionIntoGroups;
}
public void setIsPlanning(boolean isPlanning) {
this.isPlanning = isPlanning;
}
public void setIsRealized(boolean isRealized) {
this.isRealized = isRealized;
}
public void setIsMovedOrCanceled(boolean isMovedOrCanceled) {
this.isMovedOrCanceled = isMovedOrCanceled;
}
public void setIsNewMovedInOrChanged(boolean isNewMovedInOrChanged) {
this.isNewMovedInOrChanged = isNewMovedInOrChanged;
}
/** called by internal mechanisms, do not call yourself. */ /** called by internal mechanisms, do not call yourself. */
@Generated(hash = 1885258429) @Generated(hash = 1885258429)
public void __setDaoSession(DaoSession daoSession) { public void __setDaoSession(DaoSession daoSession) {

View File

@ -13,44 +13,48 @@ import java.util.List;
@Entity( @Entity(
nameInDb = "Weeks", nameInDb = "Weeks",
active = true, active = true,
indexes ={@Index(value = "userId,startDayDate", unique = true)} indexes = {@Index(value = "diaryId,startDayDate", unique = true)}
) )
public class Week { public class Week {
@Id(autoincrement = true) @Id(autoincrement = true)
private Long id; private Long id;
@Property(nameInDb = "USER_ID") @Property(nameInDb = "diary_id")
private Long userId; private Long diaryId;
@Property(nameInDb = "START_DATE") @Property(nameInDb = "start_day_date")
private String startDayDate = ""; private String startDayDate = "";
@Property(nameInDb = "IS_ATTENDANCE_SYNCED") @Property(nameInDb = "attendance_synced")
private boolean isAttendanceSynced = false; private boolean attendanceSynced = false;
@Property(nameInDb = "IS_TIMETABLE_SYNCED") @Property(nameInDb = "timetable_synced")
private boolean isTimetableSynced = false; private boolean timetableSynced = false;
@ToMany(referencedJoinProperty = "weekId") @ToMany(referencedJoinProperty = "weekId")
private List<Day> dayList; private List<Day> dayList;
/** Used to resolve relations */ /**
* Used to resolve relations
*/
@Generated(hash = 2040040024) @Generated(hash = 2040040024)
private transient DaoSession daoSession; private transient DaoSession daoSession;
/** Used for active entity operations. */ /**
* Used for active entity operations.
*/
@Generated(hash = 1019310398) @Generated(hash = 1019310398)
private transient WeekDao myDao; private transient WeekDao myDao;
@Generated(hash = 1745118398) @Generated(hash = 1608180902)
public Week(Long id, Long userId, String startDayDate, boolean isAttendanceSynced, public Week(Long id, Long diaryId, String startDayDate,
boolean isTimetableSynced) { boolean attendanceSynced, boolean timetableSynced) {
this.id = id; this.id = id;
this.userId = userId; this.diaryId = diaryId;
this.startDayDate = startDayDate; this.startDayDate = startDayDate;
this.isAttendanceSynced = isAttendanceSynced; this.attendanceSynced = attendanceSynced;
this.isTimetableSynced = isTimetableSynced; this.timetableSynced = timetableSynced;
} }
@Generated(hash = 2135529658) @Generated(hash = 2135529658)
@ -66,12 +70,12 @@ public class Week {
return this; return this;
} }
public Long getUserId() { public Long getDiaryId() {
return userId; return diaryId;
} }
public Week setUserId(Long userId) { public Week setDiaryId(Long diaryId) {
this.userId = userId; this.diaryId = diaryId;
return this; return this;
} }
@ -84,20 +88,22 @@ public class Week {
return this; return this;
} }
public boolean getIsAttendanceSynced() { public boolean isAttendanceSynced() {
return this.isAttendanceSynced; return attendanceSynced;
} }
public void setIsAttendanceSynced(boolean isAttendanceSynced) { public Week setAttendanceSynced(boolean attendanceSynced) {
this.isAttendanceSynced = isAttendanceSynced; this.attendanceSynced = attendanceSynced;
return this;
} }
public boolean getIsTimetableSynced() { public boolean isTimetableSynced() {
return this.isTimetableSynced; return timetableSynced;
} }
public void setIsTimetableSynced(boolean isTimetableSynced) { public Week setTimetableSynced(boolean timetableSynced) {
this.isTimetableSynced = isTimetableSynced; this.timetableSynced = timetableSynced;
return this;
} }
/** /**
@ -122,7 +128,9 @@ public class Week {
return dayList; return dayList;
} }
/** Resets a to-many relationship, making the next get call to query for a fresh result. */ /**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1010399236) @Generated(hash = 1010399236)
public synchronized void resetDayList() { public synchronized void resetDayList() {
dayList = null; dayList = null;
@ -164,6 +172,14 @@ public class Week {
myDao.update(this); myDao.update(this);
} }
public boolean getAttendanceSynced() {
return this.attendanceSynced;
}
public boolean getTimetableSynced() {
return this.timetableSynced;
}
/** called by internal mechanisms, do not call yourself. */ /** called by internal mechanisms, do not call yourself. */
@Generated(hash = 665278367) @Generated(hash = 665278367)
public void __setDaoSession(DaoSession daoSession) { public void __setDaoSession(DaoSession daoSession) {

View File

@ -100,7 +100,7 @@ public class Migration23 implements DbHelper.Migration {
private void insertDiaries(Database db, List<Diary> list) { private void insertDiaries(Database db, List<Diary> list) {
for (Diary diary : list) { for (Diary diary : list) {
db.execSQL("INSERT INTO Diaries(STUDENT_ID, NAME, VALUE, IS_CURRENT) VALUES(" + db.execSQL("INSERT INTO Diaries(STUDENT_ID, NAME, VALUE, IS_CURRENT) VALUES(" +
"\"" + diary.getStudentId() + "\"," + "\"" + diary.getId() + "\"," +
"\"" + diary.getName() + "\"," + "\"" + diary.getName() + "\"," +
"\"" + diary.getId() + "\"," + "\"" + diary.getId() + "\"," +
"\"" + (diary.isCurrent() ? "1" : "0") + "\"" + "\"" + (diary.isCurrent() ? "1" : "0") + "\"" +

View File

@ -0,0 +1,20 @@
package io.github.wulkanowy.data.db.dao.migrations;
import org.greenrobot.greendao.database.Database;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.data.db.dao.DbHelper;
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
public class Migration24 implements DbHelper.Migration {
@Override
public Integer getVersion() {
return 24;
}
@Override
public void runMigration(final Database db, final SharedPrefContract sharedPref, final Vulcan vulcan) throws Exception {
throw new Exception("No migrations");
}
}

View File

@ -62,27 +62,27 @@ public class AppResources implements ResourcesContract {
public String getAttendanceLessonDescription(AttendanceLesson lesson) { public String getAttendanceLessonDescription(AttendanceLesson lesson) {
int id = R.string.attendance_present; int id = R.string.attendance_present;
if (lesson.getIsAbsenceForSchoolReasons()) { if (lesson.getAbsenceForSchoolReasons()) {
id = R.string.attendance_absence_for_school_reasons; id = R.string.attendance_absence_for_school_reasons;
} }
if (lesson.getIsAbsenceExcused()) { if (lesson.getAbsenceExcused()) {
id = R.string.attendance_absence_excused; id = R.string.attendance_absence_excused;
} }
if (lesson.getIsAbsenceUnexcused()) { if (lesson.getAbsenceUnexcused()) {
id = R.string.attendance_absence_unexcused; id = R.string.attendance_absence_unexcused;
} }
if (lesson.getIsExemption()) { if (lesson.getExemption()) {
id = R.string.attendance_exemption; id = R.string.attendance_exemption;
} }
if (lesson.getIsExcusedLateness()) { if (lesson.getExcusedLateness()) {
id = R.string.attendance_excused_lateness; id = R.string.attendance_excused_lateness;
} }
if (lesson.getIsUnexcusedLateness()) { if (lesson.getUnexcusedLateness()) {
id = R.string.attendance_unexcused_lateness; id = R.string.attendance_unexcused_lateness;
} }

View File

@ -7,5 +7,5 @@ import io.github.wulkanowy.api.VulcanException;
public interface SyncContract { public interface SyncContract {
void sync() throws VulcanException, IOException, ParseException; void sync(long semesterId) throws VulcanException, IOException, ParseException;
} }

View File

@ -14,6 +14,11 @@ import io.github.wulkanowy.data.db.dao.entities.Account;
import io.github.wulkanowy.data.db.dao.entities.DaoSession; import io.github.wulkanowy.data.db.dao.entities.DaoSession;
import io.github.wulkanowy.data.db.dao.entities.Diary; import io.github.wulkanowy.data.db.dao.entities.Diary;
import io.github.wulkanowy.data.db.dao.entities.DiaryDao; import io.github.wulkanowy.data.db.dao.entities.DiaryDao;
import io.github.wulkanowy.data.db.dao.entities.Semester;
import io.github.wulkanowy.data.db.dao.entities.Student;
import io.github.wulkanowy.data.db.dao.entities.StudentDao;
import io.github.wulkanowy.data.db.dao.entities.Symbol;
import io.github.wulkanowy.data.db.dao.entities.SymbolDao;
import io.github.wulkanowy.data.db.shared.SharedPrefContract; import io.github.wulkanowy.data.db.shared.SharedPrefContract;
import io.github.wulkanowy.di.annotations.ApplicationContext; import io.github.wulkanowy.di.annotations.ApplicationContext;
import io.github.wulkanowy.utils.DataObjectConverter; import io.github.wulkanowy.utils.DataObjectConverter;
@ -45,25 +50,73 @@ public class AccountSync implements AccountSyncContract {
public void registerUser(String email, String password, String symbol) public void registerUser(String email, String password, String symbol)
throws VulcanException, IOException, CryptoException { throws VulcanException, IOException, CryptoException {
LogUtils.debug("Register new user email=" + email);
vulcan.setCredentials(email, password, symbol, null, null, null); vulcan.setCredentials(email, password, symbol, null, null, null);
daoSession.getDatabase().beginTransaction();
try {
Account account = insertAccount(email, password);
Symbol symbolEntity = insertSymbol(account);
insertStudents(symbolEntity);
insertDiaries(symbolEntity);
insertSemesters();
sharedPref.setCurrentUserId(account.getId());
daoSession.getDatabase().setTransactionSuccessful();
} finally {
daoSession.getDatabase().endTransaction();
}
}
private Account insertAccount(String email, String password) throws CryptoException {
LogUtils.debug("Register account: " + email);
Account account = new Account() Account account = new Account()
.setName(vulcan.getBasicInformation().getPersonalData().getFirstAndLastName())
.setEmail(email) .setEmail(email)
.setPassword(Scrambler.encrypt(email, password, context)) .setPassword(Scrambler.encrypt(email, password, context));
.setSymbol(vulcan.getSymbol())
.setSchoolId(vulcan.getStudentAndParent().getSchoolID())
.setRealId(vulcan.getStudentAndParent().getStudentID());
List<Diary> diaryList = DataObjectConverter.diariesToDiaryEntities(
vulcan.getStudentAndParent().getDiaries());
daoSession.getAccountDao().insert(account); daoSession.getAccountDao().insert(account);
daoSession.getDiaryDao().insertInTx(diaryList); return account;
}
sharedPref.setCurrentUserId(account.getId()); private Symbol insertSymbol(Account account) throws VulcanException, IOException {
LogUtils.debug("Register symbol: " + vulcan.getSymbol());
Symbol symbol = new Symbol()
.setUserId(account.getId())
.setSchoolId(vulcan.getStudentAndParent().getSchoolID())
.setSymbol(vulcan.getSymbol());
daoSession.getSymbolDao().insert(symbol);
return symbol;
}
private void insertStudents(Symbol symbol) throws VulcanException, IOException {
List<Student> studentList = DataObjectConverter.studentsToStudentEntities(
vulcan.getStudentAndParent().getStudents(),
symbol.getId()
);
LogUtils.debug("Register students: " + studentList.size());
daoSession.getStudentDao().insertInTx(studentList);
}
private void insertDiaries(Symbol symbolEntity) throws VulcanException, IOException {
List<Diary> diaryList = DataObjectConverter.diariesToDiaryEntities(
vulcan.getStudentAndParent().getDiaries(),
daoSession.getStudentDao().queryBuilder().where(
StudentDao.Properties.SymbolId.eq(symbolEntity.getId()),
StudentDao.Properties.Current.eq(true)
).unique().getId());
LogUtils.debug("Register diaries: " + diaryList.size());
daoSession.getDiaryDao().insertInTx(diaryList);
}
private void insertSemesters() throws VulcanException, IOException {
List<Semester> semesterList = DataObjectConverter.semestersToSemesterEntities(
vulcan.getStudentAndParent().getSemesters(),
daoSession.getDiaryDao().queryBuilder().where(
DiaryDao.Properties.Current.eq(true)
).unique().getId());
LogUtils.debug("Register semesters: " + semesterList.size());
daoSession.getSemesterDao().insertInTx(semesterList);
} }
@Override @Override
@ -78,14 +131,26 @@ public class AccountSync implements AccountSyncContract {
LogUtils.debug("Initialization current user id=" + userId); LogUtils.debug("Initialization current user id=" + userId);
Account account = daoSession.getAccountDao().load(userId); Account account = daoSession.getAccountDao().load(userId);
String email = account.getEmail();
String pass = Scrambler.decrypt(account.getEmail(), account.getPassword());
vulcan.setCredentials(account.getEmail(), Symbol symbolE = daoSession.getSymbolDao().queryBuilder().where(
Scrambler.decrypt(account.getEmail(), account.getPassword()), SymbolDao.Properties.UserId.eq(account.getId())).unique();
account.getSymbol(), String symbol = symbolE.getSymbol();
account.getSchoolId(), String schoolId = symbolE.getSchoolId();
account.getRealId(),
daoSession.getDiaryDao().queryBuilder() Student studentE = daoSession.getStudentDao().queryBuilder().where(
.where(DiaryDao.Properties.IsCurrent.eq(true)).unique().getValue() StudentDao.Properties.SymbolId.eq(symbolE.getId()),
); StudentDao.Properties.Current.eq(true)
).unique();
String studentId = studentE.getRealId();
Diary diaryE = daoSession.getDiaryDao().queryBuilder().where(
DiaryDao.Properties.StudentId.eq(studentE.getId()),
DiaryDao.Properties.Current.eq(true)
).unique();
String diaryId = diaryE.getValue();
vulcan.setCredentials(email, pass, symbol, schoolId, studentId, diaryId);
} }
} }

View File

@ -18,7 +18,6 @@ import io.github.wulkanowy.data.db.dao.entities.Day;
import io.github.wulkanowy.data.db.dao.entities.DayDao; import io.github.wulkanowy.data.db.dao.entities.DayDao;
import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.data.db.dao.entities.Week;
import io.github.wulkanowy.data.db.dao.entities.WeekDao; import io.github.wulkanowy.data.db.dao.entities.WeekDao;
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
import io.github.wulkanowy.utils.DataObjectConverter; import io.github.wulkanowy.utils.DataObjectConverter;
import io.github.wulkanowy.utils.LogUtils; import io.github.wulkanowy.utils.LogUtils;
import io.github.wulkanowy.utils.TimeUtils; import io.github.wulkanowy.utils.TimeUtils;
@ -28,27 +27,24 @@ public class AttendanceSync implements AttendanceSyncContract {
private final DaoSession daoSession; private final DaoSession daoSession;
private final SharedPrefContract sharedPref;
private final Vulcan vulcan; private final Vulcan vulcan;
private long userId; private long diaryId;
@Inject @Inject
AttendanceSync(DaoSession daoSession, SharedPrefContract sharedPref, Vulcan vulcan) { AttendanceSync(DaoSession daoSession, Vulcan vulcan) {
this.daoSession = daoSession; this.daoSession = daoSession;
this.sharedPref = sharedPref;
this.vulcan = vulcan; this.vulcan = vulcan;
} }
@Override @Override
public void syncAttendance() throws IOException, ParseException, VulcanException { public void syncAttendance(long diaryId) throws IOException, ParseException, VulcanException {
syncAttendance(null); syncAttendance(diaryId, null);
} }
@Override @Override
public void syncAttendance(String date) throws IOException, ParseException, VulcanException { public void syncAttendance(long diaryId, String date) throws IOException, ParseException, VulcanException {
this.userId = sharedPref.getCurrentUserId(); this.diaryId = diaryId;
io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> weekApi = getWeekFromApi(getNormalizedDate(date)); io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> weekApi = getWeekFromApi(getNormalizedDate(date));
Week weekDb = getWeekFromDb(weekApi.getStartDayDate()); Week weekDb = getWeekFromDb(weekApi.getStartDayDate());
@ -72,22 +68,22 @@ public class AttendanceSync implements AttendanceSyncContract {
} }
private Week getWeekFromDb(String date) { private Week getWeekFromDb(String date) {
return daoSession.getWeekDao() return daoSession.getWeekDao().queryBuilder().where(
.queryBuilder() WeekDao.Properties.DiaryId.eq(diaryId),
.where(WeekDao.Properties.UserId.eq(userId), WeekDao.Properties.StartDayDate.eq(date)) WeekDao.Properties.StartDayDate.eq(date)
.unique(); ).unique();
} }
private Long updateWeekInDb(Week dbWeekEntity, io.github.wulkanowy.api.generic.Week fromApi) { private Long updateWeekInDb(Week dbWeekEntity, io.github.wulkanowy.api.generic.Week fromApi) {
if (dbWeekEntity != null) { if (dbWeekEntity != null) {
dbWeekEntity.setIsAttendanceSynced(true); dbWeekEntity.setAttendanceSynced(true);
dbWeekEntity.update(); dbWeekEntity.update();
return dbWeekEntity.getId(); return dbWeekEntity.getId();
} }
Week apiWeekEntity = DataObjectConverter.weekToWeekEntity(fromApi).setUserId(userId); Week apiWeekEntity = DataObjectConverter.weekToWeekEntity(fromApi).setDiaryId(diaryId);
apiWeekEntity.setIsAttendanceSynced(true); apiWeekEntity.setAttendanceSynced(true);
return daoSession.getWeekDao().insert(apiWeekEntity); return daoSession.getWeekDao().insert(apiWeekEntity);
} }
@ -97,7 +93,7 @@ public class AttendanceSync implements AttendanceSyncContract {
for (io.github.wulkanowy.api.generic.Day dayFromApi : dayListFromApi) { for (io.github.wulkanowy.api.generic.Day dayFromApi : dayListFromApi) {
Day dbDayEntity = getDayFromDb(dayFromApi.getDate()); Day dbDayEntity = getDayFromDb(dayFromApi.getDate(), weekId);
Day apiDayEntity = DataObjectConverter.dayToDayEntity(dayFromApi); Day apiDayEntity = DataObjectConverter.dayToDayEntity(dayFromApi);
@ -109,11 +105,12 @@ public class AttendanceSync implements AttendanceSyncContract {
return updatedLessonList; return updatedLessonList;
} }
private Day getDayFromDb(String date) { private Day getDayFromDb(String date, long weekId) {
return daoSession.getDayDao() return daoSession.getDayDao().queryBuilder()
.queryBuilder() .where(
.where(DayDao.Properties.UserId.eq(userId), DayDao.Properties.Date.eq(date)) DayDao.Properties.WeekId.eq(weekId),
.unique(); DayDao.Properties.Date.eq(date)
).unique();
} }
private long updateDay(Day dbDayEntity, Day apiDayEntity, long weekId) { private long updateDay(Day dbDayEntity, Day apiDayEntity, long weekId) {
@ -121,7 +118,6 @@ public class AttendanceSync implements AttendanceSyncContract {
return dbDayEntity.getId(); return dbDayEntity.getId();
} }
apiDayEntity.setUserId(userId);
apiDayEntity.setWeekId(weekId); apiDayEntity.setWeekId(weekId);
return daoSession.getDayDao().insert(apiDayEntity); return daoSession.getDayDao().insert(apiDayEntity);

View File

@ -7,7 +7,7 @@ import io.github.wulkanowy.api.VulcanException;
public interface AttendanceSyncContract { public interface AttendanceSyncContract {
void syncAttendance(String date) throws IOException, ParseException, VulcanException; void syncAttendance(long diaryId, String date) throws IOException, ParseException, VulcanException;
void syncAttendance() throws IOException, ParseException, VulcanException; void syncAttendance(long diaryId) throws IOException, ParseException, VulcanException;
} }

View File

@ -10,11 +10,10 @@ import javax.inject.Singleton;
import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.VulcanException; import io.github.wulkanowy.api.VulcanException;
import io.github.wulkanowy.data.db.dao.entities.Account;
import io.github.wulkanowy.data.db.dao.entities.DaoSession; import io.github.wulkanowy.data.db.dao.entities.DaoSession;
import io.github.wulkanowy.data.db.dao.entities.Grade; import io.github.wulkanowy.data.db.dao.entities.Grade;
import io.github.wulkanowy.data.db.dao.entities.Semester;
import io.github.wulkanowy.data.db.dao.entities.SubjectDao; import io.github.wulkanowy.data.db.dao.entities.SubjectDao;
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
import io.github.wulkanowy.data.sync.SyncContract; import io.github.wulkanowy.data.sync.SyncContract;
import io.github.wulkanowy.utils.DataObjectConverter; import io.github.wulkanowy.utils.DataObjectConverter;
import io.github.wulkanowy.utils.EntitiesCompare; import io.github.wulkanowy.utils.EntitiesCompare;
@ -27,65 +26,59 @@ public class GradeSync implements SyncContract {
private final Vulcan vulcan; private final Vulcan vulcan;
private final SharedPrefContract sharedPref; private long semesterId;
private Long userId;
@Inject @Inject
GradeSync(DaoSession daoSession, SharedPrefContract sharedPref, Vulcan vulcan) { GradeSync(DaoSession daoSession, Vulcan vulcan) {
this.daoSession = daoSession; this.daoSession = daoSession;
this.sharedPref = sharedPref;
this.vulcan = vulcan; this.vulcan = vulcan;
} }
@Override @Override
public void sync() throws IOException, VulcanException, ParseException { public void sync(long semesterId) throws IOException, VulcanException, ParseException {
this.semesterId = semesterId;
userId = sharedPref.getCurrentUserId(); Semester semester = daoSession.getSemesterDao().load(semesterId);
resetSemesterRelations(semester);
Account account = daoSession.getAccountDao().load(userId); List<Grade> lastList = getUpdatedList(getComparedList(semester));
resetAccountRelations(account);
List<Grade> lastList = getUpdatedList(getComparedList(account)); daoSession.getGradeDao().deleteInTx(semester.getGradeList());
daoSession.getGradeDao().deleteInTx(account.getGradeList());
daoSession.getGradeDao().insertInTx(lastList); daoSession.getGradeDao().insertInTx(lastList);
LogUtils.debug("Synchronization grades (amount = " + lastList.size() + ")"); LogUtils.debug("Synchronization grades (amount = " + lastList.size() + ")");
} }
private void resetAccountRelations(Account account) { private void resetSemesterRelations(Semester semester) {
account.resetSubjectList(); semester.resetSubjectList();
account.resetGradeList(); semester.resetGradeList();
} }
private List<Grade> getUpdatedList(List<Grade> comparedList) { private List<Grade> getUpdatedList(List<Grade> comparedList) {
List<Grade> updatedList = new ArrayList<>(); List<Grade> updatedList = new ArrayList<>();
for (Grade grade : comparedList) { for (Grade grade : comparedList) {
grade.setUserId(userId); grade.setSemesterId(semesterId);
grade.setSubjectId(getSubjectId(grade.getSubject())); grade.setSubjectId(getSubjectId(grade.getSubject()));
updatedList.add(grade); updatedList.add(grade);
} }
return updatedList; return updatedList;
} }
private List<Grade> getComparedList(Account account) throws IOException, VulcanException, private List<Grade> getComparedList(Semester semester) throws IOException, VulcanException, ParseException {
ParseException { List<Grade> gradesFromNet = DataObjectConverter.gradesToGradeEntities(
List<Grade> gradesFromNet = DataObjectConverter vulcan.getGradesList().getAll(semester.getValue()), semesterId);
.gradesToGradeEntities(vulcan.getGradesList().getAll());
List<Grade> gradesFromDb = account.getGradeList(); List<Grade> gradesFromDb = semester.getGradeList();
return EntitiesCompare.compareGradeList(gradesFromNet, gradesFromDb); return EntitiesCompare.compareGradeList(gradesFromNet, gradesFromDb);
} }
private Long getSubjectId(String subjectName) { private Long getSubjectId(String subjectName) {
return daoSession.getSubjectDao().queryBuilder() return daoSession.getSubjectDao().queryBuilder().where(
.where(SubjectDao.Properties.Name.eq(subjectName), SubjectDao.Properties.Name.eq(subjectName),
SubjectDao.Properties.UserId.eq(userId)) SubjectDao.Properties.SemesterId.eq(semesterId)
.build() ).build().uniqueOrThrow().getId();
.uniqueOrThrow()
.getId();
} }
} }

View File

@ -1,7 +1,6 @@
package io.github.wulkanowy.data.sync.subjects; package io.github.wulkanowy.data.sync.subjects;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -10,10 +9,9 @@ import javax.inject.Singleton;
import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.VulcanException; import io.github.wulkanowy.api.VulcanException;
import io.github.wulkanowy.data.db.dao.entities.Account;
import io.github.wulkanowy.data.db.dao.entities.DaoSession; import io.github.wulkanowy.data.db.dao.entities.DaoSession;
import io.github.wulkanowy.data.db.dao.entities.Semester;
import io.github.wulkanowy.data.db.dao.entities.Subject; import io.github.wulkanowy.data.db.dao.entities.Subject;
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
import io.github.wulkanowy.data.sync.SyncContract; import io.github.wulkanowy.data.sync.SyncContract;
import io.github.wulkanowy.utils.DataObjectConverter; import io.github.wulkanowy.utils.DataObjectConverter;
import io.github.wulkanowy.utils.LogUtils; import io.github.wulkanowy.utils.LogUtils;
@ -25,21 +23,17 @@ public class SubjectSync implements SyncContract {
private final Vulcan vulcan; private final Vulcan vulcan;
private final SharedPrefContract sharedPref; private long semesterId;
private Long userId;
@Inject @Inject
SubjectSync(DaoSession daoSession, SharedPrefContract sharedPref, Vulcan vulcan) { SubjectSync(DaoSession daoSession, Vulcan vulcan) {
this.daoSession = daoSession; this.daoSession = daoSession;
this.sharedPref = sharedPref;
this.vulcan = vulcan; this.vulcan = vulcan;
} }
@Override @Override
public void sync() throws VulcanException, IOException, ParseException { public void sync(long semesterId) throws VulcanException, IOException {
this.semesterId = semesterId;
userId = sharedPref.getCurrentUserId();
List<Subject> lastList = getUpdatedList(getSubjectsFromNet()); List<Subject> lastList = getUpdatedList(getSubjectsFromNet());
@ -50,20 +44,21 @@ public class SubjectSync implements SyncContract {
} }
private List<Subject> getSubjectsFromNet() throws VulcanException, IOException { private List<Subject> getSubjectsFromNet() throws VulcanException, IOException {
return DataObjectConverter.subjectsToSubjectEntities(vulcan.getSubjectsList().getAll()); return DataObjectConverter.subjectsToSubjectEntities(
vulcan.getSubjectsList().getAll(String.valueOf(semesterId)), semesterId);
} }
private List<Subject> getSubjectsFromDb() { private List<Subject> getSubjectsFromDb() {
Account account = daoSession.getAccountDao().load(userId); Semester semester = daoSession.getSemesterDao().load(semesterId);
account.resetSubjectList(); semester.resetSubjectList();
return account.getSubjectList(); return semester.getSubjectList();
} }
private List<Subject> getUpdatedList(List<Subject> subjectsFromNet) { private List<Subject> getUpdatedList(List<Subject> subjectsFromNet) {
List<Subject> updatedList = new ArrayList<>(); List<Subject> updatedList = new ArrayList<>();
for (Subject subject : subjectsFromNet) { for (Subject subject : subjectsFromNet) {
subject.setUserId(userId); subject.setSemesterId(semesterId);
updatedList.add(subject); updatedList.add(subject);
} }
return updatedList; return updatedList;

View File

@ -18,7 +18,6 @@ import io.github.wulkanowy.data.db.dao.entities.TimetableLesson;
import io.github.wulkanowy.data.db.dao.entities.TimetableLessonDao; import io.github.wulkanowy.data.db.dao.entities.TimetableLessonDao;
import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.data.db.dao.entities.Week;
import io.github.wulkanowy.data.db.dao.entities.WeekDao; import io.github.wulkanowy.data.db.dao.entities.WeekDao;
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
import io.github.wulkanowy.utils.DataObjectConverter; import io.github.wulkanowy.utils.DataObjectConverter;
import io.github.wulkanowy.utils.LogUtils; import io.github.wulkanowy.utils.LogUtils;
import io.github.wulkanowy.utils.TimeUtils; import io.github.wulkanowy.utils.TimeUtils;
@ -28,27 +27,24 @@ public class TimetableSync implements TimetableSyncContract {
private final DaoSession daoSession; private final DaoSession daoSession;
private final SharedPrefContract sharedPref;
private final Vulcan vulcan; private final Vulcan vulcan;
private long userId; private long diaryId;
@Inject @Inject
TimetableSync(DaoSession daoSession, SharedPrefContract sharedPref, Vulcan vulcan) { TimetableSync(DaoSession daoSession, Vulcan vulcan) {
this.daoSession = daoSession; this.daoSession = daoSession;
this.sharedPref = sharedPref;
this.vulcan = vulcan; this.vulcan = vulcan;
} }
@Override @Override
public void syncTimetable() throws IOException, ParseException, VulcanException { public void syncTimetable(long diaryId) throws IOException, ParseException, VulcanException {
syncTimetable(null); syncTimetable(diaryId, null);
} }
@Override @Override
public void syncTimetable(String date) throws IOException, ParseException, VulcanException { public void syncTimetable(long diaryId, String date) throws IOException, ParseException, VulcanException {
this.userId = sharedPref.getCurrentUserId(); this.diaryId = diaryId;
io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> weekApi = getWeekFromApi(getNormalizedDate(date)); io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> weekApi = getWeekFromApi(getNormalizedDate(date));
Week weekDb = getWeekFromDb(weekApi.getStartDayDate()); Week weekDb = getWeekFromDb(weekApi.getStartDayDate());
@ -67,27 +63,27 @@ public class TimetableSync implements TimetableSyncContract {
} }
private io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> getWeekFromApi(String date) private io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> getWeekFromApi(String date)
throws IOException, VulcanException, ParseException { throws IOException, ParseException, VulcanException {
return vulcan.getTimetable().getWeekTable(date); return vulcan.getTimetable().getWeekTable(date);
} }
private Week getWeekFromDb(String date) { private Week getWeekFromDb(String date) {
return daoSession.getWeekDao() return daoSession.getWeekDao().queryBuilder().where(
.queryBuilder() WeekDao.Properties.DiaryId.eq(diaryId),
.where(WeekDao.Properties.UserId.eq(userId), WeekDao.Properties.StartDayDate.eq(date)) WeekDao.Properties.StartDayDate.eq(date)
.unique(); ).unique();
} }
private Long updateWeekInDb(Week dbEntity, io.github.wulkanowy.api.generic.Week fromApi) { private Long updateWeekInDb(Week dbEntity, io.github.wulkanowy.api.generic.Week fromApi) {
if (dbEntity != null) { if (dbEntity != null) {
dbEntity.setIsTimetableSynced(true); dbEntity.setTimetableSynced(true);
dbEntity.update(); dbEntity.update();
return dbEntity.getId(); return dbEntity.getId();
} }
Week apiEntity = DataObjectConverter.weekToWeekEntity(fromApi).setUserId(userId); Week apiEntity = DataObjectConverter.weekToWeekEntity(fromApi).setDiaryId(diaryId);
apiEntity.setIsTimetableSynced(true); apiEntity.setTimetableSynced(true);
return daoSession.getWeekDao().insert(apiEntity); return daoSession.getWeekDao().insert(apiEntity);
} }
@ -97,7 +93,7 @@ public class TimetableSync implements TimetableSyncContract {
for (io.github.wulkanowy.api.generic.Day dayFromApi : dayListFromApi) { for (io.github.wulkanowy.api.generic.Day dayFromApi : dayListFromApi) {
Day dbDayEntity = getDayFromDb(dayFromApi.getDate()); Day dbDayEntity = getDayFromDb(dayFromApi.getDate(), weekId);
Day apiDayEntity = DataObjectConverter.dayToDayEntity(dayFromApi); Day apiDayEntity = DataObjectConverter.dayToDayEntity(dayFromApi);
@ -109,15 +105,14 @@ public class TimetableSync implements TimetableSyncContract {
return updatedLessonList; return updatedLessonList;
} }
private Day getDayFromDb(String date) { private Day getDayFromDb(String date, long weekId) {
return daoSession.getDayDao() return daoSession.getDayDao().queryBuilder().where(
.queryBuilder() DayDao.Properties.WeekId.eq(weekId),
.where(DayDao.Properties.UserId.eq(userId), DayDao.Properties.Date.eq(date)) DayDao.Properties.Date.eq(date)
.unique(); ).unique();
} }
private long updateDay(Day dayFromDb, Day apiDayEntity, long weekId) { private long updateDay(Day dayFromDb, Day apiDayEntity, long weekId) {
apiDayEntity.setUserId(userId);
apiDayEntity.setWeekId(weekId); apiDayEntity.setWeekId(weekId);
if (null != dayFromDb) { if (null != dayFromDb) {

View File

@ -7,7 +7,7 @@ import io.github.wulkanowy.api.VulcanException;
public interface TimetableSyncContract { public interface TimetableSyncContract {
void syncTimetable(String date) throws VulcanException, IOException, ParseException; void syncTimetable(long diaryId, String date) throws VulcanException, IOException, ParseException;
void syncTimetable() throws VulcanException, IOException, ParseException; void syncTimetable(long diaryId) throws VulcanException, IOException, ParseException;
} }

View File

@ -77,7 +77,7 @@ public class AttendanceDialogFragment extends DialogFragment {
description.setText(lesson.getDescription()); description.setText(lesson.getDescription());
if (lesson.getIsAbsenceUnexcused()) { if (lesson.getAbsenceUnexcused()) {
description.setTextColor(getResources().getColor(R.color.colorPrimaryDark)); description.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
} }

View File

@ -141,7 +141,7 @@ public class AttendanceHeaderItem
private int countNotPresentHours(List<AttendanceSubItem> subItems) { private int countNotPresentHours(List<AttendanceSubItem> subItems) {
int i = 0; int i = 0;
for (AttendanceSubItem subItem : subItems) { for (AttendanceSubItem subItem : subItems) {
if (subItem.getLesson().getIsAbsenceUnexcused()) { if (subItem.getLesson().getAbsenceUnexcused()) {
i++; i++;
} }
} }
@ -150,8 +150,8 @@ public class AttendanceHeaderItem
private boolean isSubItemsHasChanges(List<AttendanceSubItem> subItems) { private boolean isSubItemsHasChanges(List<AttendanceSubItem> subItems) {
for (AttendanceSubItem subItem : subItems) { for (AttendanceSubItem subItem : subItems) {
if (subItem.getLesson().getIsAbsenceUnexcused() || subItem.getLesson() if (subItem.getLesson().getAbsenceUnexcused() || subItem.getLesson()
.getIsUnexcusedLateness()) { .getUnexcusedLateness()) {
return true; return true;
} }
} }

View File

@ -102,7 +102,7 @@ class AttendanceSubItem
lessonName.setText(lesson.getSubject()); lessonName.setText(lesson.getSubject());
lessonNumber.setText((String.valueOf(lesson.getNumber()))); lessonNumber.setText((String.valueOf(lesson.getNumber())));
lessonDescription.setText(lesson.getDescription()); lessonDescription.setText(lesson.getDescription());
alert.setVisibility(lesson.getIsAbsenceUnexcused() || lesson.getIsUnexcusedLateness() alert.setVisibility(lesson.getAbsenceUnexcused() || lesson.getUnexcusedLateness()
? View.VISIBLE : View.INVISIBLE); ? View.VISIBLE : View.INVISIBLE);
} }

View File

@ -94,7 +94,7 @@ public class AttendanceTabPresenter extends BasePresenter<AttendanceTabContract.
public void onDoInBackgroundLoading() throws Exception { public void onDoInBackgroundLoading() throws Exception {
Week week = getRepository().getWeek(date); Week week = getRepository().getWeek(date);
if (week == null || !week.getIsAttendanceSynced()) { if (week == null || !week.getAttendanceSynced()) {
syncData(); syncData();
week = getRepository().getWeek(date); week = getRepository().getWeek(date);
} }

View File

@ -103,8 +103,8 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
} }
@Override @Override
public void onDoInBackgroundLoading() throws Exception { public void onDoInBackgroundLoading() {
List<Subject> subjectList = getRepository().getCurrentUser().getSubjectList(); List<Subject> subjectList = getRepository().getSubjectList();
headerItems = new ArrayList<>(); headerItems = new ArrayList<>();

View File

@ -91,8 +91,8 @@ public class TimetableDialogFragment extends DialogFragment {
teacherLabel.setVisibility(View.GONE); teacherLabel.setVisibility(View.GONE);
} }
if (!lesson.getGroupName().isEmpty()) { if (!lesson.getGroup().isEmpty()) {
group.setText(lesson.getGroupName()); group.setText(lesson.getGroup());
} else { } else {
group.setVisibility(View.GONE); group.setVisibility(View.GONE);
groupLabel.setVisibility(View.GONE); groupLabel.setVisibility(View.GONE);

View File

@ -105,9 +105,9 @@ public class TimetableHeaderItem
dayName.setText(StringUtils.capitalize(item.getDayName())); dayName.setText(StringUtils.capitalize(item.getDayName()));
date.setText(item.getDate()); date.setText(item.getDate());
alert.setVisibility(isSubItemNewMovedInOrChanged(subItems) ? View.VISIBLE : View.INVISIBLE); alert.setVisibility(isSubItemNewMovedInOrChanged(subItems) ? View.VISIBLE : View.INVISIBLE);
freeName.setVisibility(item.getIsFreeDay() ? View.VISIBLE : View.INVISIBLE); freeName.setVisibility(item.getFreeDay() ? View.VISIBLE : View.INVISIBLE);
freeName.setText(item.getFreeDayName()); freeName.setText(item.getFreeDayName());
setInactiveHeader(item.getIsFreeDay()); setInactiveHeader(item.getFreeDay());
} }
private void setInactiveHeader(boolean inactive) { private void setInactiveHeader(boolean inactive) {
@ -134,8 +134,8 @@ public class TimetableHeaderItem
boolean isAlertActive = false; boolean isAlertActive = false;
for (TimetableSubItem subItem : subItems) { for (TimetableSubItem subItem : subItems) {
if (subItem.getLesson().getIsMovedOrCanceled() || if (subItem.getLesson().getMovedOrCanceled() ||
subItem.getLesson().getIsNewMovedInOrChanged()) { subItem.getLesson().getNewMovedInOrChanged()) {
isAlertActive = true; isAlertActive = true;
} }
} }

View File

@ -108,9 +108,9 @@ public class TimetableSubItem
lessonTime.setText(getLessonTimeString()); lessonTime.setText(getLessonTimeString());
numberOfLesson.setText(lesson.getNumber()); numberOfLesson.setText(lesson.getNumber());
room.setText(getRoomString()); room.setText(getRoomString());
alert.setVisibility(lesson.getIsMovedOrCanceled() || lesson.getIsNewMovedInOrChanged() alert.setVisibility(lesson.getMovedOrCanceled() || lesson.getNewMovedInOrChanged()
? View.VISIBLE : View.INVISIBLE); ? View.VISIBLE : View.INVISIBLE);
lessonName.setPaintFlags(lesson.getIsMovedOrCanceled() ? lessonName.getPaintFlags() lessonName.setPaintFlags(lesson.getMovedOrCanceled() ? lessonName.getPaintFlags()
| Paint.STRIKE_THRU_TEXT_FLAG : | Paint.STRIKE_THRU_TEXT_FLAG :
lessonName.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); lessonName.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
room.setText(getRoomString()); room.setText(getRoomString());

View File

@ -97,7 +97,7 @@ public class TimetableTabPresenter extends BasePresenter<TimetableTabContract.Vi
public void onDoInBackgroundLoading() throws Exception { public void onDoInBackgroundLoading() throws Exception {
Week week = getRepository().getWeek(date); Week week = getRepository().getWeek(date);
if (week == null || !week.getIsTimetableSynced()) { if (week == null || !week.getTimetableSynced()) {
syncData(); syncData();
week = getRepository().getWeek(date); week = getRepository().getWeek(date);
} }
@ -113,7 +113,7 @@ public class TimetableTabPresenter extends BasePresenter<TimetableTabContract.Vi
TimetableHeaderItem headerItem = new TimetableHeaderItem(day); TimetableHeaderItem headerItem = new TimetableHeaderItem(day);
if (isFreeWeek) { if (isFreeWeek) {
isFreeWeek = day.getIsFreeDay(); isFreeWeek = day.getFreeDay();
} }
List<TimetableLesson> lessonList = day.getTimetableLessons(); List<TimetableLesson> lessonList = day.getTimetableLessons();

View File

@ -8,6 +8,8 @@ import io.github.wulkanowy.data.db.dao.entities.AttendanceLesson;
import io.github.wulkanowy.data.db.dao.entities.Day; import io.github.wulkanowy.data.db.dao.entities.Day;
import io.github.wulkanowy.data.db.dao.entities.Diary; import io.github.wulkanowy.data.db.dao.entities.Diary;
import io.github.wulkanowy.data.db.dao.entities.Grade; import io.github.wulkanowy.data.db.dao.entities.Grade;
import io.github.wulkanowy.data.db.dao.entities.Semester;
import io.github.wulkanowy.data.db.dao.entities.Student;
import io.github.wulkanowy.data.db.dao.entities.Subject; import io.github.wulkanowy.data.db.dao.entities.Subject;
import io.github.wulkanowy.data.db.dao.entities.TimetableLesson; import io.github.wulkanowy.data.db.dao.entities.TimetableLesson;
import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.data.db.dao.entities.Week;
@ -18,26 +20,56 @@ public final class DataObjectConverter {
throw new IllegalStateException("Utility class"); throw new IllegalStateException("Utility class");
} }
public static List<Diary> diariesToDiaryEntities(List<io.github.wulkanowy.api.Diary> diaryList) { public static List<Student> studentsToStudentEntities(List<io.github.wulkanowy.api.Student> students, Long symbolId) {
List<Student> studentList = new ArrayList<>();
for (io.github.wulkanowy.api.Student student : students) {
studentList.add(new Student()
.setName(student.getName())
.setCurrent(student.isCurrent())
.setRealId(student.getId())
.setSymbolId(symbolId)
);
}
return studentList;
}
public static List<Diary> diariesToDiaryEntities(List<io.github.wulkanowy.api.Diary> diaryList, Long studentId) {
List<Diary> diaryEntityList = new ArrayList<>(); List<Diary> diaryEntityList = new ArrayList<>();
for (io.github.wulkanowy.api.Diary diary : diaryList) { for (io.github.wulkanowy.api.Diary diary : diaryList) {
Diary diaryEntity = new Diary() diaryEntityList.add(new Diary()
.setStudentId(studentId)
.setValue(diary.getId()) .setValue(diary.getId())
.setName(diary.getName()) .setName(diary.getName())
.setStudentId(diary.getStudentId()) .setCurrent(diary.isCurrent()));
.setIsCurrent(diary.isCurrent());
diaryEntityList.add(diaryEntity);
} }
return diaryEntityList; return diaryEntityList;
} }
public static List<Subject> subjectsToSubjectEntities(List<io.github.wulkanowy.api.grades.Subject> subjectList) { public static List<Semester> semestersToSemesterEntities(List<io.github.wulkanowy.api.Semester> semesters, long diaryId) {
List<Semester> semesterList = new ArrayList<>();
for (io.github.wulkanowy.api.Semester semester : semesters) {
semesterList.add(new Semester()
.setDiaryId(diaryId)
.setName(semester.getName())
.setCurrent(semester.isCurrent())
.setValue(semester.getId())
);
}
return semesterList;
}
public static List<Subject> subjectsToSubjectEntities(List<io.github.wulkanowy.api.grades.Subject> subjectList, long semesterId) {
List<Subject> subjectEntityList = new ArrayList<>(); List<Subject> subjectEntityList = new ArrayList<>();
for (io.github.wulkanowy.api.grades.Subject subject : subjectList) { for (io.github.wulkanowy.api.grades.Subject subject : subjectList) {
Subject subjectEntity = new Subject() Subject subjectEntity = new Subject()
.setSemesterId(semesterId)
.setName(subject.getName()) .setName(subject.getName())
.setPredictedRating(subject.getPredictedRating()) .setPredictedRating(subject.getPredictedRating())
.setFinalRating(subject.getFinalRating()); .setFinalRating(subject.getFinalRating());
@ -47,11 +79,11 @@ public final class DataObjectConverter {
return subjectEntityList; return subjectEntityList;
} }
public static List<Grade> gradesToGradeEntities(List<io.github.wulkanowy.api.grades.Grade> gradeList) { public static List<Grade> gradesToGradeEntities(List<io.github.wulkanowy.api.grades.Grade> gradeList, long semesterId) {
List<Grade> gradeEntityList = new ArrayList<>(); List<Grade> gradeEntityList = new ArrayList<>();
for (io.github.wulkanowy.api.grades.Grade grade : gradeList) { for (io.github.wulkanowy.api.grades.Grade grade : gradeList) {
Grade gradeEntity = new Grade() gradeEntityList.add(new Grade()
.setSubject(grade.getSubject()) .setSubject(grade.getSubject())
.setValue(grade.getValue()) .setValue(grade.getValue())
.setColor(grade.getColor()) .setColor(grade.getColor())
@ -60,10 +92,9 @@ public final class DataObjectConverter {
.setWeight(grade.getWeight()) .setWeight(grade.getWeight())
.setDate(grade.getDate()) .setDate(grade.getDate())
.setTeacher(grade.getTeacher()) .setTeacher(grade.getTeacher())
.setSemester(grade.getSemester()); .setSemesterId(semesterId));
gradeEntityList.add(gradeEntity);
} }
return gradeEntityList; return gradeEntityList;
} }
@ -75,11 +106,10 @@ public final class DataObjectConverter {
return new Day() return new Day()
.setDate(day.getDate()) .setDate(day.getDate())
.setDayName(day.getDayName()) .setDayName(day.getDayName())
.setIsFreeDay(day.isFreeDay()) .setFreeDay(day.isFreeDay())
.setFreeDayName(day.getFreeDayName()); .setFreeDayName(day.getFreeDayName());
} }
public static List<Day> daysToDaysEntities(List<io.github.wulkanowy.api.generic.Day> dayList) { public static List<Day> daysToDaysEntities(List<io.github.wulkanowy.api.generic.Day> dayList) {
List<Day> dayEntityList = new ArrayList<>(); List<Day> dayEntityList = new ArrayList<>();
@ -89,14 +119,24 @@ public final class DataObjectConverter {
return dayEntityList; return dayEntityList;
} }
public static TimetableLesson lessonToTimetableLessonEntity(io.github.wulkanowy.api.generic.Lesson lesson) { public static List<TimetableLesson> lessonsToTimetableLessonsEntities(List<io.github.wulkanowy.api.generic.Lesson> lessonList) {
List<TimetableLesson> lessonEntityList = new ArrayList<>();
for (io.github.wulkanowy.api.generic.Lesson lesson : lessonList) {
lessonEntityList.add(lessonToTimetableLessonEntity(lesson));
}
return lessonEntityList;
}
private static TimetableLesson lessonToTimetableLessonEntity(io.github.wulkanowy.api.generic.Lesson lesson) {
return new TimetableLesson() return new TimetableLesson()
.setNumber(lesson.getNumber()) .setNumber(lesson.getNumber())
.setSubject(lesson.getSubject()) .setSubject(lesson.getSubject())
.setTeacher(lesson.getTeacher()) .setTeacher(lesson.getTeacher())
.setRoom(lesson.getRoom()) .setRoom(lesson.getRoom())
.setDescription(lesson.getDescription()) .setDescription(lesson.getDescription())
.setGroupName(lesson.getGroupName()) .setGroup(lesson.getGroupName())
.setStartTime(lesson.getStartTime()) .setStartTime(lesson.getStartTime())
.setEndTime(lesson.getEndTime()) .setEndTime(lesson.getEndTime())
.setDate(lesson.getDate()) .setDate(lesson.getDate())
@ -108,35 +148,27 @@ public final class DataObjectConverter {
.setNewMovedInOrChanged(lesson.isNewMovedInOrChanged()); .setNewMovedInOrChanged(lesson.isNewMovedInOrChanged());
} }
public static AttendanceLesson lessonToAttendanceLessonEntity(io.github.wulkanowy.api.generic.Lesson lesson) {
return new AttendanceLesson()
.setNumber(Integer.valueOf(lesson.getNumber()))
.setSubject(lesson.getSubject())
.setDate(lesson.getDate())
.setIsPresence(lesson.isPresence())
.setIsAbsenceUnexcused(lesson.isAbsenceUnexcused())
.setIsAbsenceExcused(lesson.isAbsenceExcused())
.setIsUnexcusedLateness(lesson.isUnexcusedLateness())
.setIsAbsenceForSchoolReasons(lesson.isAbsenceForSchoolReasons())
.setIsExcusedLateness(lesson.isExcusedLateness())
.setIsExemption(lesson.isExemption());
}
public static List<TimetableLesson> lessonsToTimetableLessonsEntities(List<io.github.wulkanowy.api.generic.Lesson> lessonList) {
List<TimetableLesson> lessonEntityList = new ArrayList<>();
for (io.github.wulkanowy.api.generic.Lesson lesson : lessonList) {
lessonEntityList.add(lessonToTimetableLessonEntity(lesson));
}
return lessonEntityList;
}
public static List<AttendanceLesson> lessonsToAttendanceLessonsEntities(List<io.github.wulkanowy.api.generic.Lesson> lessonList) { public static List<AttendanceLesson> lessonsToAttendanceLessonsEntities(List<io.github.wulkanowy.api.generic.Lesson> lessonList) {
List<AttendanceLesson> lessonEntityList = new ArrayList<>(); List<AttendanceLesson> lessonEntityList = new ArrayList<>();
for (io.github.wulkanowy.api.generic.Lesson lesson : lessonList) { for (io.github.wulkanowy.api.generic.Lesson lesson : lessonList) {
lessonEntityList.add(lessonToAttendanceLessonEntity(lesson)); lessonEntityList.add(lessonToAttendanceLessonEntity(lesson));
} }
return lessonEntityList; return lessonEntityList;
} }
private static AttendanceLesson lessonToAttendanceLessonEntity(io.github.wulkanowy.api.generic.Lesson lesson) {
return new AttendanceLesson()
.setNumber(Integer.valueOf(lesson.getNumber()))
.setSubject(lesson.getSubject())
.setDate(lesson.getDate())
.setPresence(lesson.isPresence())
.setAbsenceUnexcused(lesson.isAbsenceUnexcused())
.setAbsenceExcused(lesson.isAbsenceExcused())
.setUnexcusedLateness(lesson.isUnexcusedLateness())
.setAbsenceForSchoolReasons(lesson.isAbsenceForSchoolReasons())
.setExcusedLateness(lesson.isExcusedLateness())
.setExemption(lesson.isExemption());
}
} }

View File

@ -19,7 +19,7 @@ public class DataObjectConverterTest {
List<Subject> subjectList = new ArrayList<>(); List<Subject> subjectList = new ArrayList<>();
subjectList.add(new Subject().setName("Matematyka")); subjectList.add(new Subject().setName("Matematyka"));
List<io.github.wulkanowy.data.db.dao.entities.Subject> subjectEntitiesList = List<io.github.wulkanowy.data.db.dao.entities.Subject> subjectEntitiesList =
DataObjectConverter.subjectsToSubjectEntities(subjectList); DataObjectConverter.subjectsToSubjectEntities(subjectList, 1L);
Assert.assertEquals("Matematyka", subjectEntitiesList.get(0).getName()); Assert.assertEquals("Matematyka", subjectEntitiesList.get(0).getName());
} }
@ -27,7 +27,7 @@ public class DataObjectConverterTest {
@Test @Test
public void subjectConversionEmptyTest() { public void subjectConversionEmptyTest() {
Assert.assertEquals(new ArrayList<>(), Assert.assertEquals(new ArrayList<>(),
DataObjectConverter.subjectsToSubjectEntities(new ArrayList<Subject>())); DataObjectConverter.subjectsToSubjectEntities(new ArrayList<Subject>(), 1L));
} }
@Test @Test
@ -35,7 +35,7 @@ public class DataObjectConverterTest {
List<Grade> gradeList = new ArrayList<>(); List<Grade> gradeList = new ArrayList<>();
gradeList.add(new Grade().setDescription("Lorem ipsum")); gradeList.add(new Grade().setDescription("Lorem ipsum"));
List<io.github.wulkanowy.data.db.dao.entities.Grade> gradeEntitiesList = List<io.github.wulkanowy.data.db.dao.entities.Grade> gradeEntitiesList =
DataObjectConverter.gradesToGradeEntities(gradeList); DataObjectConverter.gradesToGradeEntities(gradeList, 1L);
Assert.assertEquals("Lorem ipsum", gradeEntitiesList.get(0).getDescription()); Assert.assertEquals("Lorem ipsum", gradeEntitiesList.get(0).getDescription());
} }
@ -43,7 +43,7 @@ public class DataObjectConverterTest {
@Test @Test
public void gradeConversionEmptyTest() { public void gradeConversionEmptyTest() {
Assert.assertEquals(new ArrayList<>(), Assert.assertEquals(new ArrayList<>(),
DataObjectConverter.gradesToGradeEntities(new ArrayList<Grade>())); DataObjectConverter.gradesToGradeEntities(new ArrayList<Grade>(), 1L));
} }
@Test @Test

View File

@ -30,8 +30,7 @@ public class EntitiesCompareTest {
.setDescription("Lorem ipsum") .setDescription("Lorem ipsum")
.setWeight("10") .setWeight("10")
.setDate("01.01.2017") .setDate("01.01.2017")
.setTeacher("Andrzej") .setTeacher("Andrzej");
.setSemester("777");
grade2 = new Grade() grade2 = new Grade()
.setSubject("Religia") .setSubject("Religia")
@ -41,8 +40,7 @@ public class EntitiesCompareTest {
.setDescription("Wolna wola") .setDescription("Wolna wola")
.setWeight("10") .setWeight("10")
.setDate("01.01.2017") .setDate("01.01.2017")
.setTeacher("Andrzej") .setTeacher("Andrzej");
.setSemester("777");
} }
@Test @Test