package com.github.neunkasulle.chronocommand.control;

import com.github.neunkasulle.chronocommand.model.Category;
import com.github.neunkasulle.chronocommand.model.CategoryDAO;
import com.github.neunkasulle.chronocommand.model.DAOHelper;
import org.hibernate.cfg.NotYetImplementedException;


/**
 * Created by Janze on 18.01.2016.
 * Controling startup and shutdown
 */
public class MainControl extends Control {


    private static MainControl ourInstance = new MainControl();

    private MainControl() {
        realm = new com.github.neunkasulle.chronocommand.security.Realm();
    }

    public static MainControl getInstance() {
        return ourInstance;
    }



    private void exceptionHandling() {
        throw new NotYetImplementedException();
    }

    public void startup() {
        DAOHelper.getInstance().startup();

        CategoryDAO.getInstance().saveCategory(new Category("Programming"));
        CategoryDAO.getInstance().saveCategory(new Category("Procrastination"));

        // TODO initiate anything that needs initiating
    }

    public void shutdown() {
        DAOHelper.getInstance().shutdown();

        // TODO initiate anything that needs initiating
    }
}

@@ -232,16 +232,131 @@
 Helper;%0A
+import com.github.neunkasulle.chronocommand.model.UserDAO;%0Aimport com.github.neunkasulle.chronocommand.model.User;%0A
 import o
@@ -400,16 +400,16 @@
 eption;%0A
-
 %0A%0A/**%0A *
@@ -945,24 +945,122 @@
 startup();%0A%0A
+        // TODO initiate anything that needs initiating%0A%0A        // DEBUG fill database with data%0A
         Cate
@@ -1218,55 +1218,408 @@
     
-// TODO initiate anything that needs initiating
+User tom = new User();%0A        tom.setEmail(%22tom@chronocommand.eu%22);%0A        tom.setPassword(%22cat%22);%0A        tom.setUsername(%22tom%22);%0A        UserDAO.getInstance().saveUser(tom);%0A%0A        User matt = new User();%0A        matt.setEmail(%22matt@example.com%22);%0A        matt.setPassword(%22matt%22);%0A        matt.setUsername(%22matt%22);%0A        matt.setSupervisor(tom);%0A        UserDAO.getInstance().saveUser(matt);
 %0A   

Create users on startup for testing purposes