@@ -7,7 +7,7 @@ import java.io.UnsupportedEncodingException;
7
7
import javax.servlet.http.HttpServletRequest ;
8
8
import javax.validation.Valid ;
9
9
import org.rooinaction.taskmanager.model.Task ;
10
- import org.rooinaction.taskmanager.repository.TaskRepository ;
10
+ import org.rooinaction.taskmanager.service.TaskService ;
11
11
import org.rooinaction.taskmanager.web.TaskController ;
12
12
import org.springframework.beans.factory.annotation.Autowired ;
13
13
import org.springframework.ui.Model ;
@@ -22,7 +22,7 @@ import org.springframework.web.util.WebUtils;
22
22
privileged aspect TaskController_Roo_Controller {
23
23
24
24
@Autowired
25
- TaskRepository TaskController . taskRepository ;
25
+ TaskService TaskController . taskService ;
26
26
27
27
@RequestMapping (method = RequestMethod . POST , produces = " text/html" )
28
28
public String TaskController.create (@Valid Task task , BindingResult bindingResult , Model uiModel , HttpServletRequest httpServletRequest ) {
@@ -31,7 +31,7 @@ privileged aspect TaskController_Roo_Controller {
31
31
return " tasks/create" ;
32
32
}
33
33
uiModel. asMap(). clear();
34
- taskRepository . save (task);
34
+ taskService . saveTask (task);
35
35
return " redirect:/tasks/" + encodeUrlPathSegment(task. getId(). toString(), httpServletRequest);
36
36
}
37
37
@@ -43,7 +43,7 @@ privileged aspect TaskController_Roo_Controller {
43
43
44
44
@RequestMapping (value = " /{id}" , produces = " text/html" )
45
45
public String TaskController.show (@PathVariable ("id ") Long id, Model uiModel) {
46
- uiModel. addAttribute(" task" , taskRepository . findOne (id));
46
+ uiModel. addAttribute(" task" , taskService . findTask (id));
47
47
uiModel. addAttribute(" itemId" , id);
48
48
return " tasks/show" ;
49
49
}
@@ -53,11 +53,11 @@ privileged aspect TaskController_Roo_Controller {
53
53
if (page != null || size != null ) {
54
54
int sizeNo = size == null ? 10 : size. intValue();
55
55
final int firstResult = page == null ? 0 : (page. intValue() - 1 ) * sizeNo;
56
- uiModel. addAttribute(" tasks" , taskRepository . findAll( new org.springframework.data.domain . PageRequest ( firstResult / sizeNo , sizeNo)) . getContent( ));
57
- float nrOfPages = (float ) taskRepository . count () / sizeNo;
56
+ uiModel. addAttribute(" tasks" , taskService . findTaskEntries( firstResult, sizeNo));
57
+ float nrOfPages = (float ) taskService . countAllTasks () / sizeNo;
58
58
uiModel. addAttribute(" maxPages" , (int ) ((nrOfPages > (int ) nrOfPages || nrOfPages == 0.0 ) ? nrOfPages + 1 : nrOfPages));
59
59
} else {
60
- uiModel. addAttribute(" tasks" , taskRepository . findAll ());
60
+ uiModel. addAttribute(" tasks" , taskService . findAllTasks ());
61
61
}
62
62
return " tasks/list" ;
63
63
}
@@ -69,20 +69,20 @@ privileged aspect TaskController_Roo_Controller {
69
69
return " tasks/update" ;
70
70
}
71
71
uiModel. asMap(). clear();
72
- taskRepository . save (task);
72
+ taskService . updateTask (task);
73
73
return " redirect:/tasks/" + encodeUrlPathSegment(task. getId(). toString(), httpServletRequest);
74
74
}
75
75
76
76
@RequestMapping (value = " /{id}" , params = " form" , produces = " text/html" )
77
77
public String TaskController.updateForm (@PathVariable ("id ") Long id, Model uiModel) {
78
- populateEditForm(uiModel, taskRepository . findOne (id));
78
+ populateEditForm(uiModel, taskService . findTask (id));
79
79
return " tasks/update" ;
80
80
}
81
81
82
82
@RequestMapping (value = " /{id}" , method = RequestMethod . DELETE , produces = " text/html" )
83
83
public String TaskController.delete (@PathVariable ("id ") Long id, @RequestParam (value = "page ", required = false ) Integer page, @RequestParam (value = "size ", required = false ) Integer size, Model uiModel) {
84
- Task task = taskRepository . findOne (id);
85
- taskRepository . delete (task);
84
+ Task task = taskService . findTask (id);
85
+ taskService . deleteTask (task);
86
86
uiModel. asMap(). clear();
87
87
uiModel. addAttribute(" page" , (page == null ) ? " 1" : page. toString());
88
88
uiModel. addAttribute(" size" , (size == null ) ? " 10" : size. toString());
0 commit comments