mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 17:32:45 +01:00
Refactor entites (#86)
This commit is contained in:
parent
6fcf09e2b7
commit
119e38254a
@ -4,8 +4,6 @@ public class Diary implements ParamItem {
|
||||
|
||||
private String id = "";
|
||||
|
||||
private String studentId = "";
|
||||
|
||||
private String name = "";
|
||||
|
||||
private boolean current = false;
|
||||
@ -19,16 +17,6 @@ public class Diary implements ParamItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStudentId() {
|
||||
return studentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Diary setStudentId(String studentId) {
|
||||
this.studentId = studentId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -4,8 +4,6 @@ interface ParamItem {
|
||||
|
||||
ParamItem setId(String id);
|
||||
|
||||
ParamItem setStudentId(String id);
|
||||
|
||||
ParamItem setName(String name);
|
||||
|
||||
ParamItem setCurrent(boolean isCurrent);
|
||||
|
@ -4,8 +4,6 @@ public class Semester implements ParamItem {
|
||||
|
||||
private String id = "";
|
||||
|
||||
private String studentId = "";
|
||||
|
||||
private String name = "";
|
||||
|
||||
private boolean current = false;
|
||||
@ -19,16 +17,6 @@ public class Semester implements ParamItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStudentId() {
|
||||
return studentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Semester setStudentId(String studentId) {
|
||||
this.studentId = studentId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -17,15 +17,6 @@ public class Student implements ParamItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStudentId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Student setStudentId(String studentId) {
|
||||
return setId(studentId);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -140,8 +140,8 @@ public class StudentAndParent implements SnP {
|
||||
|
||||
for (Element e : semesterOptions) {
|
||||
Semester semester = new Semester()
|
||||
.setId(e.text())
|
||||
.setName(e.attr("value"));
|
||||
.setId(e.attr("value"))
|
||||
.setName(e.text());
|
||||
|
||||
if (isCurrent(e)) {
|
||||
semester.setCurrent(true);
|
||||
@ -167,9 +167,6 @@ public class StudentAndParent implements SnP {
|
||||
if (isCurrent(e)) {
|
||||
item.setCurrent(true);
|
||||
}
|
||||
if (item instanceof Diary) {
|
||||
item.setStudentId(getStudentID());
|
||||
}
|
||||
|
||||
list.add((T) item);
|
||||
} catch (Exception ex) {
|
||||
|
@ -18,8 +18,6 @@ public class Grade {
|
||||
|
||||
private String teacher = "";
|
||||
|
||||
private String semester = "";
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
@ -99,14 +97,4 @@ public class Grade {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSemester() {
|
||||
return semester;
|
||||
}
|
||||
|
||||
public Grade setSemester(String semester) {
|
||||
this.semester = semester;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import io.github.wulkanowy.api.Semester;
|
||||
import io.github.wulkanowy.api.SnP;
|
||||
import io.github.wulkanowy.api.VulcanException;
|
||||
|
||||
@ -42,24 +41,18 @@ public class GradesList {
|
||||
Document gradesPage = snp.getSnPPageDocument(getGradesPageUrl() + semester);
|
||||
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) {
|
||||
if ("Brak ocen".equals(row.select("td:nth-child(2)").text())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
grades.add(getGrade(row, semester));
|
||||
grades.add(getGrade(row));
|
||||
}
|
||||
|
||||
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 symbol = descriptions.split(", ")[0];
|
||||
@ -75,8 +68,7 @@ public class GradesList {
|
||||
.setDescription(description)
|
||||
.setWeight(row.select("td:nth-child(4)").text())
|
||||
.setDate(date)
|
||||
.setTeacher(row.select("td:nth-child(6)").text())
|
||||
.setSemester(semester);
|
||||
.setTeacher(row.select("td:nth-child(6)").text());
|
||||
}
|
||||
|
||||
private String getColor(String styleAttr) {
|
||||
|
@ -13,16 +13,21 @@ import io.github.wulkanowy.api.VulcanException;
|
||||
|
||||
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) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
|
||||
|
@ -96,12 +96,12 @@ public class StudentAndParentTest {
|
||||
|
||||
Assert.assertEquals(2, semesters.size());
|
||||
|
||||
Assert.assertEquals("1", semesters.get(0).getId());
|
||||
Assert.assertEquals("1234", semesters.get(0).getName());
|
||||
Assert.assertEquals("1", semesters.get(0).getName());
|
||||
Assert.assertEquals("1234", semesters.get(0).getId());
|
||||
Assert.assertFalse(semesters.get(0).isCurrent());
|
||||
|
||||
Assert.assertEquals("2", semesters.get(1).getId());
|
||||
Assert.assertEquals("1235", semesters.get(1).getName());
|
||||
Assert.assertEquals("2", semesters.get(1).getName());
|
||||
Assert.assertEquals("1235", semesters.get(1).getId());
|
||||
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(2).isCurrent());
|
||||
|
||||
Assert.assertEquals("100", snp.getDiaries().get(0).getStudentId());
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -101,14 +101,4 @@ public class GradesListTest extends StudentAndParentTestCase {
|
||||
Assert.assertEquals("Klaudia Dziedzic", list.get(4).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());
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ android {
|
||||
}
|
||||
|
||||
greendao {
|
||||
schemaVersion 23
|
||||
schemaVersion 24
|
||||
generateTests = true
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,13 @@ public class AttendanceLessonTest extends AbstractDaoTestLongPk<AttendanceLesson
|
||||
protected AttendanceLesson createEntity(Long key) {
|
||||
AttendanceLesson entity = new AttendanceLesson();
|
||||
entity.setId(key);
|
||||
entity.setIsPresence(false);
|
||||
entity.setIsAbsenceUnexcused(false);
|
||||
entity.setIsAbsenceExcused(false);
|
||||
entity.setIsUnexcusedLateness(false);
|
||||
entity.setIsAbsenceForSchoolReasons(false);
|
||||
entity.setIsExcusedLateness(false);
|
||||
entity.setIsExemption(false);
|
||||
entity.setPresence(false);
|
||||
entity.setAbsenceUnexcused(false);
|
||||
entity.setAbsenceExcused(false);
|
||||
entity.setUnexcusedLateness(false);
|
||||
entity.setAbsenceForSchoolReasons(false);
|
||||
entity.setExcusedLateness(false);
|
||||
entity.setExemption(false);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class DayTest extends AbstractDaoTestLongPk<DayDao, Day> {
|
||||
protected Day createEntity(Long key) {
|
||||
Day entity = new Day();
|
||||
entity.setId(key);
|
||||
entity.setIsFreeDay(false);
|
||||
entity.setFreeDay(false);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class DiaryTest extends AbstractDaoTestLongPk<DiaryDao, Diary> {
|
||||
protected Diary createEntity(Long key) {
|
||||
Diary entity = new Diary();
|
||||
entity.setId(key);
|
||||
entity.setIsCurrent(false);
|
||||
entity.setCurrent(false);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -12,12 +12,12 @@ public class TimetableLessonTest extends AbstractDaoTestLongPk<TimetableLessonDa
|
||||
protected TimetableLesson createEntity(Long key) {
|
||||
TimetableLesson entity = new TimetableLesson();
|
||||
entity.setId(key);
|
||||
entity.setIsEmpty(false);
|
||||
entity.setIsDivisionIntoGroups(false);
|
||||
entity.setIsPlanning(false);
|
||||
entity.setIsRealized(false);
|
||||
entity.setIsMovedOrCanceled(false);
|
||||
entity.setIsNewMovedInOrChanged(false);
|
||||
entity.setEmpty(false);
|
||||
entity.setDivisionIntoGroups(false);
|
||||
entity.setPlanning(false);
|
||||
entity.setRealized(false);
|
||||
entity.setMovedOrCanceled(false);
|
||||
entity.setNewMovedInOrChanged(false);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
@ -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.AttendanceLesson;
|
||||
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.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.WeekDao;
|
||||
import io.github.wulkanowy.data.db.resources.ResourcesContract;
|
||||
@ -136,32 +141,32 @@ public class Repository implements RepositoryContract {
|
||||
|
||||
@Override
|
||||
public void syncGrades() throws VulcanException, IOException, ParseException {
|
||||
gradeSync.sync();
|
||||
gradeSync.sync(getCurrentSemesterId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncSubjects() throws VulcanException, IOException, ParseException {
|
||||
subjectSync.sync();
|
||||
subjectSync.sync(getCurrentSemesterId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAttendance() throws ParseException, IOException, VulcanException {
|
||||
attendanceSync.syncAttendance();
|
||||
attendanceSync.syncAttendance(getCurrentDiaryId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAttendance(String date) throws ParseException, IOException, VulcanException {
|
||||
attendanceSync.syncAttendance(date);
|
||||
attendanceSync.syncAttendance(getCurrentDiaryId(), date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncTimetable() throws VulcanException, IOException, ParseException {
|
||||
timetableSync.syncTimetable();
|
||||
timetableSync.syncTimetable(getCurrentDiaryId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncTimetable(String date) throws VulcanException, IOException, ParseException {
|
||||
timetableSync.syncTimetable(date);
|
||||
timetableSync.syncTimetable(getCurrentDiaryId(), date);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -179,16 +184,52 @@ public class Repository implements RepositoryContract {
|
||||
|
||||
@Override
|
||||
public Week getWeek(String date) {
|
||||
return daoSession.getWeekDao().queryBuilder()
|
||||
.where(WeekDao.Properties.StartDayDate.eq(date),
|
||||
WeekDao.Properties.UserId.eq(getCurrentUserId()))
|
||||
.unique();
|
||||
return daoSession.getWeekDao().queryBuilder().where(
|
||||
WeekDao.Properties.StartDayDate.eq(date),
|
||||
WeekDao.Properties.DiaryId.eq(getCurrentDiaryId())
|
||||
).unique();
|
||||
}
|
||||
|
||||
public List<Subject> getSubjectList() {
|
||||
return daoSession.getSemesterDao().load(getCurrentSemesterId()).getSubjectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Grade> getNewGrades() {
|
||||
return daoSession.getGradeDao().queryBuilder()
|
||||
.where(GradeDao.Properties.IsNew.eq(1))
|
||||
.list();
|
||||
return daoSession.getGradeDao().queryBuilder().where(
|
||||
GradeDao.Properties.IsNew.eq(1),
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -9,15 +9,13 @@ import javax.inject.Singleton;
|
||||
import io.github.wulkanowy.api.VulcanException;
|
||||
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.Subject;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Week;
|
||||
import io.github.wulkanowy.data.db.resources.ResourcesContract;
|
||||
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
|
||||
public interface RepositoryContract extends ResourcesContract, AccountSyncContract,
|
||||
AttendanceSyncContract, TimetableSyncContract {
|
||||
public interface RepositoryContract extends ResourcesContract, AccountSyncContract {
|
||||
|
||||
long getCurrentUserId();
|
||||
|
||||
@ -39,11 +37,29 @@ public interface RepositoryContract extends ResourcesContract, AccountSyncContra
|
||||
|
||||
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;
|
||||
|
||||
Account getCurrentUser();
|
||||
|
||||
Week getWeek(String date);
|
||||
|
||||
List<Subject> getSubjectList();
|
||||
|
||||
List<Grade> getNewGrades();
|
||||
|
||||
long getCurrentStudentId();
|
||||
|
||||
long getCurrentSymbolId();
|
||||
|
||||
long getCurrentDiaryId();
|
||||
|
||||
long getCurrentSemesterId();
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import javax.inject.Singleton;
|
||||
import io.github.wulkanowy.api.Vulcan;
|
||||
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.Migration24;
|
||||
import io.github.wulkanowy.data.db.shared.SharedPrefContract;
|
||||
import io.github.wulkanowy.di.annotations.ApplicationContext;
|
||||
import io.github.wulkanowy.di.annotations.DatabaseInfo;
|
||||
@ -39,11 +40,9 @@ public class DbHelper extends DaoMaster.OpenHelper {
|
||||
|
||||
@Override
|
||||
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);
|
||||
Database database = new StandardDatabase(db);
|
||||
recreateDatabase(database);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,17 +58,23 @@ public class DbHelper extends DaoMaster.OpenHelper {
|
||||
LogUtils.info("Migration " + migration.getVersion() + " complete");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DaoMaster.dropAllTables(db, true);
|
||||
sharedPref.setCurrentUserId(0);
|
||||
recreateDatabase(db);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void recreateDatabase(Database db) {
|
||||
sharedPref.setCurrentUserId(0);
|
||||
DaoMaster.dropAllTables(db, true);
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
private List<Migration> getMigrations() {
|
||||
List<Migration> migrations = new ArrayList<>();
|
||||
migrations.add(new Migration23());
|
||||
migrations.add(new Migration24());
|
||||
|
||||
// Sorting just to be safe, in case other people add migrations in the wrong order.
|
||||
Comparator<Migration> migrationComparator = new Comparator<Migration>() {
|
||||
|
@ -4,10 +4,9 @@ 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.Index;
|
||||
import org.greenrobot.greendao.annotation.JoinProperty;
|
||||
import org.greenrobot.greendao.annotation.Property;
|
||||
import org.greenrobot.greendao.annotation.ToMany;
|
||||
import org.greenrobot.greendao.annotation.Unique;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -20,38 +19,15 @@ public class Account {
|
||||
@Id(autoincrement = true)
|
||||
private Long id;
|
||||
|
||||
@Index(unique = true)
|
||||
@Property(nameInDb = "REAL_ID")
|
||||
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")
|
||||
@Unique
|
||||
@Property(nameInDb = "email")
|
||||
private String email;
|
||||
|
||||
@Property(nameInDb = "PASSWORD")
|
||||
@Property(nameInDb = "password")
|
||||
private String password;
|
||||
|
||||
@ToMany(joinProperties = {
|
||||
@JoinProperty(name = "realId", referencedName = "studentId")
|
||||
})
|
||||
private List<Diary> diaryList;
|
||||
|
||||
@ToMany(referencedJoinProperty = "userId")
|
||||
private List<Subject> subjectList;
|
||||
|
||||
@ToMany(referencedJoinProperty = "userId")
|
||||
private List<Grade> gradeList;
|
||||
|
||||
@ToMany(referencedJoinProperty = "userId")
|
||||
private List<Day> dayList;
|
||||
private List<Symbol> symbolList;
|
||||
|
||||
/**
|
||||
* Used to resolve relations
|
||||
@ -65,14 +41,9 @@ public class Account {
|
||||
@Generated(hash = 335469827)
|
||||
private transient AccountDao myDao;
|
||||
|
||||
@Generated(hash = 727721142)
|
||||
public Account(Long id, String realId, String symbol, String schoolId, String name,
|
||||
String email, String password) {
|
||||
@Generated(hash = 1104194311)
|
||||
public Account(Long id, String email, String password) {
|
||||
this.id = id;
|
||||
this.realId = realId;
|
||||
this.symbol = symbol;
|
||||
this.schoolId = schoolId;
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
}
|
||||
@ -82,34 +53,15 @@ public class Account {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Account setId(Long id) {
|
||||
public void setId(Long 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() {
|
||||
return email;
|
||||
return this.email;
|
||||
}
|
||||
|
||||
public Account setEmail(String email) {
|
||||
@ -118,7 +70,7 @@ public class Account {
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public Account setPassword(String password) {
|
||||
@ -126,180 +78,34 @@ public class Account {
|
||||
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).
|
||||
* Changes to to-many relations are not persisted, make changes to the target entity.
|
||||
*/
|
||||
@Generated(hash = 1472214466)
|
||||
public List<Diary> getDiaryList() {
|
||||
if (diaryList == null) {
|
||||
@Generated(hash = 822972496)
|
||||
public List<Symbol> getSymbolList() {
|
||||
if (symbolList == 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._queryAccount_DiaryList(realId);
|
||||
SymbolDao targetDao = daoSession.getSymbolDao();
|
||||
List<Symbol> symbolListNew = targetDao._queryAccount_SymbolList(id);
|
||||
synchronized (this) {
|
||||
if (diaryList == null) {
|
||||
diaryList = diaryListNew;
|
||||
if (symbolList == null) {
|
||||
symbolList = symbolListNew;
|
||||
}
|
||||
}
|
||||
}
|
||||
return diaryList;
|
||||
return symbolList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
@Generated(hash = 1716801695)
|
||||
public synchronized void resetSymbolList() {
|
||||
symbolList = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,38 +20,38 @@ public class AttendanceLesson implements Serializable {
|
||||
@Id(autoincrement = true)
|
||||
private Long id;
|
||||
|
||||
@Property(nameInDb = "DAY_ID")
|
||||
@Property(nameInDb = "day_id")
|
||||
private Long dayId;
|
||||
|
||||
@Property(nameInDb = "DATE")
|
||||
@Property(nameInDb = "date")
|
||||
private String date = "";
|
||||
|
||||
@Property(nameInDb = "NUMBER_OF_LESSON")
|
||||
@Property(nameInDb = "number_of_lesson")
|
||||
private int number = 0;
|
||||
|
||||
@Property(nameInDb = "SUBJECT_NAME")
|
||||
@Property(nameInDb = "subject")
|
||||
private String subject = "";
|
||||
|
||||
@Property(nameInDb = "IS_PRESENCE")
|
||||
private boolean isPresence = false;
|
||||
@Property(nameInDb = "presence")
|
||||
private boolean presence = false;
|
||||
|
||||
@Property(nameInDb = "IS_ABSENCE_UNEXCUSED")
|
||||
private boolean isAbsenceUnexcused = false;
|
||||
@Property(nameInDb = "absence_unexcused")
|
||||
private boolean absenceUnexcused = false;
|
||||
|
||||
@Property(nameInDb = "IS_ABSENCE_EXCUSED")
|
||||
private boolean isAbsenceExcused = false;
|
||||
@Property(nameInDb = "absence_excused")
|
||||
private boolean absenceExcused = false;
|
||||
|
||||
@Property(nameInDb = "IS_UNEXCUSED_LATENESS")
|
||||
private boolean isUnexcusedLateness = false;
|
||||
@Property(nameInDb = "unexcused_lateness")
|
||||
private boolean unexcusedLateness = false;
|
||||
|
||||
@Property(nameInDb = "IS_ABSENCE_FOR_SCHOOL_REASONS")
|
||||
private boolean isAbsenceForSchoolReasons = false;
|
||||
@Property(nameInDb = "absence_for_school_reasons")
|
||||
private boolean absenceForSchoolReasons = false;
|
||||
|
||||
@Property(nameInDb = "IS_EXCUSED_LATENESS")
|
||||
private boolean isExcusedLateness = false;
|
||||
@Property(nameInDb = "excused_lateness")
|
||||
private boolean excusedLateness = false;
|
||||
|
||||
@Property(nameInDb = "IS_EXEMPTION")
|
||||
private boolean isExemption = false;
|
||||
@Property(nameInDb = "exemption")
|
||||
private boolean exemption = false;
|
||||
|
||||
@Transient
|
||||
private String description = "";
|
||||
@ -70,24 +70,24 @@ public class AttendanceLesson implements Serializable {
|
||||
@Generated(hash = 1936953859)
|
||||
private transient AttendanceLessonDao myDao;
|
||||
|
||||
@Generated(hash = 1428129046)
|
||||
@Generated(hash = 1741231228)
|
||||
public AttendanceLesson(Long id, Long dayId, String date, int number,
|
||||
String subject, boolean isPresence, boolean isAbsenceUnexcused,
|
||||
boolean isAbsenceExcused, boolean isUnexcusedLateness,
|
||||
boolean isAbsenceForSchoolReasons, boolean isExcusedLateness,
|
||||
boolean isExemption) {
|
||||
String subject, boolean presence, boolean absenceUnexcused,
|
||||
boolean absenceExcused, boolean unexcusedLateness,
|
||||
boolean absenceForSchoolReasons, boolean excusedLateness,
|
||||
boolean exemption) {
|
||||
this.id = id;
|
||||
this.dayId = dayId;
|
||||
this.date = date;
|
||||
this.number = number;
|
||||
this.subject = subject;
|
||||
this.isPresence = isPresence;
|
||||
this.isAbsenceUnexcused = isAbsenceUnexcused;
|
||||
this.isAbsenceExcused = isAbsenceExcused;
|
||||
this.isUnexcusedLateness = isUnexcusedLateness;
|
||||
this.isAbsenceForSchoolReasons = isAbsenceForSchoolReasons;
|
||||
this.isExcusedLateness = isExcusedLateness;
|
||||
this.isExemption = isExemption;
|
||||
this.presence = presence;
|
||||
this.absenceUnexcused = absenceUnexcused;
|
||||
this.absenceExcused = absenceExcused;
|
||||
this.unexcusedLateness = unexcusedLateness;
|
||||
this.absenceForSchoolReasons = absenceForSchoolReasons;
|
||||
this.excusedLateness = excusedLateness;
|
||||
this.exemption = exemption;
|
||||
}
|
||||
|
||||
@Generated(hash = 921806575)
|
||||
@ -137,66 +137,66 @@ public class AttendanceLesson implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsPresence() {
|
||||
return this.isPresence;
|
||||
public boolean getPresence() {
|
||||
return this.presence;
|
||||
}
|
||||
|
||||
public AttendanceLesson setIsPresence(boolean isPresence) {
|
||||
this.isPresence = isPresence;
|
||||
public AttendanceLesson setPresence(boolean presence) {
|
||||
this.presence = presence;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsAbsenceUnexcused() {
|
||||
return this.isAbsenceUnexcused;
|
||||
public boolean getAbsenceUnexcused() {
|
||||
return this.absenceUnexcused;
|
||||
}
|
||||
|
||||
public AttendanceLesson setIsAbsenceUnexcused(boolean isAbsenceUnexcused) {
|
||||
this.isAbsenceUnexcused = isAbsenceUnexcused;
|
||||
public AttendanceLesson setAbsenceUnexcused(boolean absenceUnexcused) {
|
||||
this.absenceUnexcused = absenceUnexcused;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsAbsenceExcused() {
|
||||
return this.isAbsenceExcused;
|
||||
public boolean getAbsenceExcused() {
|
||||
return this.absenceExcused;
|
||||
}
|
||||
|
||||
public AttendanceLesson setIsAbsenceExcused(boolean isAbsenceExcused) {
|
||||
this.isAbsenceExcused = isAbsenceExcused;
|
||||
public AttendanceLesson setAbsenceExcused(boolean absenceExcused) {
|
||||
this.absenceExcused = absenceExcused;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsUnexcusedLateness() {
|
||||
return this.isUnexcusedLateness;
|
||||
public boolean getUnexcusedLateness() {
|
||||
return this.unexcusedLateness;
|
||||
}
|
||||
|
||||
public AttendanceLesson setIsUnexcusedLateness(boolean isUnexcusedLateness) {
|
||||
this.isUnexcusedLateness = isUnexcusedLateness;
|
||||
public AttendanceLesson setUnexcusedLateness(boolean unexcusedLateness) {
|
||||
this.unexcusedLateness = unexcusedLateness;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsAbsenceForSchoolReasons() {
|
||||
return this.isAbsenceForSchoolReasons;
|
||||
public boolean getAbsenceForSchoolReasons() {
|
||||
return this.absenceForSchoolReasons;
|
||||
}
|
||||
|
||||
public AttendanceLesson setIsAbsenceForSchoolReasons(boolean isAbsenceForSchoolReasons) {
|
||||
this.isAbsenceForSchoolReasons = isAbsenceForSchoolReasons;
|
||||
public AttendanceLesson setAbsenceForSchoolReasons(boolean absenceForSchoolReasons) {
|
||||
this.absenceForSchoolReasons = absenceForSchoolReasons;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsExcusedLateness() {
|
||||
return this.isExcusedLateness;
|
||||
public boolean getExcusedLateness() {
|
||||
return this.excusedLateness;
|
||||
}
|
||||
|
||||
public AttendanceLesson setIsExcusedLateness(boolean isExcusedLateness) {
|
||||
this.isExcusedLateness = isExcusedLateness;
|
||||
public AttendanceLesson setExcusedLateness(boolean excusedLateness) {
|
||||
this.excusedLateness = excusedLateness;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsExemption() {
|
||||
return this.isExemption;
|
||||
public boolean getExemption() {
|
||||
return this.exemption;
|
||||
}
|
||||
|
||||
public AttendanceLesson setIsExemption(boolean isExemption) {
|
||||
this.isExemption = isExemption;
|
||||
public AttendanceLesson setExemption(boolean exemption) {
|
||||
this.exemption = exemption;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import org.greenrobot.greendao.annotation.Entity;
|
||||
import org.greenrobot.greendao.annotation.Generated;
|
||||
import org.greenrobot.greendao.annotation.Id;
|
||||
import org.greenrobot.greendao.annotation.Index;
|
||||
import org.greenrobot.greendao.annotation.OrderBy;
|
||||
import org.greenrobot.greendao.annotation.Property;
|
||||
import org.greenrobot.greendao.annotation.ToMany;
|
||||
|
||||
@ -14,36 +13,32 @@ import java.util.List;
|
||||
@Entity(
|
||||
nameInDb = "Days",
|
||||
active = true,
|
||||
indexes = {@Index(value = "userId,weekId,date", unique = true)}
|
||||
indexes = {@Index(value = "weekId,date", unique = true)}
|
||||
)
|
||||
public class Day {
|
||||
|
||||
@Id(autoincrement = true)
|
||||
private Long id;
|
||||
|
||||
@Property(nameInDb = "USER_ID")
|
||||
private Long userId;
|
||||
|
||||
@Property(nameInDb = "WEEK_ID")
|
||||
@Property(nameInDb = "week_id")
|
||||
private Long weekId;
|
||||
|
||||
@Property(nameInDb = "DATE")
|
||||
@Property(nameInDb = "date")
|
||||
private String date = "";
|
||||
|
||||
@Property(nameInDb = "DAY_NAME")
|
||||
@Property(nameInDb = "day_name")
|
||||
private String dayName = "";
|
||||
|
||||
@Property(nameInDb = "IS_FREE_DAY")
|
||||
private boolean isFreeDay = false;
|
||||
@Property(nameInDb = "free_day")
|
||||
private boolean freeDay = false;
|
||||
|
||||
@Property(nameInDb = "FREE_DAY_NAME")
|
||||
@Property(nameInDb = "free_day_name")
|
||||
private String freeDayName = "";
|
||||
|
||||
@ToMany(referencedJoinProperty = "dayId")
|
||||
private List<TimetableLesson> timetableLessons;
|
||||
|
||||
@ToMany(referencedJoinProperty = "dayId")
|
||||
@OrderBy("number ASC")
|
||||
private List<AttendanceLesson> attendanceLessons;
|
||||
|
||||
/**
|
||||
@ -58,15 +53,14 @@ public class Day {
|
||||
@Generated(hash = 312167767)
|
||||
private transient DayDao myDao;
|
||||
|
||||
@Generated(hash = 723729681)
|
||||
public Day(Long id, Long userId, Long weekId, String date, String dayName,
|
||||
boolean isFreeDay, String freeDayName) {
|
||||
@Generated(hash = 523139020)
|
||||
public Day(Long id, Long weekId, String date, String dayName, boolean freeDay,
|
||||
String freeDayName) {
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
this.weekId = weekId;
|
||||
this.date = date;
|
||||
this.dayName = dayName;
|
||||
this.isFreeDay = isFreeDay;
|
||||
this.freeDay = freeDay;
|
||||
this.freeDayName = freeDayName;
|
||||
}
|
||||
|
||||
@ -82,26 +76,16 @@ public class Day {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public Long getWeekId() {
|
||||
return weekId;
|
||||
return this.weekId;
|
||||
}
|
||||
|
||||
public Day setWeekId(Long weekId) {
|
||||
public void setWeekId(Long weekId) {
|
||||
this.weekId = weekId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Day setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public Day setDate(String date) {
|
||||
@ -110,7 +94,7 @@ public class Day {
|
||||
}
|
||||
|
||||
public String getDayName() {
|
||||
return dayName;
|
||||
return this.dayName;
|
||||
}
|
||||
|
||||
public Day setDayName(String dayName) {
|
||||
@ -118,17 +102,17 @@ public class Day {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsFreeDay() {
|
||||
return this.isFreeDay;
|
||||
public boolean getFreeDay() {
|
||||
return this.freeDay;
|
||||
}
|
||||
|
||||
public Day setIsFreeDay(boolean isFreeDay) {
|
||||
this.isFreeDay = isFreeDay;
|
||||
public Day setFreeDay(boolean freeDay) {
|
||||
this.freeDay = freeDay;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFreeDayName() {
|
||||
return freeDayName;
|
||||
return this.freeDayName;
|
||||
}
|
||||
|
||||
public Day setFreeDayName(String freeDayName) {
|
||||
@ -159,7 +143,9 @@ public class Day {
|
||||
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)
|
||||
public synchronized void resetTimetableLessons() {
|
||||
timetableLessons = null;
|
||||
@ -188,7 +174,9 @@ public class Day {
|
||||
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)
|
||||
public synchronized void resetAttendanceLessons() {
|
||||
attendanceLessons = null;
|
||||
|
@ -5,6 +5,9 @@ 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 = "Diaries",
|
||||
@ -15,17 +18,20 @@ public class Diary {
|
||||
@Id(autoincrement = true)
|
||||
private Long id;
|
||||
|
||||
@Property(nameInDb = "STUDENT_ID")
|
||||
private String studentId;
|
||||
@Property(nameInDb = "student_id")
|
||||
private Long studentId;
|
||||
|
||||
@Property(nameInDb = "NAME")
|
||||
@Property(nameInDb = "current")
|
||||
private boolean current;
|
||||
|
||||
@Property(nameInDb = "name")
|
||||
private String name;
|
||||
|
||||
@Property(nameInDb = "VALUE")
|
||||
@Property(nameInDb = "value")
|
||||
private String value;
|
||||
|
||||
@Property(nameInDb = "IS_CURRENT")
|
||||
private boolean isCurrent;
|
||||
@ToMany(referencedJoinProperty = "diaryId")
|
||||
private List<Semester> semesterList;
|
||||
|
||||
/**
|
||||
* Used to resolve relations
|
||||
@ -39,14 +45,13 @@ public class Diary {
|
||||
@Generated(hash = 21166549)
|
||||
private transient DiaryDao myDao;
|
||||
|
||||
@Generated(hash = 459332202)
|
||||
public Diary(Long id, String studentId, String name, String value,
|
||||
boolean isCurrent) {
|
||||
@Generated(hash = 277096196)
|
||||
public Diary(Long id, Long studentId, boolean current, String name, String value) {
|
||||
this.id = id;
|
||||
this.studentId = studentId;
|
||||
this.current = current;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.isCurrent = isCurrent;
|
||||
}
|
||||
|
||||
@Generated(hash = 112123061)
|
||||
@ -54,25 +59,24 @@ public class Diary {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Diary setId(Long id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStudentId() {
|
||||
return studentId;
|
||||
public Long getStudentId() {
|
||||
return this.studentId;
|
||||
}
|
||||
|
||||
public Diary setStudentId(String studentId) {
|
||||
public Diary setStudentId(Long studentId) {
|
||||
this.studentId = studentId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Diary setName(String name) {
|
||||
@ -81,7 +85,7 @@ public class Diary {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public Diary setValue(String value) {
|
||||
@ -89,31 +93,43 @@ public class Diary {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsCurrent() {
|
||||
return isCurrent;
|
||||
public boolean getCurrent() {
|
||||
return this.current;
|
||||
}
|
||||
|
||||
public Diary setIsCurrent(boolean current) {
|
||||
isCurrent = current;
|
||||
public Diary setCurrent(boolean current) {
|
||||
this.current = current;
|
||||
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;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DiaryDao getMyDao() {
|
||||
return myDao;
|
||||
}
|
||||
|
||||
public Diary setMyDao(DiaryDao myDao) {
|
||||
this.myDao = myDao;
|
||||
return this;
|
||||
/**
|
||||
* Resets a to-many relationship, making the next get call to query for a fresh result.
|
||||
*/
|
||||
@Generated(hash = 995060657)
|
||||
public synchronized void resetSemesterList() {
|
||||
semesterList = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,72 +21,44 @@ public class Grade implements Serializable {
|
||||
@Id(autoincrement = true)
|
||||
protected Long id;
|
||||
|
||||
@Property(nameInDb = "SUBJECT_ID")
|
||||
@Property(nameInDb = "semester_id")
|
||||
private Long semesterId;
|
||||
|
||||
@Property(nameInDb = "subject_id")
|
||||
private Long subjectId;
|
||||
|
||||
@Property(nameInDb = "USER_ID")
|
||||
private Long userId;
|
||||
|
||||
@Property(nameInDb = "SUBJECT")
|
||||
@Property(nameInDb = "subject")
|
||||
private String subject = "";
|
||||
|
||||
@Property(nameInDb = "VALUE")
|
||||
@Property(nameInDb = "value")
|
||||
protected String value = "";
|
||||
|
||||
@Property(nameInDb = "COLOR")
|
||||
private String color = "";
|
||||
|
||||
@Property(nameInDb = "SYMBOL")
|
||||
private String symbol = "";
|
||||
|
||||
@Property(nameInDb = "DESCRIPTION")
|
||||
private String description = "";
|
||||
|
||||
@Property(nameInDb = "WEIGHT")
|
||||
@Property(nameInDb = "weight")
|
||||
private String weight = "";
|
||||
|
||||
@Property(nameInDb = "DATE")
|
||||
@Property(nameInDb = "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 = "";
|
||||
|
||||
@Property(nameInDb = "SEMESTER")
|
||||
private String semester = "";
|
||||
|
||||
@Property(nameInDb = "IS_NEW")
|
||||
@Property(nameInDb = "is_new")
|
||||
private boolean isNew = false;
|
||||
|
||||
@Property(nameInDb = "READ")
|
||||
@Property(nameInDb = "read")
|
||||
private boolean read = true;
|
||||
|
||||
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
|
||||
*/
|
||||
@ -99,6 +71,29 @@ public class Grade implements Serializable {
|
||||
@Generated(hash = 681281562)
|
||||
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() {
|
||||
|
||||
String replacedString = value.replaceAll("[^0-9]", "");
|
||||
@ -133,6 +128,7 @@ public class Grade implements Serializable {
|
||||
Grade grade = (Grade) o;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(semesterId, grade.semesterId)
|
||||
.append(subject, grade.subject)
|
||||
.append(value, grade.value)
|
||||
.append(color, grade.color)
|
||||
@ -141,13 +137,13 @@ public class Grade implements Serializable {
|
||||
.append(weight, grade.weight)
|
||||
.append(date, grade.date)
|
||||
.append(teacher, grade.teacher)
|
||||
.append(semester, grade.semester)
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(semesterId)
|
||||
.append(subject)
|
||||
.append(value)
|
||||
.append(color)
|
||||
@ -156,48 +152,19 @@ public class Grade implements Serializable {
|
||||
.append(weight)
|
||||
.append(date)
|
||||
.append(teacher)
|
||||
.append(semester)
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Grade setId(Long id) {
|
||||
public void setId(Long 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() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public Grade setValue(String value) {
|
||||
@ -205,8 +172,26 @@ public class Grade implements Serializable {
|
||||
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() {
|
||||
return color;
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public Grade setColor(String color) {
|
||||
@ -215,7 +200,7 @@ public class Grade implements Serializable {
|
||||
}
|
||||
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
return this.symbol;
|
||||
}
|
||||
|
||||
public Grade setSymbol(String symbol) {
|
||||
@ -224,7 +209,7 @@ public class Grade implements Serializable {
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public Grade setDescription(String description) {
|
||||
@ -233,7 +218,7 @@ public class Grade implements Serializable {
|
||||
}
|
||||
|
||||
public String getWeight() {
|
||||
return weight;
|
||||
return this.weight;
|
||||
}
|
||||
|
||||
public Grade setWeight(String weight) {
|
||||
@ -242,7 +227,7 @@ public class Grade implements Serializable {
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public Grade setDate(String date) {
|
||||
@ -251,7 +236,7 @@ public class Grade implements Serializable {
|
||||
}
|
||||
|
||||
public String getTeacher() {
|
||||
return teacher;
|
||||
return this.teacher;
|
||||
}
|
||||
|
||||
public Grade setTeacher(String teacher) {
|
||||
@ -259,22 +244,12 @@ public class Grade implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSemester() {
|
||||
return semester;
|
||||
}
|
||||
|
||||
public Grade setSemester(String semester) {
|
||||
this.semester = semester;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsNew() {
|
||||
return this.isNew;
|
||||
}
|
||||
|
||||
public Grade setIsNew(boolean isNew) {
|
||||
public void setIsNew(boolean isNew) {
|
||||
this.isNew = isNew;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getRead() {
|
||||
@ -286,6 +261,17 @@ public class Grade implements Serializable {
|
||||
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)}.
|
||||
* Entity must attached to an entity context.
|
||||
@ -298,6 +284,7 @@ public class Grade implements Serializable {
|
||||
myDao.delete(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
|
||||
* Entity must attached to an entity context.
|
||||
@ -310,6 +297,7 @@ public class Grade implements Serializable {
|
||||
myDao.refresh(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
|
||||
* Entity must attached to an entity context.
|
||||
@ -322,6 +310,7 @@ public class Grade implements Serializable {
|
||||
myDao.update(this);
|
||||
}
|
||||
|
||||
|
||||
/** called by internal mechanisms, do not call yourself. */
|
||||
@Generated(hash = 1187286414)
|
||||
public void __setDaoSession(DaoSession daoSession) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -18,21 +18,18 @@ public class Subject {
|
||||
@Id(autoincrement = true)
|
||||
private Long id;
|
||||
|
||||
@Property(nameInDb = "USER_ID")
|
||||
private Long userId;
|
||||
@Property(nameInDb = "semester_id")
|
||||
private Long semesterId;
|
||||
|
||||
@Property(nameInDb = "NAME")
|
||||
@Property(nameInDb = "name")
|
||||
private String name;
|
||||
|
||||
@Property(nameInDb = "PREDICTED_RATING")
|
||||
@Property(nameInDb = "predicted_rating")
|
||||
private String predictedRating;
|
||||
|
||||
@Property(nameInDb = "FINAL_RATING")
|
||||
@Property(nameInDb = "final_rating")
|
||||
private String finalRating;
|
||||
|
||||
@Property(nameInDb = "SEMESTER")
|
||||
private String semester;
|
||||
|
||||
@ToMany(referencedJoinProperty = "subjectId")
|
||||
private List<Grade> gradeList;
|
||||
|
||||
@ -48,15 +45,14 @@ public class Subject {
|
||||
@Generated(hash = 1644932788)
|
||||
private transient SubjectDao myDao;
|
||||
|
||||
@Generated(hash = 396325764)
|
||||
public Subject(Long id, Long userId, String name, String predictedRating,
|
||||
String finalRating, String semester) {
|
||||
@Generated(hash = 1817932538)
|
||||
public Subject(Long id, Long semesterId, String name, String predictedRating,
|
||||
String finalRating) {
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
this.semesterId = semesterId;
|
||||
this.name = name;
|
||||
this.predictedRating = predictedRating;
|
||||
this.finalRating = finalRating;
|
||||
this.semester = semester;
|
||||
}
|
||||
|
||||
@Generated(hash = 1617906264)
|
||||
@ -64,25 +60,24 @@ public class Subject {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Subject setId(Long id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
public Long getSemesterId() {
|
||||
return this.semesterId;
|
||||
}
|
||||
|
||||
public Subject setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
public Subject setSemesterId(Long semesterId) {
|
||||
this.semesterId = semesterId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Subject setName(String name) {
|
||||
@ -91,7 +86,7 @@ public class Subject {
|
||||
}
|
||||
|
||||
public String getPredictedRating() {
|
||||
return predictedRating;
|
||||
return this.predictedRating;
|
||||
}
|
||||
|
||||
public Subject setPredictedRating(String predictedRating) {
|
||||
@ -100,7 +95,7 @@ public class Subject {
|
||||
}
|
||||
|
||||
public String getFinalRating() {
|
||||
return finalRating;
|
||||
return this.finalRating;
|
||||
}
|
||||
|
||||
public Subject setFinalRating(String finalRating) {
|
||||
@ -108,45 +103,6 @@ public class Subject {
|
||||
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)}.
|
||||
* Entity must attached to an entity context.
|
||||
@ -183,6 +139,34 @@ public class Subject {
|
||||
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. */
|
||||
@Generated(hash = 937984622)
|
||||
public void __setDaoSession(DaoSession daoSession) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -16,58 +16,58 @@ import java.io.Serializable;
|
||||
)
|
||||
public class TimetableLesson implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 42L;
|
||||
|
||||
@Id(autoincrement = true)
|
||||
private Long id;
|
||||
|
||||
@Property(nameInDb = "DAY_ID")
|
||||
@Property(nameInDb = "day_id")
|
||||
private Long dayId;
|
||||
|
||||
@Property(nameInDb = "NUMBER_OF_LESSON")
|
||||
@Property(nameInDb = "number")
|
||||
private String number;
|
||||
|
||||
@Property(nameInDb = "SUBJECT_NAME")
|
||||
@Property(nameInDb = "subject")
|
||||
private String subject = "";
|
||||
|
||||
@Property(nameInDb = "TEACHER")
|
||||
@Property(nameInDb = "teacher")
|
||||
private String teacher = "";
|
||||
|
||||
@Property(nameInDb = "ROOM")
|
||||
@Property(nameInDb = "room")
|
||||
private String room = "";
|
||||
|
||||
@Property(nameInDb = "DESCRIPTION")
|
||||
@Property(nameInDb = "description")
|
||||
private String description = "";
|
||||
|
||||
@Property(nameInDb = "GROUP_NAME")
|
||||
private String groupName = "";
|
||||
@Property(nameInDb = "group")
|
||||
private String group = "";
|
||||
|
||||
@Property(nameInDb = "START_TIME")
|
||||
@Property(nameInDb = "start_time")
|
||||
private String startTime = "";
|
||||
|
||||
@Property(nameInDb = "END_TIME")
|
||||
@Property(nameInDb = "end_time")
|
||||
private String endTime = "";
|
||||
|
||||
@Property(nameInDb = "DATE")
|
||||
@Property(nameInDb = "date")
|
||||
private String date = "";
|
||||
|
||||
@Property(nameInDb = "IS_EMPTY")
|
||||
private boolean isEmpty = false;
|
||||
@Property(nameInDb = "empty")
|
||||
private boolean empty = false;
|
||||
|
||||
@Property(nameInDb = "IS_DIVISION_INTO_GROUP")
|
||||
private boolean isDivisionIntoGroups = false;
|
||||
@Property(nameInDb = "division_into_groups")
|
||||
private boolean divisionIntoGroups = false;
|
||||
|
||||
@Property(nameInDb = "IS_PLANNING")
|
||||
private boolean isPlanning = false;
|
||||
@Property(nameInDb = "planning")
|
||||
private boolean planning = false;
|
||||
|
||||
@Property(nameInDb = "IS_REALIZED")
|
||||
private boolean isRealized = false;
|
||||
@Property(nameInDb = "realized")
|
||||
private boolean realized = false;
|
||||
|
||||
@Property(nameInDb = "IS_MOVED_CANCELED")
|
||||
private boolean isMovedOrCanceled = false;
|
||||
@Property(nameInDb = "moved_canceled")
|
||||
private boolean movedOrCanceled = false;
|
||||
|
||||
@Property(nameInDb = "IS_NEW_MOVED_IN_CANCELED")
|
||||
private boolean isNewMovedInOrChanged = false;
|
||||
|
||||
private static final long serialVersionUID = 42L;
|
||||
@Property(nameInDb = "new_moved_in_canceled")
|
||||
private boolean newMovedInOrChanged = false;
|
||||
|
||||
/**
|
||||
* Used to resolve relations
|
||||
@ -81,12 +81,12 @@ public class TimetableLesson implements Serializable {
|
||||
@Generated(hash = 1119360138)
|
||||
private transient TimetableLessonDao myDao;
|
||||
|
||||
@Generated(hash = 627457324)
|
||||
@Generated(hash = 1955911128)
|
||||
public TimetableLesson(Long id, Long dayId, String number, String subject,
|
||||
String teacher, String room, String description, String groupName,
|
||||
String startTime, String endTime, String date, boolean isEmpty,
|
||||
boolean isDivisionIntoGroups, boolean isPlanning, boolean isRealized,
|
||||
boolean isMovedOrCanceled, boolean isNewMovedInOrChanged) {
|
||||
String teacher, String room, String description, String group,
|
||||
String startTime, String endTime, String date, boolean empty,
|
||||
boolean divisionIntoGroups, boolean planning, boolean realized,
|
||||
boolean movedOrCanceled, boolean newMovedInOrChanged) {
|
||||
this.id = id;
|
||||
this.dayId = dayId;
|
||||
this.number = number;
|
||||
@ -94,16 +94,16 @@ public class TimetableLesson implements Serializable {
|
||||
this.teacher = teacher;
|
||||
this.room = room;
|
||||
this.description = description;
|
||||
this.groupName = groupName;
|
||||
this.group = group;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.date = date;
|
||||
this.isEmpty = isEmpty;
|
||||
this.isDivisionIntoGroups = isDivisionIntoGroups;
|
||||
this.isPlanning = isPlanning;
|
||||
this.isRealized = isRealized;
|
||||
this.isMovedOrCanceled = isMovedOrCanceled;
|
||||
this.isNewMovedInOrChanged = isNewMovedInOrChanged;
|
||||
this.empty = empty;
|
||||
this.divisionIntoGroups = divisionIntoGroups;
|
||||
this.planning = planning;
|
||||
this.realized = realized;
|
||||
this.movedOrCanceled = movedOrCanceled;
|
||||
this.newMovedInOrChanged = newMovedInOrChanged;
|
||||
}
|
||||
|
||||
@Generated(hash = 1878030142)
|
||||
@ -122,8 +122,9 @@ public class TimetableLesson implements Serializable {
|
||||
return this.dayId;
|
||||
}
|
||||
|
||||
public void setDayId(Long dayId) {
|
||||
public TimetableLesson setDayId(Long dayId) {
|
||||
this.dayId = dayId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNumber() {
|
||||
@ -171,12 +172,12 @@ public class TimetableLesson implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return this.groupName;
|
||||
public String getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
public TimetableLesson setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
public TimetableLesson setGroup(String group) {
|
||||
this.group = group;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -207,57 +208,57 @@ public class TimetableLesson implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsEmpty() {
|
||||
return this.isEmpty;
|
||||
public boolean getEmpty() {
|
||||
return this.empty;
|
||||
}
|
||||
|
||||
public TimetableLesson setEmpty(boolean isEmpty) {
|
||||
this.isEmpty = isEmpty;
|
||||
public TimetableLesson setEmpty(boolean empty) {
|
||||
this.empty = empty;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsDivisionIntoGroups() {
|
||||
return this.isDivisionIntoGroups;
|
||||
public boolean getDivisionIntoGroups() {
|
||||
return this.divisionIntoGroups;
|
||||
}
|
||||
|
||||
public TimetableLesson setDivisionIntoGroups(boolean isDivisionIntoGroups) {
|
||||
this.isDivisionIntoGroups = isDivisionIntoGroups;
|
||||
public TimetableLesson setDivisionIntoGroups(boolean divisionIntoGroups) {
|
||||
this.divisionIntoGroups = divisionIntoGroups;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsPlanning() {
|
||||
return this.isPlanning;
|
||||
public boolean getPlanning() {
|
||||
return this.planning;
|
||||
}
|
||||
|
||||
public TimetableLesson setPlanning(boolean isPlanning) {
|
||||
this.isPlanning = isPlanning;
|
||||
public TimetableLesson setPlanning(boolean planning) {
|
||||
this.planning = planning;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsRealized() {
|
||||
return this.isRealized;
|
||||
public boolean getRealized() {
|
||||
return this.realized;
|
||||
}
|
||||
|
||||
public TimetableLesson setRealized(boolean isRealized) {
|
||||
this.isRealized = isRealized;
|
||||
public TimetableLesson setRealized(boolean realized) {
|
||||
this.realized = realized;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsMovedOrCanceled() {
|
||||
return this.isMovedOrCanceled;
|
||||
public boolean getMovedOrCanceled() {
|
||||
return this.movedOrCanceled;
|
||||
}
|
||||
|
||||
public TimetableLesson setMovedOrCanceled(boolean isMovedOrCanceled) {
|
||||
this.isMovedOrCanceled = isMovedOrCanceled;
|
||||
public TimetableLesson setMovedOrCanceled(boolean movedOrCanceled) {
|
||||
this.movedOrCanceled = movedOrCanceled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsNewMovedInOrChanged() {
|
||||
return this.isNewMovedInOrChanged;
|
||||
public boolean getNewMovedInOrChanged() {
|
||||
return this.newMovedInOrChanged;
|
||||
}
|
||||
|
||||
public TimetableLesson setNewMovedInOrChanged(boolean isNewMovedInOrChanged) {
|
||||
this.isNewMovedInOrChanged = isNewMovedInOrChanged;
|
||||
public TimetableLesson setNewMovedInOrChanged(boolean newMovedInOrChanged) {
|
||||
this.newMovedInOrChanged = newMovedInOrChanged;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -297,30 +298,6 @@ public class TimetableLesson implements Serializable {
|
||||
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. */
|
||||
@Generated(hash = 1885258429)
|
||||
public void __setDaoSession(DaoSession daoSession) {
|
||||
|
@ -13,44 +13,48 @@ import java.util.List;
|
||||
@Entity(
|
||||
nameInDb = "Weeks",
|
||||
active = true,
|
||||
indexes ={@Index(value = "userId,startDayDate", unique = true)}
|
||||
indexes = {@Index(value = "diaryId,startDayDate", unique = true)}
|
||||
)
|
||||
public class Week {
|
||||
|
||||
@Id(autoincrement = true)
|
||||
private Long id;
|
||||
|
||||
@Property(nameInDb = "USER_ID")
|
||||
private Long userId;
|
||||
@Property(nameInDb = "diary_id")
|
||||
private Long diaryId;
|
||||
|
||||
@Property(nameInDb = "START_DATE")
|
||||
@Property(nameInDb = "start_day_date")
|
||||
private String startDayDate = "";
|
||||
|
||||
@Property(nameInDb = "IS_ATTENDANCE_SYNCED")
|
||||
private boolean isAttendanceSynced = false;
|
||||
@Property(nameInDb = "attendance_synced")
|
||||
private boolean attendanceSynced = false;
|
||||
|
||||
@Property(nameInDb = "IS_TIMETABLE_SYNCED")
|
||||
private boolean isTimetableSynced = false;
|
||||
@Property(nameInDb = "timetable_synced")
|
||||
private boolean timetableSynced = false;
|
||||
|
||||
@ToMany(referencedJoinProperty = "weekId")
|
||||
private List<Day> dayList;
|
||||
|
||||
/** Used to resolve relations */
|
||||
/**
|
||||
* Used to resolve relations
|
||||
*/
|
||||
@Generated(hash = 2040040024)
|
||||
private transient DaoSession daoSession;
|
||||
|
||||
/** Used for active entity operations. */
|
||||
/**
|
||||
* Used for active entity operations.
|
||||
*/
|
||||
@Generated(hash = 1019310398)
|
||||
private transient WeekDao myDao;
|
||||
|
||||
@Generated(hash = 1745118398)
|
||||
public Week(Long id, Long userId, String startDayDate, boolean isAttendanceSynced,
|
||||
boolean isTimetableSynced) {
|
||||
@Generated(hash = 1608180902)
|
||||
public Week(Long id, Long diaryId, String startDayDate,
|
||||
boolean attendanceSynced, boolean timetableSynced) {
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
this.diaryId = diaryId;
|
||||
this.startDayDate = startDayDate;
|
||||
this.isAttendanceSynced = isAttendanceSynced;
|
||||
this.isTimetableSynced = isTimetableSynced;
|
||||
this.attendanceSynced = attendanceSynced;
|
||||
this.timetableSynced = timetableSynced;
|
||||
}
|
||||
|
||||
@Generated(hash = 2135529658)
|
||||
@ -66,12 +70,12 @@ public class Week {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
public Long getDiaryId() {
|
||||
return diaryId;
|
||||
}
|
||||
|
||||
public Week setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
public Week setDiaryId(Long diaryId) {
|
||||
this.diaryId = diaryId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -84,20 +88,22 @@ public class Week {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsAttendanceSynced() {
|
||||
return this.isAttendanceSynced;
|
||||
public boolean isAttendanceSynced() {
|
||||
return attendanceSynced;
|
||||
}
|
||||
|
||||
public void setIsAttendanceSynced(boolean isAttendanceSynced) {
|
||||
this.isAttendanceSynced = isAttendanceSynced;
|
||||
public Week setAttendanceSynced(boolean attendanceSynced) {
|
||||
this.attendanceSynced = attendanceSynced;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsTimetableSynced() {
|
||||
return this.isTimetableSynced;
|
||||
public boolean isTimetableSynced() {
|
||||
return timetableSynced;
|
||||
}
|
||||
|
||||
public void setIsTimetableSynced(boolean isTimetableSynced) {
|
||||
this.isTimetableSynced = isTimetableSynced;
|
||||
public Week setTimetableSynced(boolean timetableSynced) {
|
||||
this.timetableSynced = timetableSynced;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +128,9 @@ public class Week {
|
||||
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)
|
||||
public synchronized void resetDayList() {
|
||||
dayList = null;
|
||||
@ -164,6 +172,14 @@ public class Week {
|
||||
myDao.update(this);
|
||||
}
|
||||
|
||||
public boolean getAttendanceSynced() {
|
||||
return this.attendanceSynced;
|
||||
}
|
||||
|
||||
public boolean getTimetableSynced() {
|
||||
return this.timetableSynced;
|
||||
}
|
||||
|
||||
/** called by internal mechanisms, do not call yourself. */
|
||||
@Generated(hash = 665278367)
|
||||
public void __setDaoSession(DaoSession daoSession) {
|
||||
|
@ -100,7 +100,7 @@ public class Migration23 implements DbHelper.Migration {
|
||||
private void insertDiaries(Database db, List<Diary> list) {
|
||||
for (Diary diary : list) {
|
||||
db.execSQL("INSERT INTO Diaries(STUDENT_ID, NAME, VALUE, IS_CURRENT) VALUES(" +
|
||||
"\"" + diary.getStudentId() + "\"," +
|
||||
"\"" + diary.getId() + "\"," +
|
||||
"\"" + diary.getName() + "\"," +
|
||||
"\"" + diary.getId() + "\"," +
|
||||
"\"" + (diary.isCurrent() ? "1" : "0") + "\"" +
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -62,27 +62,27 @@ public class AppResources implements ResourcesContract {
|
||||
public String getAttendanceLessonDescription(AttendanceLesson lesson) {
|
||||
int id = R.string.attendance_present;
|
||||
|
||||
if (lesson.getIsAbsenceForSchoolReasons()) {
|
||||
if (lesson.getAbsenceForSchoolReasons()) {
|
||||
id = R.string.attendance_absence_for_school_reasons;
|
||||
}
|
||||
|
||||
if (lesson.getIsAbsenceExcused()) {
|
||||
if (lesson.getAbsenceExcused()) {
|
||||
id = R.string.attendance_absence_excused;
|
||||
}
|
||||
|
||||
if (lesson.getIsAbsenceUnexcused()) {
|
||||
if (lesson.getAbsenceUnexcused()) {
|
||||
id = R.string.attendance_absence_unexcused;
|
||||
}
|
||||
|
||||
if (lesson.getIsExemption()) {
|
||||
if (lesson.getExemption()) {
|
||||
id = R.string.attendance_exemption;
|
||||
}
|
||||
|
||||
if (lesson.getIsExcusedLateness()) {
|
||||
if (lesson.getExcusedLateness()) {
|
||||
id = R.string.attendance_excused_lateness;
|
||||
}
|
||||
|
||||
if (lesson.getIsUnexcusedLateness()) {
|
||||
if (lesson.getUnexcusedLateness()) {
|
||||
id = R.string.attendance_unexcused_lateness;
|
||||
}
|
||||
|
||||
|
@ -7,5 +7,5 @@ import io.github.wulkanowy.api.VulcanException;
|
||||
|
||||
public interface SyncContract {
|
||||
|
||||
void sync() throws VulcanException, IOException, ParseException;
|
||||
void sync(long semesterId) throws VulcanException, IOException, ParseException;
|
||||
}
|
||||
|
@ -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.Diary;
|
||||
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.di.annotations.ApplicationContext;
|
||||
import io.github.wulkanowy.utils.DataObjectConverter;
|
||||
@ -45,25 +50,73 @@ public class AccountSync implements AccountSyncContract {
|
||||
public void registerUser(String email, String password, String symbol)
|
||||
throws VulcanException, IOException, CryptoException {
|
||||
|
||||
LogUtils.debug("Register new user email=" + email);
|
||||
|
||||
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()
|
||||
.setName(vulcan.getBasicInformation().getPersonalData().getFirstAndLastName())
|
||||
.setEmail(email)
|
||||
.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());
|
||||
|
||||
.setPassword(Scrambler.encrypt(email, password, context));
|
||||
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
|
||||
@ -78,14 +131,26 @@ public class AccountSync implements AccountSyncContract {
|
||||
LogUtils.debug("Initialization current user id=" + userId);
|
||||
|
||||
Account account = daoSession.getAccountDao().load(userId);
|
||||
String email = account.getEmail();
|
||||
String pass = Scrambler.decrypt(account.getEmail(), account.getPassword());
|
||||
|
||||
vulcan.setCredentials(account.getEmail(),
|
||||
Scrambler.decrypt(account.getEmail(), account.getPassword()),
|
||||
account.getSymbol(),
|
||||
account.getSchoolId(),
|
||||
account.getRealId(),
|
||||
daoSession.getDiaryDao().queryBuilder()
|
||||
.where(DiaryDao.Properties.IsCurrent.eq(true)).unique().getValue()
|
||||
);
|
||||
Symbol symbolE = daoSession.getSymbolDao().queryBuilder().where(
|
||||
SymbolDao.Properties.UserId.eq(account.getId())).unique();
|
||||
String symbol = symbolE.getSymbol();
|
||||
String schoolId = symbolE.getSchoolId();
|
||||
|
||||
Student studentE = daoSession.getStudentDao().queryBuilder().where(
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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.Week;
|
||||
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.LogUtils;
|
||||
import io.github.wulkanowy.utils.TimeUtils;
|
||||
@ -28,27 +27,24 @@ public class AttendanceSync implements AttendanceSyncContract {
|
||||
|
||||
private final DaoSession daoSession;
|
||||
|
||||
private final SharedPrefContract sharedPref;
|
||||
|
||||
private final Vulcan vulcan;
|
||||
|
||||
private long userId;
|
||||
private long diaryId;
|
||||
|
||||
@Inject
|
||||
AttendanceSync(DaoSession daoSession, SharedPrefContract sharedPref, Vulcan vulcan) {
|
||||
AttendanceSync(DaoSession daoSession, Vulcan vulcan) {
|
||||
this.daoSession = daoSession;
|
||||
this.sharedPref = sharedPref;
|
||||
this.vulcan = vulcan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAttendance() throws IOException, ParseException, VulcanException {
|
||||
syncAttendance(null);
|
||||
public void syncAttendance(long diaryId) throws IOException, ParseException, VulcanException {
|
||||
syncAttendance(diaryId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAttendance(String date) throws IOException, ParseException, VulcanException {
|
||||
this.userId = sharedPref.getCurrentUserId();
|
||||
public void syncAttendance(long diaryId, String date) throws IOException, ParseException, VulcanException {
|
||||
this.diaryId = diaryId;
|
||||
|
||||
io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> weekApi = getWeekFromApi(getNormalizedDate(date));
|
||||
Week weekDb = getWeekFromDb(weekApi.getStartDayDate());
|
||||
@ -72,22 +68,22 @@ public class AttendanceSync implements AttendanceSyncContract {
|
||||
}
|
||||
|
||||
private Week getWeekFromDb(String date) {
|
||||
return daoSession.getWeekDao()
|
||||
.queryBuilder()
|
||||
.where(WeekDao.Properties.UserId.eq(userId), WeekDao.Properties.StartDayDate.eq(date))
|
||||
.unique();
|
||||
return daoSession.getWeekDao().queryBuilder().where(
|
||||
WeekDao.Properties.DiaryId.eq(diaryId),
|
||||
WeekDao.Properties.StartDayDate.eq(date)
|
||||
).unique();
|
||||
}
|
||||
|
||||
private Long updateWeekInDb(Week dbWeekEntity, io.github.wulkanowy.api.generic.Week fromApi) {
|
||||
if (dbWeekEntity != null) {
|
||||
dbWeekEntity.setIsAttendanceSynced(true);
|
||||
dbWeekEntity.setAttendanceSynced(true);
|
||||
dbWeekEntity.update();
|
||||
|
||||
return dbWeekEntity.getId();
|
||||
}
|
||||
|
||||
Week apiWeekEntity = DataObjectConverter.weekToWeekEntity(fromApi).setUserId(userId);
|
||||
apiWeekEntity.setIsAttendanceSynced(true);
|
||||
Week apiWeekEntity = DataObjectConverter.weekToWeekEntity(fromApi).setDiaryId(diaryId);
|
||||
apiWeekEntity.setAttendanceSynced(true);
|
||||
|
||||
return daoSession.getWeekDao().insert(apiWeekEntity);
|
||||
}
|
||||
@ -97,7 +93,7 @@ public class AttendanceSync implements AttendanceSyncContract {
|
||||
|
||||
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);
|
||||
|
||||
@ -109,11 +105,12 @@ public class AttendanceSync implements AttendanceSyncContract {
|
||||
return updatedLessonList;
|
||||
}
|
||||
|
||||
private Day getDayFromDb(String date) {
|
||||
return daoSession.getDayDao()
|
||||
.queryBuilder()
|
||||
.where(DayDao.Properties.UserId.eq(userId), DayDao.Properties.Date.eq(date))
|
||||
.unique();
|
||||
private Day getDayFromDb(String date, long weekId) {
|
||||
return daoSession.getDayDao().queryBuilder()
|
||||
.where(
|
||||
DayDao.Properties.WeekId.eq(weekId),
|
||||
DayDao.Properties.Date.eq(date)
|
||||
).unique();
|
||||
}
|
||||
|
||||
private long updateDay(Day dbDayEntity, Day apiDayEntity, long weekId) {
|
||||
@ -121,7 +118,6 @@ public class AttendanceSync implements AttendanceSyncContract {
|
||||
return dbDayEntity.getId();
|
||||
}
|
||||
|
||||
apiDayEntity.setUserId(userId);
|
||||
apiDayEntity.setWeekId(weekId);
|
||||
|
||||
return daoSession.getDayDao().insert(apiDayEntity);
|
||||
|
@ -7,7 +7,7 @@ import io.github.wulkanowy.api.VulcanException;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -10,11 +10,10 @@ import javax.inject.Singleton;
|
||||
|
||||
import io.github.wulkanowy.api.Vulcan;
|
||||
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.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.shared.SharedPrefContract;
|
||||
import io.github.wulkanowy.data.sync.SyncContract;
|
||||
import io.github.wulkanowy.utils.DataObjectConverter;
|
||||
import io.github.wulkanowy.utils.EntitiesCompare;
|
||||
@ -27,65 +26,59 @@ public class GradeSync implements SyncContract {
|
||||
|
||||
private final Vulcan vulcan;
|
||||
|
||||
private final SharedPrefContract sharedPref;
|
||||
|
||||
private Long userId;
|
||||
private long semesterId;
|
||||
|
||||
@Inject
|
||||
GradeSync(DaoSession daoSession, SharedPrefContract sharedPref, Vulcan vulcan) {
|
||||
GradeSync(DaoSession daoSession, Vulcan vulcan) {
|
||||
this.daoSession = daoSession;
|
||||
this.sharedPref = sharedPref;
|
||||
this.vulcan = vulcan;
|
||||
}
|
||||
|
||||
@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);
|
||||
resetAccountRelations(account);
|
||||
List<Grade> lastList = getUpdatedList(getComparedList(semester));
|
||||
|
||||
List<Grade> lastList = getUpdatedList(getComparedList(account));
|
||||
|
||||
daoSession.getGradeDao().deleteInTx(account.getGradeList());
|
||||
daoSession.getGradeDao().deleteInTx(semester.getGradeList());
|
||||
daoSession.getGradeDao().insertInTx(lastList);
|
||||
|
||||
LogUtils.debug("Synchronization grades (amount = " + lastList.size() + ")");
|
||||
}
|
||||
|
||||
private void resetAccountRelations(Account account) {
|
||||
account.resetSubjectList();
|
||||
account.resetGradeList();
|
||||
private void resetSemesterRelations(Semester semester) {
|
||||
semester.resetSubjectList();
|
||||
semester.resetGradeList();
|
||||
}
|
||||
|
||||
private List<Grade> getUpdatedList(List<Grade> comparedList) {
|
||||
List<Grade> updatedList = new ArrayList<>();
|
||||
|
||||
for (Grade grade : comparedList) {
|
||||
grade.setUserId(userId);
|
||||
grade.setSemesterId(semesterId);
|
||||
grade.setSubjectId(getSubjectId(grade.getSubject()));
|
||||
updatedList.add(grade);
|
||||
}
|
||||
|
||||
return updatedList;
|
||||
}
|
||||
|
||||
private List<Grade> getComparedList(Account account) throws IOException, VulcanException,
|
||||
ParseException {
|
||||
List<Grade> gradesFromNet = DataObjectConverter
|
||||
.gradesToGradeEntities(vulcan.getGradesList().getAll());
|
||||
private List<Grade> getComparedList(Semester semester) throws IOException, VulcanException, ParseException {
|
||||
List<Grade> gradesFromNet = DataObjectConverter.gradesToGradeEntities(
|
||||
vulcan.getGradesList().getAll(semester.getValue()), semesterId);
|
||||
|
||||
List<Grade> gradesFromDb = account.getGradeList();
|
||||
List<Grade> gradesFromDb = semester.getGradeList();
|
||||
|
||||
return EntitiesCompare.compareGradeList(gradesFromNet, gradesFromDb);
|
||||
}
|
||||
|
||||
private Long getSubjectId(String subjectName) {
|
||||
return daoSession.getSubjectDao().queryBuilder()
|
||||
.where(SubjectDao.Properties.Name.eq(subjectName),
|
||||
SubjectDao.Properties.UserId.eq(userId))
|
||||
.build()
|
||||
.uniqueOrThrow()
|
||||
.getId();
|
||||
return daoSession.getSubjectDao().queryBuilder().where(
|
||||
SubjectDao.Properties.Name.eq(subjectName),
|
||||
SubjectDao.Properties.SemesterId.eq(semesterId)
|
||||
).build().uniqueOrThrow().getId();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.github.wulkanowy.data.sync.subjects;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -10,10 +9,9 @@ import javax.inject.Singleton;
|
||||
|
||||
import io.github.wulkanowy.api.Vulcan;
|
||||
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.Semester;
|
||||
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.utils.DataObjectConverter;
|
||||
import io.github.wulkanowy.utils.LogUtils;
|
||||
@ -25,21 +23,17 @@ public class SubjectSync implements SyncContract {
|
||||
|
||||
private final Vulcan vulcan;
|
||||
|
||||
private final SharedPrefContract sharedPref;
|
||||
|
||||
private Long userId;
|
||||
private long semesterId;
|
||||
|
||||
@Inject
|
||||
SubjectSync(DaoSession daoSession, SharedPrefContract sharedPref, Vulcan vulcan) {
|
||||
SubjectSync(DaoSession daoSession, Vulcan vulcan) {
|
||||
this.daoSession = daoSession;
|
||||
this.sharedPref = sharedPref;
|
||||
this.vulcan = vulcan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync() throws VulcanException, IOException, ParseException {
|
||||
|
||||
userId = sharedPref.getCurrentUserId();
|
||||
public void sync(long semesterId) throws VulcanException, IOException {
|
||||
this.semesterId = semesterId;
|
||||
|
||||
List<Subject> lastList = getUpdatedList(getSubjectsFromNet());
|
||||
|
||||
@ -50,20 +44,21 @@ public class SubjectSync implements SyncContract {
|
||||
}
|
||||
|
||||
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() {
|
||||
Account account = daoSession.getAccountDao().load(userId);
|
||||
account.resetSubjectList();
|
||||
return account.getSubjectList();
|
||||
Semester semester = daoSession.getSemesterDao().load(semesterId);
|
||||
semester.resetSubjectList();
|
||||
return semester.getSubjectList();
|
||||
}
|
||||
|
||||
private List<Subject> getUpdatedList(List<Subject> subjectsFromNet) {
|
||||
List<Subject> updatedList = new ArrayList<>();
|
||||
|
||||
for (Subject subject : subjectsFromNet) {
|
||||
subject.setUserId(userId);
|
||||
subject.setSemesterId(semesterId);
|
||||
updatedList.add(subject);
|
||||
}
|
||||
return updatedList;
|
||||
|
@ -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.Week;
|
||||
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.LogUtils;
|
||||
import io.github.wulkanowy.utils.TimeUtils;
|
||||
@ -28,27 +27,24 @@ public class TimetableSync implements TimetableSyncContract {
|
||||
|
||||
private final DaoSession daoSession;
|
||||
|
||||
private final SharedPrefContract sharedPref;
|
||||
|
||||
private final Vulcan vulcan;
|
||||
|
||||
private long userId;
|
||||
private long diaryId;
|
||||
|
||||
@Inject
|
||||
TimetableSync(DaoSession daoSession, SharedPrefContract sharedPref, Vulcan vulcan) {
|
||||
TimetableSync(DaoSession daoSession, Vulcan vulcan) {
|
||||
this.daoSession = daoSession;
|
||||
this.sharedPref = sharedPref;
|
||||
this.vulcan = vulcan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncTimetable() throws IOException, ParseException, VulcanException {
|
||||
syncTimetable(null);
|
||||
public void syncTimetable(long diaryId) throws IOException, ParseException, VulcanException {
|
||||
syncTimetable(diaryId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncTimetable(String date) throws IOException, ParseException, VulcanException {
|
||||
this.userId = sharedPref.getCurrentUserId();
|
||||
public void syncTimetable(long diaryId, String date) throws IOException, ParseException, VulcanException {
|
||||
this.diaryId = diaryId;
|
||||
|
||||
io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> weekApi = getWeekFromApi(getNormalizedDate(date));
|
||||
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)
|
||||
throws IOException, VulcanException, ParseException {
|
||||
throws IOException, ParseException, VulcanException {
|
||||
return vulcan.getTimetable().getWeekTable(date);
|
||||
}
|
||||
|
||||
private Week getWeekFromDb(String date) {
|
||||
return daoSession.getWeekDao()
|
||||
.queryBuilder()
|
||||
.where(WeekDao.Properties.UserId.eq(userId), WeekDao.Properties.StartDayDate.eq(date))
|
||||
.unique();
|
||||
return daoSession.getWeekDao().queryBuilder().where(
|
||||
WeekDao.Properties.DiaryId.eq(diaryId),
|
||||
WeekDao.Properties.StartDayDate.eq(date)
|
||||
).unique();
|
||||
}
|
||||
|
||||
private Long updateWeekInDb(Week dbEntity, io.github.wulkanowy.api.generic.Week fromApi) {
|
||||
if (dbEntity != null) {
|
||||
dbEntity.setIsTimetableSynced(true);
|
||||
dbEntity.setTimetableSynced(true);
|
||||
dbEntity.update();
|
||||
|
||||
return dbEntity.getId();
|
||||
}
|
||||
|
||||
Week apiEntity = DataObjectConverter.weekToWeekEntity(fromApi).setUserId(userId);
|
||||
apiEntity.setIsTimetableSynced(true);
|
||||
Week apiEntity = DataObjectConverter.weekToWeekEntity(fromApi).setDiaryId(diaryId);
|
||||
apiEntity.setTimetableSynced(true);
|
||||
|
||||
return daoSession.getWeekDao().insert(apiEntity);
|
||||
}
|
||||
@ -97,7 +93,7 @@ public class TimetableSync implements TimetableSyncContract {
|
||||
|
||||
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);
|
||||
|
||||
@ -109,15 +105,14 @@ public class TimetableSync implements TimetableSyncContract {
|
||||
return updatedLessonList;
|
||||
}
|
||||
|
||||
private Day getDayFromDb(String date) {
|
||||
return daoSession.getDayDao()
|
||||
.queryBuilder()
|
||||
.where(DayDao.Properties.UserId.eq(userId), DayDao.Properties.Date.eq(date))
|
||||
.unique();
|
||||
private Day getDayFromDb(String date, long weekId) {
|
||||
return daoSession.getDayDao().queryBuilder().where(
|
||||
DayDao.Properties.WeekId.eq(weekId),
|
||||
DayDao.Properties.Date.eq(date)
|
||||
).unique();
|
||||
}
|
||||
|
||||
private long updateDay(Day dayFromDb, Day apiDayEntity, long weekId) {
|
||||
apiDayEntity.setUserId(userId);
|
||||
apiDayEntity.setWeekId(weekId);
|
||||
|
||||
if (null != dayFromDb) {
|
||||
|
@ -7,7 +7,7 @@ import io.github.wulkanowy.api.VulcanException;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class AttendanceDialogFragment extends DialogFragment {
|
||||
|
||||
description.setText(lesson.getDescription());
|
||||
|
||||
if (lesson.getIsAbsenceUnexcused()) {
|
||||
if (lesson.getAbsenceUnexcused()) {
|
||||
description.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class AttendanceHeaderItem
|
||||
private int countNotPresentHours(List<AttendanceSubItem> subItems) {
|
||||
int i = 0;
|
||||
for (AttendanceSubItem subItem : subItems) {
|
||||
if (subItem.getLesson().getIsAbsenceUnexcused()) {
|
||||
if (subItem.getLesson().getAbsenceUnexcused()) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -150,8 +150,8 @@ public class AttendanceHeaderItem
|
||||
|
||||
private boolean isSubItemsHasChanges(List<AttendanceSubItem> subItems) {
|
||||
for (AttendanceSubItem subItem : subItems) {
|
||||
if (subItem.getLesson().getIsAbsenceUnexcused() || subItem.getLesson()
|
||||
.getIsUnexcusedLateness()) {
|
||||
if (subItem.getLesson().getAbsenceUnexcused() || subItem.getLesson()
|
||||
.getUnexcusedLateness()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class AttendanceSubItem
|
||||
lessonName.setText(lesson.getSubject());
|
||||
lessonNumber.setText((String.valueOf(lesson.getNumber())));
|
||||
lessonDescription.setText(lesson.getDescription());
|
||||
alert.setVisibility(lesson.getIsAbsenceUnexcused() || lesson.getIsUnexcusedLateness()
|
||||
alert.setVisibility(lesson.getAbsenceUnexcused() || lesson.getUnexcusedLateness()
|
||||
? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class AttendanceTabPresenter extends BasePresenter<AttendanceTabContract.
|
||||
public void onDoInBackgroundLoading() throws Exception {
|
||||
Week week = getRepository().getWeek(date);
|
||||
|
||||
if (week == null || !week.getIsAttendanceSynced()) {
|
||||
if (week == null || !week.getAttendanceSynced()) {
|
||||
syncData();
|
||||
week = getRepository().getWeek(date);
|
||||
}
|
||||
|
@ -103,8 +103,8 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDoInBackgroundLoading() throws Exception {
|
||||
List<Subject> subjectList = getRepository().getCurrentUser().getSubjectList();
|
||||
public void onDoInBackgroundLoading() {
|
||||
List<Subject> subjectList = getRepository().getSubjectList();
|
||||
|
||||
headerItems = new ArrayList<>();
|
||||
|
||||
|
@ -91,8 +91,8 @@ public class TimetableDialogFragment extends DialogFragment {
|
||||
teacherLabel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (!lesson.getGroupName().isEmpty()) {
|
||||
group.setText(lesson.getGroupName());
|
||||
if (!lesson.getGroup().isEmpty()) {
|
||||
group.setText(lesson.getGroup());
|
||||
} else {
|
||||
group.setVisibility(View.GONE);
|
||||
groupLabel.setVisibility(View.GONE);
|
||||
|
@ -105,9 +105,9 @@ public class TimetableHeaderItem
|
||||
dayName.setText(StringUtils.capitalize(item.getDayName()));
|
||||
date.setText(item.getDate());
|
||||
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());
|
||||
setInactiveHeader(item.getIsFreeDay());
|
||||
setInactiveHeader(item.getFreeDay());
|
||||
}
|
||||
|
||||
private void setInactiveHeader(boolean inactive) {
|
||||
@ -134,8 +134,8 @@ public class TimetableHeaderItem
|
||||
boolean isAlertActive = false;
|
||||
|
||||
for (TimetableSubItem subItem : subItems) {
|
||||
if (subItem.getLesson().getIsMovedOrCanceled() ||
|
||||
subItem.getLesson().getIsNewMovedInOrChanged()) {
|
||||
if (subItem.getLesson().getMovedOrCanceled() ||
|
||||
subItem.getLesson().getNewMovedInOrChanged()) {
|
||||
isAlertActive = true;
|
||||
}
|
||||
}
|
||||
|
@ -108,9 +108,9 @@ public class TimetableSubItem
|
||||
lessonTime.setText(getLessonTimeString());
|
||||
numberOfLesson.setText(lesson.getNumber());
|
||||
room.setText(getRoomString());
|
||||
alert.setVisibility(lesson.getIsMovedOrCanceled() || lesson.getIsNewMovedInOrChanged()
|
||||
alert.setVisibility(lesson.getMovedOrCanceled() || lesson.getNewMovedInOrChanged()
|
||||
? View.VISIBLE : View.INVISIBLE);
|
||||
lessonName.setPaintFlags(lesson.getIsMovedOrCanceled() ? lessonName.getPaintFlags()
|
||||
lessonName.setPaintFlags(lesson.getMovedOrCanceled() ? lessonName.getPaintFlags()
|
||||
| Paint.STRIKE_THRU_TEXT_FLAG :
|
||||
lessonName.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
|
||||
room.setText(getRoomString());
|
||||
|
@ -97,7 +97,7 @@ public class TimetableTabPresenter extends BasePresenter<TimetableTabContract.Vi
|
||||
public void onDoInBackgroundLoading() throws Exception {
|
||||
Week week = getRepository().getWeek(date);
|
||||
|
||||
if (week == null || !week.getIsTimetableSynced()) {
|
||||
if (week == null || !week.getTimetableSynced()) {
|
||||
syncData();
|
||||
week = getRepository().getWeek(date);
|
||||
}
|
||||
@ -113,7 +113,7 @@ public class TimetableTabPresenter extends BasePresenter<TimetableTabContract.Vi
|
||||
TimetableHeaderItem headerItem = new TimetableHeaderItem(day);
|
||||
|
||||
if (isFreeWeek) {
|
||||
isFreeWeek = day.getIsFreeDay();
|
||||
isFreeWeek = day.getFreeDay();
|
||||
}
|
||||
|
||||
List<TimetableLesson> lessonList = day.getTimetableLessons();
|
||||
|
@ -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.Diary;
|
||||
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.TimetableLesson;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Week;
|
||||
@ -18,26 +20,56 @@ public final class DataObjectConverter {
|
||||
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<>();
|
||||
|
||||
for (io.github.wulkanowy.api.Diary diary : diaryList) {
|
||||
Diary diaryEntity = new Diary()
|
||||
diaryEntityList.add(new Diary()
|
||||
.setStudentId(studentId)
|
||||
.setValue(diary.getId())
|
||||
.setName(diary.getName())
|
||||
.setStudentId(diary.getStudentId())
|
||||
.setIsCurrent(diary.isCurrent());
|
||||
diaryEntityList.add(diaryEntity);
|
||||
.setCurrent(diary.isCurrent()));
|
||||
}
|
||||
|
||||
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<>();
|
||||
|
||||
for (io.github.wulkanowy.api.grades.Subject subject : subjectList) {
|
||||
Subject subjectEntity = new Subject()
|
||||
.setSemesterId(semesterId)
|
||||
.setName(subject.getName())
|
||||
.setPredictedRating(subject.getPredictedRating())
|
||||
.setFinalRating(subject.getFinalRating());
|
||||
@ -47,11 +79,11 @@ public final class DataObjectConverter {
|
||||
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<>();
|
||||
|
||||
for (io.github.wulkanowy.api.grades.Grade grade : gradeList) {
|
||||
Grade gradeEntity = new Grade()
|
||||
gradeEntityList.add(new Grade()
|
||||
.setSubject(grade.getSubject())
|
||||
.setValue(grade.getValue())
|
||||
.setColor(grade.getColor())
|
||||
@ -60,10 +92,9 @@ public final class DataObjectConverter {
|
||||
.setWeight(grade.getWeight())
|
||||
.setDate(grade.getDate())
|
||||
.setTeacher(grade.getTeacher())
|
||||
.setSemester(grade.getSemester());
|
||||
|
||||
gradeEntityList.add(gradeEntity);
|
||||
.setSemesterId(semesterId));
|
||||
}
|
||||
|
||||
return gradeEntityList;
|
||||
}
|
||||
|
||||
@ -75,11 +106,10 @@ public final class DataObjectConverter {
|
||||
return new Day()
|
||||
.setDate(day.getDate())
|
||||
.setDayName(day.getDayName())
|
||||
.setIsFreeDay(day.isFreeDay())
|
||||
.setFreeDay(day.isFreeDay())
|
||||
.setFreeDayName(day.getFreeDayName());
|
||||
}
|
||||
|
||||
|
||||
public static List<Day> daysToDaysEntities(List<io.github.wulkanowy.api.generic.Day> dayList) {
|
||||
List<Day> dayEntityList = new ArrayList<>();
|
||||
|
||||
@ -89,14 +119,24 @@ public final class DataObjectConverter {
|
||||
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()
|
||||
.setNumber(lesson.getNumber())
|
||||
.setSubject(lesson.getSubject())
|
||||
.setTeacher(lesson.getTeacher())
|
||||
.setRoom(lesson.getRoom())
|
||||
.setDescription(lesson.getDescription())
|
||||
.setGroupName(lesson.getGroupName())
|
||||
.setGroup(lesson.getGroupName())
|
||||
.setStartTime(lesson.getStartTime())
|
||||
.setEndTime(lesson.getEndTime())
|
||||
.setDate(lesson.getDate())
|
||||
@ -108,35 +148,27 @@ public final class DataObjectConverter {
|
||||
.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) {
|
||||
List<AttendanceLesson> lessonEntityList = new ArrayList<>();
|
||||
|
||||
for (io.github.wulkanowy.api.generic.Lesson lesson : lessonList) {
|
||||
lessonEntityList.add(lessonToAttendanceLessonEntity(lesson));
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class DataObjectConverterTest {
|
||||
List<Subject> subjectList = new ArrayList<>();
|
||||
subjectList.add(new Subject().setName("Matematyka"));
|
||||
List<io.github.wulkanowy.data.db.dao.entities.Subject> subjectEntitiesList =
|
||||
DataObjectConverter.subjectsToSubjectEntities(subjectList);
|
||||
DataObjectConverter.subjectsToSubjectEntities(subjectList, 1L);
|
||||
|
||||
Assert.assertEquals("Matematyka", subjectEntitiesList.get(0).getName());
|
||||
}
|
||||
@ -27,7 +27,7 @@ public class DataObjectConverterTest {
|
||||
@Test
|
||||
public void subjectConversionEmptyTest() {
|
||||
Assert.assertEquals(new ArrayList<>(),
|
||||
DataObjectConverter.subjectsToSubjectEntities(new ArrayList<Subject>()));
|
||||
DataObjectConverter.subjectsToSubjectEntities(new ArrayList<Subject>(), 1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -35,7 +35,7 @@ public class DataObjectConverterTest {
|
||||
List<Grade> gradeList = new ArrayList<>();
|
||||
gradeList.add(new Grade().setDescription("Lorem ipsum"));
|
||||
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());
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class DataObjectConverterTest {
|
||||
@Test
|
||||
public void gradeConversionEmptyTest() {
|
||||
Assert.assertEquals(new ArrayList<>(),
|
||||
DataObjectConverter.gradesToGradeEntities(new ArrayList<Grade>()));
|
||||
DataObjectConverter.gradesToGradeEntities(new ArrayList<Grade>(), 1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -30,8 +30,7 @@ public class EntitiesCompareTest {
|
||||
.setDescription("Lorem ipsum")
|
||||
.setWeight("10")
|
||||
.setDate("01.01.2017")
|
||||
.setTeacher("Andrzej")
|
||||
.setSemester("777");
|
||||
.setTeacher("Andrzej");
|
||||
|
||||
grade2 = new Grade()
|
||||
.setSubject("Religia")
|
||||
@ -41,8 +40,7 @@ public class EntitiesCompareTest {
|
||||
.setDescription("Wolna wola")
|
||||
.setWeight("10")
|
||||
.setDate("01.01.2017")
|
||||
.setTeacher("Andrzej")
|
||||
.setSemester("777");
|
||||
.setTeacher("Andrzej");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user