// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
//     private final DateTime mCurrentDateTime;
//     private static int mDaysOfYear = 0;
//     private static int mSemester;
// 
//     public StudentCalendar() {
//         mCurrentDateTime = new DateTime();
//         mDaysOfYear = getDaysOfYear();
// 
//         if (mCurrentDateTime.getMonthOfYear() >= 9) {
//             mSemester = 1;
//         } else {
//             mSemester = 2;
//         }
//     }
// 
//     public int getDayOfYear() {
//         int dayOfYear;
//         if (mCurrentDateTime.getMonthOfYear() >= 9) {
//             DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
//         } else {
//             DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
//         }
// 
//         return dayOfYear + 1;
//     }
// 
//     public int getDayOfYear(DateTime dateTime) {
//         int dayOfYear;
//         if (dateTime.getMonthOfYear() >= 9) {
//             DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
//         } else {
//             DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
//         }
//         return dayOfYear;
//     }
// 
//     public int getDaysOfYear() {
//         if (mDaysOfYear == 0) {
//             DateTime september;
//             DateTime august;
// 
//             if (mCurrentDateTime.getMonthOfYear() <= 8) {
//                 september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
//                 august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
//             } else {
//                 september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
//                 august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
//             }
// 
//             mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
//         }
//         return mDaysOfYear;
//     }
// 
//     public static int getWorkWeek(DateTime dateTime) {
//         DateTime september;
// 
//         if (dateTime.getMonthOfYear() <= 8) {
//             september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
//         }
// 
//         Interval interval = new Interval(september, dateTime);
//         int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
//         workWeek = workWeek == 0 ? 4 : workWeek;
//         return workWeek;
//     }
// 
//     public static DateTime convertToDefaultDateTime(int studentDay) {
//         DateTime september;
//         int currentMonth = DateTime.now().getMonthOfYear();
//         if (currentMonth <= 8) {
//             september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
//         }
//         return september.plusDays(studentDay - 1);
//     }
// 
//     public int getSemester() {
//         return mSemester;
//     }
// 
//     public static long getStartStudentYear() {
//         DateTime september;
// 
//         if (DateTime.now().getMonthOfYear() <= 8) {
//             september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
//         }
// 
//         return september.getMillis();
//     }
// 
//     public static long getEndStudentYear() {
//         DateTime august;
//         if (DateTime.now().getMonthOfYear() <= 8) {
//             august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
//         } else {
//             august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
//         }
//         return august.getMillis();
//     }
// 
// }


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.ArrayList;
import java.util.Map;

    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i2) {
        /*
        sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_COMMENTS);
        onCreate(sqLiteDatabase);
        */
    }

    public ArrayList<Lesson> fetchAllLessons(String groupId) {
        this.open();
        String scheduleGroup = "schedule_" + groupId;
        Cursor c = db.rawQuery("SELECT*FROM " + scheduleGroup, null);
        ArrayList<Lesson> lessons = new ArrayList<Lesson>(c.getCount());

        while (c.moveToNext()) {
            Lesson lesson = new Lesson();
            setDataFromCursor(lesson, c);
            lessons.add(lesson);
        }

        this.close();
        return lessons;
    }

    public Lesson[] getLessonsOfDay(String groupID, DateTime dayOfYear, int subgroup) {
        String sWeekDay = "";
        int weekDay = dayOfYear.getDayOfWeek();
// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
//     private final DateTime mCurrentDateTime;
//     private static int mDaysOfYear = 0;
//     private static int mSemester;
// 
//     public StudentCalendar() {
//         mCurrentDateTime = new DateTime();
//         mDaysOfYear = getDaysOfYear();
// 
//         if (mCurrentDateTime.getMonthOfYear() >= 9) {
//             mSemester = 1;
//         } else {
//             mSemester = 2;
//         }
//     }
// 
//     public int getDayOfYear() {
//         int dayOfYear;
//         if (mCurrentDateTime.getMonthOfYear() >= 9) {
//             DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
//         } else {
//             DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
//         }
// 
//         return dayOfYear + 1;
//     }
// 
//     public int getDayOfYear(DateTime dateTime) {
//         int dayOfYear;
//         if (dateTime.getMonthOfYear() >= 9) {
//             DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
//         } else {
//             DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
//         }
//         return dayOfYear;
//     }
// 
//     public int getDaysOfYear() {
//         if (mDaysOfYear == 0) {
//             DateTime september;
//             DateTime august;
// 
//             if (mCurrentDateTime.getMonthOfYear() <= 8) {
//                 september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
//                 august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
//             } else {
//                 september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
//                 august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
//             }
// 
//             mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
//         }
//         return mDaysOfYear;
//     }
// 
//     public static int getWorkWeek(DateTime dateTime) {
//         DateTime september;
// 
//         if (dateTime.getMonthOfYear() <= 8) {
//             september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
//         }
// 
//         Interval interval = new Interval(september, dateTime);
//         int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
//         workWeek = workWeek == 0 ? 4 : workWeek;
//         return workWeek;
//     }
// 
//     public static DateTime convertToDefaultDateTime(int studentDay) {
//         DateTime september;
//         int currentMonth = DateTime.now().getMonthOfYear();
//         if (currentMonth <= 8) {
//             september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
//         }
//         return september.plusDays(studentDay - 1);
//     }
// 
//     public int getSemester() {
//         return mSemester;
//     }
// 
//     public static long getStartStudentYear() {
//         DateTime september;
// 
//         if (DateTime.now().getMonthOfYear() <= 8) {
//             september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
//         }
// 
//         return september.getMillis();
//     }
// 
//     public static long getEndStudentYear() {
//         DateTime august;
//         if (DateTime.now().getMonthOfYear() <= 8) {
//             august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
//         } else {
//             august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
//         }
//         return august.getMillis();
//     }
// 
// }


// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleDatabase.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.ArrayList;
import java.util.Map;


    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i2) {
        /*
        sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_COMMENTS);
        onCreate(sqLiteDatabase);
        */
    }

    public ArrayList<Lesson> fetchAllLessons(String groupId) {
        this.open();
        String scheduleGroup = "schedule_" + groupId;
        Cursor c = db.rawQuery("SELECT*FROM " + scheduleGroup, null);
        ArrayList<Lesson> lessons = new ArrayList<Lesson>(c.getCount());

        while (c.moveToNext()) {
            Lesson lesson = new Lesson();
            setDataFromCursor(lesson, c);
            lessons.add(lesson);
        }

        this.close();
        return lessons;
    }

    public Lesson[] getLessonsOfDay(String groupID, DateTime dayOfYear, int subgroup) {
        String sWeekDay = "";
        int weekDay = dayOfYear.getDayOfWeek();
        int workWeek = StudentCalendar.getWorkWeek(dayOfYear);