|
| 1 | +/* |
| 2 | + * The MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2015, Mahmoud Ben Hassine ([email protected]) |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in |
| 14 | + * all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | + * THE SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +package io.github.benas.todolist.web.action.user; |
| 26 | + |
| 27 | +import java.io.File; |
| 28 | +import java.util.List; |
| 29 | + |
| 30 | +import com.opensymphony.xwork2.Action; |
| 31 | + |
| 32 | +import io.github.benas.todolist.web.action.BaseAction; |
| 33 | +import io.github.benas.todolist.web.common.util.TodoListUtils; |
| 34 | +import io.github.todolist.core.domain.Todo; |
| 35 | +import io.github.todolist.core.domain.User; |
| 36 | + |
| 37 | +/** |
| 38 | + * Action class to load user's todo list in home page. |
| 39 | + * <p/> |
| 40 | + |
| 41 | + */ |
| 42 | +public class FilesAction extends BaseAction { |
| 43 | + |
| 44 | + private List<Todo> todoList; |
| 45 | + |
| 46 | + private int totalCount; |
| 47 | + |
| 48 | + private int doneCount; |
| 49 | + |
| 50 | + private int todoCount; |
| 51 | + |
| 52 | + public String execute() { |
| 53 | + User user = getSessionUser(); |
| 54 | + todoList = todoService.getTodoListByUser(user.getId()); |
| 55 | + totalCount = todoList.size(); |
| 56 | + doneCount = TodoListUtils.countTotalDone(todoList); |
| 57 | + todoCount = totalCount - doneCount; |
| 58 | + return Action.SUCCESS; |
| 59 | + } |
| 60 | + |
| 61 | + /* |
| 62 | + * Getters for model attributes |
| 63 | + */ |
| 64 | + |
| 65 | + public List<Todo> getTodoList() { |
| 66 | + return todoList; |
| 67 | + } |
| 68 | + |
| 69 | + public String getHomeTabStyle() { |
| 70 | + return "active"; |
| 71 | + } |
| 72 | + |
| 73 | + public int getTotalCount() { |
| 74 | + return totalCount; |
| 75 | + } |
| 76 | + |
| 77 | + public int getDoneCount() { |
| 78 | + return doneCount; |
| 79 | + } |
| 80 | + |
| 81 | + public int getTodoCount() { |
| 82 | + return todoCount; |
| 83 | + } |
| 84 | + |
| 85 | +} |
0 commit comments