// Path: NotificationAnalyser/app/src/main/java/com/tierep/notificationanalyser/NotificationAppView.java
// public class NotificationAppView {
//     public String AppName;
//     public Integer Notifications;
//     public Integer MaxNotifications;
// 
//     public NotificationAppView() {
//         this.AppName = "";
//         this.Notifications = 0;
//         this.MaxNotifications = 0;
//     }
// 
//     /**
//      *
//      * @param appName The name of the app.
//      * @param notifications The number of notifications from the app.
//      * @param maxNotifications The maximum number of notifications from any app.
//      */
//     public NotificationAppView(String appName, Integer notifications, Integer maxNotifications) {
//         this.AppName = appName;
//         this.Notifications = notifications;
//         this.MaxNotifications = maxNotifications;
//     }
// }
// 
// Path: NotificationAnalyser/app/src/main/java/com/tierep/notificationanalyser/NotificationDateView.java
// public class NotificationDateView {
//     public Date Date;
//     public Integer Notifications;
// 
//     public NotificationDateView() {
//         this.Date = null;
//         this.Notifications = 0;
//     }
// 
//     public NotificationDateView(Date date, Integer notifications) {
//         this.Date = date;
//         this.Notifications = notifications;
//     }
// }


import com.j256.ormlite.dao.BaseDaoImpl;
import com.j256.ormlite.dao.GenericRawResults;
import com.j256.ormlite.support.ConnectionSource;
import com.tierep.notificationanalyser.NotificationAppView;
import com.tierep.notificationanalyser.NotificationDateView;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
        String dateString = df.format(date);

        String rawQuery = "SELECT " + NotificationItem.FIELD_PACKAGE_NAME
                + ", COUNT(*) FROM " + NotificationItem.FIELD_TABLE_NAME
                + " WHERE strftime('%d-%m-%Y'," + NotificationItem.FIELD_DATE + ") = '" + dateString + "'"
                    + " AND " + NotificationItem.FIELD_PACKAGE_NAME + " IN "
                        + " (SELECT  " + Application.FIELD_PACKAGE_NAME
                        + " FROM " + Application.FIELD_TABLE_NAME
                        + " WHERE " + Application.FIELD_IGNORE + " = 0)"
                + " GROUP BY " + NotificationItem.FIELD_PACKAGE_NAME;

        return this.getOverviewGeneric(rawQuery);
    }

    @Override
    public List<NotificationAppView> getOverviewWeek(Date date) throws SQLException {
        Calendar cal = Calendar.getInstance();
        cal.setFirstDayOfWeek(Calendar.MONDAY);
        cal.setTime(date);
        cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
        Date firstDayOfWeek = cal.getTime();

        cal.add(Calendar.DATE, 6);
        Date lastDayOfWeek = cal.getTime();

        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String dateStringFirstDay = df.format(firstDayOfWeek);
        String dateStringLastDay = df.format(lastDayOfWeek);

        String rawQuery = "SELECT " + NotificationItem.FIELD_PACKAGE_NAME
// Path: NotificationAnalyser/app/src/main/java/com/tierep/notificationanalyser/NotificationAppView.java
// public class NotificationAppView {
//     public String AppName;
//     public Integer Notifications;
//     public Integer MaxNotifications;
// 
//     public NotificationAppView() {
//         this.AppName = "";
//         this.Notifications = 0;
//         this.MaxNotifications = 0;
//     }
// 
//     /**
//      *
//      * @param appName The name of the app.
//      * @param notifications The number of notifications from the app.
//      * @param maxNotifications The maximum number of notifications from any app.
//      */
//     public NotificationAppView(String appName, Integer notifications, Integer maxNotifications) {
//         this.AppName = appName;
//         this.Notifications = notifications;
//         this.MaxNotifications = maxNotifications;
//     }
// }
// 
// Path: NotificationAnalyser/app/src/main/java/com/tierep/notificationanalyser/NotificationDateView.java
// public class NotificationDateView {
//     public Date Date;
//     public Integer Notifications;
// 
//     public NotificationDateView() {
//         this.Date = null;
//         this.Notifications = 0;
//     }
// 
//     public NotificationDateView(Date date, Integer notifications) {
//         this.Date = date;
//         this.Notifications = notifications;
//     }
// }


// Path: NotificationAnalyser/app/src/main/java/com/tierep/notificationanalyser/models/NotificationItemDaoImpl.java
import com.j256.ormlite.dao.BaseDaoImpl;
import com.j256.ormlite.dao.GenericRawResults;
import com.j256.ormlite.support.ConnectionSource;
import com.tierep.notificationanalyser.NotificationAppView;
import com.tierep.notificationanalyser.NotificationDateView;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

        String dateString = df.format(date);

        String rawQuery = "SELECT " + NotificationItem.FIELD_PACKAGE_NAME
                + ", COUNT(*) FROM " + NotificationItem.FIELD_TABLE_NAME
                + " WHERE strftime('%d-%m-%Y'," + NotificationItem.FIELD_DATE + ") = '" + dateString + "'"
                    + " AND " + NotificationItem.FIELD_PACKAGE_NAME + " IN "
                        + " (SELECT  " + Application.FIELD_PACKAGE_NAME
                        + " FROM " + Application.FIELD_TABLE_NAME
                        + " WHERE " + Application.FIELD_IGNORE + " = 0)"
                + " GROUP BY " + NotificationItem.FIELD_PACKAGE_NAME;

        return this.getOverviewGeneric(rawQuery);
    }

    @Override
    public List<NotificationAppView> getOverviewWeek(Date date) throws SQLException {
        Calendar cal = Calendar.getInstance();
        cal.setFirstDayOfWeek(Calendar.MONDAY);
        cal.setTime(date);
        cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
        Date firstDayOfWeek = cal.getTime();

        cal.add(Calendar.DATE, 6);
        Date lastDayOfWeek = cal.getTime();

        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String dateStringFirstDay = df.format(firstDayOfWeek);
        String dateStringLastDay = df.format(lastDayOfWeek);

        String rawQuery = "SELECT " + NotificationItem.FIELD_PACKAGE_NAME
                + ", COUNT(*) FROM " + NotificationItem.FIELD_TABLE_NAME