// load categories of all tasks of the user
 @Override
 public TreeSet<Category> loadCategories(int userId) {
   TreeSet<Category> categoriesList =
       new TreeSet<
           Category>(); // use treeset to disallow duplicates and get alphabetical order of
                        // categories
   List<Task> tasksList = taskDao.loadTasksofUsers(userId);
   for (Task task : tasksList) {
     logger.debug("Processing categories of task - " + task.getTaskName());
     Category category = categoryDao.getCategoryofTask(task.getId());
     categoriesList.add(category);
   }
   logger.info("Loaded categories");
   return categoriesList;
 }
 // load tags of all tasks of the user
 @Override
 public TreeSet<Tag> loadTags(int userId) {
   TreeSet<Tag> tagsList =
       new TreeSet<Tag>(); // use treeset to disallow duplicates and get alphabetical order of tags
   List<Task> tasksList = taskDao.loadTasksofUsers(userId);
   for (Task task : tasksList) {
     logger.debug("Processing tags of task - " + task.getTaskName());
     List<Tag> tagsListofTask = new ArrayList<Tag>();
     tagsListofTask = tagDao.getTagsofTask(task.getId());
     for (Tag tag : tagsListofTask) {
       tagsList.add(tag);
     }
   }
   logger.info("Loaded tags");
   return tagsList;
 }
 @Override
 public int registerUser(User user) {
   int userId = userDao.addUser(user);
   // add default tasks
   Task defaultTask1 = new Task();
   Task defaultTask2 = new Task();
   defaultTask1.setTaskName("Buy groceries today");
   defaultTask2.setTaskName("Write code tomorrow");
   defaultTask1.setUserid(userId);
   defaultTask2.setUserid(userId);
   int taskId1 = taskDao.addTask(defaultTask1);
   int taskId2 = taskDao.addTask(defaultTask2);
   String defaulttask1Id = Integer.toString(taskId1);
   String defaulttask2Id = Integer.toString(taskId2);
   logger.info("Added default tasks");
   // add default tags
   Tag defaulttag1 = new Tag();
   Tag defaulttag2 = new Tag();
   Tag defaulttag3 = new Tag();
   Tag defaulttag4 = new Tag();
   defaulttag1.setTagName("office");
   defaulttag1.setTaskids(defaulttask2Id);
   defaulttag2.setTagName("home");
   defaulttag2.setTaskids(defaulttask1Id);
   defaulttag3.setTagName("vegetables");
   defaulttag3.setTaskids(defaulttask1Id);
   defaulttag4.setTagName("project");
   defaulttag4.setTaskids(defaulttask2Id);
   tagDao.addTag(defaulttag1);
   tagDao.addTag(defaulttag2);
   tagDao.addTag(defaulttag3);
   tagDao.addTag(defaulttag4);
   logger.info("Added default tags");
   // add default categories
   Category defaultCategory1 = new Category();
   Category defaultCategory2 = new Category();
   defaultCategory1.setCategoryName("work");
   defaultCategory1.setTaskids(defaulttask2Id);
   defaultCategory2.setCategoryName("personal");
   defaultCategory2.setTaskids(defaulttask1Id);
   categoryDao.addCategory(defaultCategory1);
   categoryDao.addCategory(defaultCategory2);
   logger.info("Added default categories");
   return userId;
 }
 @Override
 public List<Task> loadTasks(int userId) {
   List<Task> tasksList = taskDao.loadTasksofUsers(userId);
   return tasksList;
 }