// 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;
        Date firstDayOfMonth = cal.getTime();

        cal.add(Calendar.MONTH, 1);
        Date lastDayOfMonth = cal.getTime();

        return this.queryBuilder().where()
                .eq(NotificationItem.FIELD_PACKAGE_NAME, appName).and()
                .ge(NotificationItem.FIELD_DATE, firstDayOfMonth).and()
                .le(NotificationItem.FIELD_DATE, lastDayOfMonth).query();
    }


    private List<NotificationAppView> getOverviewGeneric(String rawQuery) throws SQLException {
        List<NotificationAppView> list = new LinkedList<NotificationAppView>();
        int maxCount = 0;

        GenericRawResults<String[]> rawResults = this.queryRaw(rawQuery);
        List<String[]> results = rawResults.getResults();

        for (String[] result : results) {
            int ntfCount = Integer.parseInt(result[1]);
            maxCount = ntfCount > maxCount ? ntfCount : maxCount;
        }
        for (String[] result : results) {
            list.add(new NotificationAppView(result[0], Integer.parseInt(result[1]), maxCount));
        }
        return list;
    }

    @Override
// 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;

        Date firstDayOfMonth = cal.getTime();

        cal.add(Calendar.MONTH, 1);
        Date lastDayOfMonth = cal.getTime();

        return this.queryBuilder().where()
                .eq(NotificationItem.FIELD_PACKAGE_NAME, appName).and()
                .ge(NotificationItem.FIELD_DATE, firstDayOfMonth).and()
                .le(NotificationItem.FIELD_DATE, lastDayOfMonth).query();
    }


    private List<NotificationAppView> getOverviewGeneric(String rawQuery) throws SQLException {
        List<NotificationAppView> list = new LinkedList<NotificationAppView>();
        int maxCount = 0;

        GenericRawResults<String[]> rawResults = this.queryRaw(rawQuery);
        List<String[]> results = rawResults.getResults();

        for (String[] result : results) {
            int ntfCount = Integer.parseInt(result[1]);
            maxCount = ntfCount > maxCount ? ntfCount : maxCount;
        }
        for (String[] result : results) {
            list.add(new NotificationAppView(result[0], Integer.parseInt(result[1]), maxCount));
        }
        return list;
    }

    @Override
    public List<NotificationDateView> getSummaryLastDays(int days) throws SQLException {