diff --git a/etc/TODO.md b/etc/TODO.md
index d161abce..3384ab8d 100644
--- a/etc/TODO.md
+++ b/etc/TODO.md
@@ -88,8 +88,6 @@ https://www.baeldung.com/maven-enforcer-plugin
# 2.3.14
Fixed #122, Fixed #123, Fixed #127, Fixed #130, Fixed #152, Fixed #153, Fixed #154, Fixed #155, Fixed #156, Fixed #157, Fixed #158, Fixed #159, Fixed #160, Fixed #161, Fixed #162, Fixed #163, Fixed #164, Fixed #165, Fixed #166, Fixed #167
-
-
https://developer.okta.com/blog/2019/03/28/test-java-spring-boot-junit5
# 2.3.15
@@ -99,10 +97,16 @@ https://github.com/thymeleaf/thymeleaf-testing
# 2.3.16
Fixed #169, Fixed #170, Fixed #171, Fixed #172, Fixed #183
-
# 2.3.17
Fixed #223, Fixed #224, Fixed #225, Fixed #226, Fixed #227, Fixed #228, Fixed #229, Fixed #230, Fixed #231, Fixed #232, Fixed #233
-
Fixed #201, Fixed #202, Fixed #203, Fixed #204, Fixed #205, Fixed #206, Fixed #207, Fixed #208, Fixed #209, Fixed #210, Fixed #211, Fixed #212, Fixed #213, Fixed #214, Fixed #215, Fixed #216, Fixed #217, Fixed #218, Fixed #219
-
Fixed #220, Fixed #221, Fixed #222
+
+#2.3.18
+Fixed #128, Fixed #192, Fixed #193, Fixed #194, Fixed #195, Fixed #196, Fixed #197, Fixed #198, Fixed #199, Fixed #200, Fixed #239, Fixed #240
+
+#2.3.19
+Fixed #241, Fixed #242, Fixed #243, Fixed #252
+
+#2.3.20
+
diff --git a/etc/requirements/Requirements.md b/etc/requirements/Requirements.md
index 280b5421..8cc5f91b 100644
--- a/etc/requirements/Requirements.md
+++ b/etc/requirements/Requirements.md
@@ -17,51 +17,58 @@
## F017 show /taskstate/completed
## F018 show /taskstate/trash
-## F020 Task move to /taskstate/inbox
-## F021 Task move to /taskstate/today
-## F022 Task move to /taskstate/next
-## F023 Task move to /taskstate/waiting
-## F024 Task move to /taskstate/scheduled
-## F025 Task move to /taskstate/someday
-## F026 Task move to /taskstate/focus
-## F027 Task move to /taskstate/completed
-## F028 Task move to /taskstate/trash
+## F020 Drag and Drop: Task move to /taskstate/inbox
+## F021 Drag and Drop: Task move to /taskstate/today
+## F022 Drag and Drop: Task move to /taskstate/next
+## F023 Drag and Drop: Task move to /taskstate/waiting
+## F024 Drag and Drop: Task move to /taskstate/scheduled
+## F025 Drag and Drop: Task move to /taskstate/someday
+## F026 Drag and Drop: Task move to /taskstate/focus
+## F027 Drag and Drop: Task move to /taskstate/completed
+## F028 Drag and Drop: Task move to /taskstate/trash
-## F030 Taskstate: Add Task to Inbox
-## F031 Taskstate: Add Task to Inbox again
-## F032 Taskstate: Task Edit
-## F033 Taskstate: Task Edit Form -> change Taskstate via DropDown
-## F054 Taskstate: Task Edit Form -> change Project via DropDown
-## F035 Taskstate: Task Edit Form -> transform to Project
-## F036 Taskstate: Task setFocus
-## F037 Taskstate: Task unSetFocus
-## F038 Taskstate: Task complete
-## F039 Taskstate: Task incomplete
-## F040 Taskstate: Task delete
-## F041 Taskstate: Task undelete
+## F029 Drag and Drop: Task move to Project
+## F030 Drag and Drop: Project move to Project
-## F050 Project/Root: Add Task
-## F051 Project/Root: Add SubProject
-## F052 Project/Root: Task Edit
-## F053 Project/Root: Task Edit Form -> change Taskstate via DropDown
-## F054 Project/Root: Task Edit Form -> change Project via DropDown
-## F055 Project/Root: Task Edit Form -> transform to Project
-## F056 Project/Root: Task setFocus
-## F057 Project/Root: Task unSetFocus
-## F058 Project/Root: Task complete
-## F059 Project/Root: Task incomplete
-## F060 Project/Root: Task delete
-## F061 Project/Root: Task undelete
+## F031 Drag and Drop: Move Task to Change Task-Order in Taskstate
+## F032 Drag and Drop: Move Task to Change Task-Order in Project/Root
+## F033 Drag and Drop: Move Task to Change Task-Order in Project/id
-## F070 Project/id: Add Task
-## F071 Project/id: Add SubProject
-## F072 Project/id: Task Edit
-## F073 Project/id: Task Edit Form -> change Taskstate via DropDown
-## F074 Project/id: Task Edit Form -> change Project via DropDown
-## F075 Project/id: Task Edit Form -> transform to Project
-## F076 Project/id: Task setFocus
-## F077 Project/id: Task unSetFocus
-## F078 Project/id: Task complete
-## F079 Project/id: Task incomplete
-## F080 Project/id: Task delete
-## F081 Project/id: Task undelete
+## F040 Taskstate: Add Task to Inbox
+## F041 Taskstate: Add Task to Inbox again
+## F042 Taskstate: Task Edit
+## F043 Taskstate: Task Edit Form -> change Taskstate via DropDown
+## F044 Taskstate: Task Edit Form -> change Project via DropDown
+## F045 Taskstate: Task Edit Form -> transform to Project
+## F046 Taskstate: Task setFocus
+## F047 Taskstate: Task unSetFocus
+## F048 Taskstate: Task complete
+## F049 Taskstate: Task incomplete
+## F050 Taskstate: Task delete
+## F051 Taskstate: Task undelete
+
+## F060 Project/Root: Add Task
+## F061 Project/Root: Add SubProject
+## F062 Project/Root: Task Edit
+## F063 Project/Root: Task Edit Form -> change Taskstate via DropDown
+## F064 Project/Root: Task Edit Form -> change Project via DropDown
+## F065 Project/Root: Task Edit Form -> transform to Project
+## F066 Project/Root: Task setFocus
+## F067 Project/Root: Task unSetFocus
+## F068 Project/Root: Task complete
+## F069 Project/Root: Task incomplete
+## F070 Project/Root: Task delete
+## F071 Project/Root: Task undelete
+
+## F080 Project/id: Add Task
+## F081 Project/id: Add SubProject
+## F082 Project/id: Task Edit
+## F083 Project/id: Task Edit Form -> change Taskstate via DropDown
+## F084 Project/id: Task Edit Form -> change Project via DropDown
+## F085 Project/id: Task Edit Form -> transform to Project
+## F086 Project/id: Task setFocus
+## F087 Project/id: Task unSetFocus
+## F088 Project/id: Task complete
+## F089 Project/id: Task incomplete
+## F090 Project/id: Task delete
+## F091 Project/id: Task undelete
diff --git a/pom.xml b/pom.xml
index f021115b..ca82c615 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.woehlke
simpleworklist
- 2.3.18-SNAPSHOT
+ 2.3.20-SNAPSHOT
jar
org.springframework.boot
diff --git a/src/main/java/org/woehlke/simpleworklist/application/common/AbstractController.java b/src/main/java/org/woehlke/simpleworklist/application/common/AbstractController.java
index d92da238..8a94f239 100644
--- a/src/main/java/org/woehlke/simpleworklist/application/common/AbstractController.java
+++ b/src/main/java/org/woehlke/simpleworklist/application/common/AbstractController.java
@@ -147,9 +147,9 @@ protected Context getContext(UserSessionBean userSession){
UserAccount thisUser = this.getUser();
if(userSession == null){
userSession = new UserSessionBean();
- long defaultContextId = thisUser.getDefaultContext().getId();
- userSession.setLastContextId(defaultContextId);
}
+ long defaultContextId = thisUser.getDefaultContext().getId();
+ userSession.setLastContextId(defaultContextId);
Context context = contextService.findByIdAndUserAccount(userSession.getLastContextId(), thisUser);
userSession.setLastContextId(context.getId());
userSession.setUserAccountid(thisUser.getId());
diff --git a/src/main/java/org/woehlke/simpleworklist/application/testdata/TestDataServiceImpl.java b/src/main/java/org/woehlke/simpleworklist/application/testdata/TestDataServiceImpl.java
index 5bb9ec35..01d1c06f 100644
--- a/src/main/java/org/woehlke/simpleworklist/application/testdata/TestDataServiceImpl.java
+++ b/src/main/java/org/woehlke/simpleworklist/application/testdata/TestDataServiceImpl.java
@@ -38,12 +38,14 @@ public TestDataServiceImpl(ProjectRepository projectRepository, TaskRepository t
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public void createTestCategoryTreeForUserAccount(UserAccount userAccount) {
- List contexts = contextRepository.findByUserAccount(userAccount);
- Iterator iterator = contexts.iterator();
- Context contextWork = iterator.next();
log.info("----------------------------------------------");
log.info("createTestCategoryTreeForUserAccount");
log.info("----------------------------------------------");
+ log.info("userAccount: "+userAccount.toString());
+ log.info("----------------------------------------------");
+ Context contextWork = userAccount.getDefaultContext();
+ log.info("contextWork: "+contextWork.toString());
+ log.info("----------------------------------------------");
Date nowDate = new Date();
long now = nowDate.getTime();
String name01 = "test01_" + now;
diff --git a/src/main/java/org/woehlke/simpleworklist/context/Context.java b/src/main/java/org/woehlke/simpleworklist/context/Context.java
index a2921a90..fe03ad16 100644
--- a/src/main/java/org/woehlke/simpleworklist/context/Context.java
+++ b/src/main/java/org/woehlke/simpleworklist/context/Context.java
@@ -35,7 +35,7 @@
@Getter
@Setter
@NoArgsConstructor
-@EqualsAndHashCode(callSuper = true)
+@EqualsAndHashCode(callSuper = true, exclude = "userAccount")
@ToString(callSuper = true, exclude = "userAccount")
public class Context extends AuditModel implements Serializable, ComparableById {
diff --git a/src/main/java/org/woehlke/simpleworklist/context/ContextRepository.java b/src/main/java/org/woehlke/simpleworklist/context/ContextRepository.java
index 6d5f0b7e..f06cd736 100644
--- a/src/main/java/org/woehlke/simpleworklist/context/ContextRepository.java
+++ b/src/main/java/org/woehlke/simpleworklist/context/ContextRepository.java
@@ -1,8 +1,9 @@
package org.woehlke.simpleworklist.context;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
-import org.woehlke.simpleworklist.context.Context;
import org.woehlke.simpleworklist.user.account.UserAccount;
import java.util.List;
@@ -13,7 +14,10 @@
@Repository
public interface ContextRepository extends JpaRepository {
+ //TODO: #251 change List to Page
+ @Deprecated
List findByUserAccount(UserAccount user);
+ Page findByUserAccount(UserAccount user, Pageable pageRequest);
Context findByIdAndUserAccount(long newContextId, UserAccount userAccount);
diff --git a/src/main/java/org/woehlke/simpleworklist/context/ContextService.java b/src/main/java/org/woehlke/simpleworklist/context/ContextService.java
index def131bb..4d207d7b 100644
--- a/src/main/java/org/woehlke/simpleworklist/context/ContextService.java
+++ b/src/main/java/org/woehlke/simpleworklist/context/ContextService.java
@@ -9,12 +9,16 @@
*/
public interface ContextService {
+ //TODO: #251 change List to Page
+ //TODO: rename to findByUser
List getAllForUser(UserAccount user);
Context findByIdAndUserAccount(long newContextId, UserAccount userAccount);
+ //TODO: rename to add
Context createNewContext(NewContextForm newContext, UserAccount user);
+ //TODO: rename to update
Context updateContext(Context context);
boolean delete(Context context);
diff --git a/src/main/java/org/woehlke/simpleworklist/project/Project.java b/src/main/java/org/woehlke/simpleworklist/project/Project.java
index f690c2b5..05204169 100644
--- a/src/main/java/org/woehlke/simpleworklist/project/Project.java
+++ b/src/main/java/org/woehlke/simpleworklist/project/Project.java
@@ -36,8 +36,8 @@
)
@Getter
@Setter
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true, exclude = "children")
+@EqualsAndHashCode(callSuper = true, exclude = {"children","parent"})
+@ToString(callSuper = true, exclude = {"children","parent","description"})
public class Project extends AuditModel implements Serializable, ComparableById {
private static final long serialVersionUID = 4566653175832872422L;
@@ -167,5 +167,9 @@ public Project addOtherProjectToChildren(Project project) {
project.setParent(this);
return project;
}
+
+ public String out(){
+ return "Project: "+name+" ("+id+")";
+ }
}
diff --git a/src/main/java/org/woehlke/simpleworklist/project/ProjectController.java b/src/main/java/org/woehlke/simpleworklist/project/ProjectController.java
index b8ec6e47..8f391259 100644
--- a/src/main/java/org/woehlke/simpleworklist/project/ProjectController.java
+++ b/src/main/java/org/woehlke/simpleworklist/project/ProjectController.java
@@ -35,13 +35,17 @@ public class ProjectController extends AbstractController {
private final ProjectControllerService projectControllerService;
private final TaskService taskService;
- private final TaskStateControllerService taskStateControllerService;
+ private final TaskProjektService taskProjektService;
@Autowired
- public ProjectController(ProjectControllerService projectControllerService, TaskService taskService, TaskStateControllerService taskStateControllerService) {
+ public ProjectController(
+ ProjectControllerService projectControllerService,
+ TaskService taskService,
+ TaskProjektService taskProjektService
+ ) {
this.projectControllerService = projectControllerService;
this.taskService = taskService;
- this.taskStateControllerService = taskStateControllerService;
+ this.taskProjektService = taskProjektService;
}
@RequestMapping(path = "/task/add", method = RequestMethod.GET)
@@ -71,6 +75,7 @@ public final String projectTaskAddGet(
model.addAttribute("thisProject", thisProject);
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("task", task);
+ model.addAttribute("userSession", userSession);
return "project/id/task/add";
}
@@ -79,7 +84,9 @@ public final String projectTaskAddPost(
@PathVariable long projectId,
@ModelAttribute("userSession") UserSessionBean userSession,
@Valid Task task,
- BindingResult result, Locale locale, Model model) {
+ BindingResult result,
+ Locale locale, Model model
+ ) {
Context context = super.getContext(userSession);
UserAccount userAccount = context.getUserAccount();
if (result.hasErrors()) {
@@ -95,6 +102,7 @@ public final String projectTaskAddPost(
model.addAttribute("thisProject", thisProject);
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("task", task);
+ model.addAttribute("userSession", userSession);
return "project/id/task/add";
} else {
Project thisProject = projectService.findByProjectId(projectId);
@@ -113,6 +121,7 @@ public final String projectTaskAddPost(
task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskService.addToProject(task);
log.info(task.toString());
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
}
@@ -124,7 +133,8 @@ public final String project(
@RequestParam(required = false) String message,
@RequestParam(required = false) boolean isDeleted,
@ModelAttribute("userSession") UserSessionBean userSession,
- Locale locale, Model model) {
+ Locale locale, Model model
+ ) {
log.info("/project/"+projectId);
Context context = super.getContext(userSession);
userSession.setLastProjectId(projectId);
@@ -149,6 +159,7 @@ public final String project(
model.addAttribute("message",message);
model.addAttribute("isDeleted",isDeleted);
}
+ model.addAttribute("userSession", userSession);
return "project/id/show";
}
@@ -161,6 +172,7 @@ public final String projectAddProjectGet(
log.info("private addNewProjectGet (GET) projectId="+projectId);
Context context = super.getContext(userSession);
projectControllerService.addNewProjectToProjectIdForm(projectId, userSession, context, locale, model);
+ model.addAttribute("userSession", userSession);
return "project/id/project/add";
}
@@ -170,7 +182,8 @@ public final String projectAddProjectPost(
@ModelAttribute("userSession") UserSessionBean userSession,
@Valid Project project,
BindingResult result,
- Locale locale, Model model) {
+ Locale locale, Model model
+ ) {
log.info("private addNewProjectPost (POST) projectId="+projectId+" "+project.toString());
Context context = super.getContext(userSession);
return projectControllerService.addNewProjectToProjectIdPersist(
@@ -184,19 +197,18 @@ public final String projectAddProjectPost(
);
}
-
- @RequestMapping(path = "/project/move/{targetProjectId}", method = RequestMethod.GET)
+ @RequestMapping(path = "/project/move/to/project/{targetProjectId}", method = RequestMethod.GET)
public final String projectMoveToProjectGet(
@PathVariable("projectId") Project thisProject,
@PathVariable long targetProjectId,
@ModelAttribute("userSession") UserSessionBean userSession,
- Locale locale, Model model
+ Model model
) {
- Context context = super.getContext(userSession);
userSession.setLastProjectId(thisProject.getId());
model.addAttribute("userSession",userSession);
Project targetProject = projectService.findByProjectId(targetProjectId);
thisProject = projectService.moveProjectToAnotherProject(thisProject, targetProject );
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -216,6 +228,7 @@ public final String projectEditGet(
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("thisProject", thisProject);
model.addAttribute("project", thisProject);
+ model.addAttribute("userSession", userSession);
return "project/id/edit";
}
@@ -229,7 +242,6 @@ public final String projectEditPost(
) {
Context context = super.getContext(userSession);
UserAccount thisUser = context.getUserAccount();
- model.addAttribute("userSession", userSession);
Project thisProject;
if (result.hasErrors()) {
for (ObjectError e : result.getAllErrors()) {
@@ -238,6 +250,7 @@ public final String projectEditPost(
thisProject = projectService.findByProjectId(projectId);
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForShowOneProject(thisProject,locale);
model.addAttribute("breadcrumb", breadcrumb);
+ model.addAttribute("userSession", userSession);
return "project/id/edit";
} else {
thisProject = projectService.findByProjectId(project.getId());
@@ -267,19 +280,20 @@ public final String projectDeleteGet(
Locale locale,
Model model
) {
- //Context context = super.getContext(userSession);
userSession.setLastProjectId(project.getId());
- //model.addAttribute("userSession", userSession);//TODO: really?
+ model.addAttribute("userSession", userSession);
boolean hasNoData = taskService.projectHasNoTasks(project);
boolean hasNoChildren = project.hasNoChildren();
boolean delete = hasNoData && hasNoChildren;
if (delete) {
Project parent = projectService.delete(project);
- String message = "Project is deleted. You see its parent project now."; //TODO: message to message_properties
+ //TODO: message to message_properties
+ String message = "Project is deleted. You see its parent project now.";
//TODO: message to UserSessionBean userSession
model.addAttribute("message", message );
//TODO: isDeleted as message to UserSessionBean userSession
model.addAttribute("isDeleted",true);
+ model.addAttribute("userSession", userSession);
if(parent == null){
return "redirect:/project/root";
} else {
@@ -306,12 +320,13 @@ public final String projectDeleteGet(
model.addAttribute("taskPage", taskPage);
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("thisProject", project);
+ model.addAttribute("userSession", userSession);
return "project/id/show";
}
}
@RequestMapping(path = "/task/{taskId}/changeorderto/{destinationTaskId}", method = RequestMethod.GET)
- public String projectTaskChangeOrderToTaskGet(
+ public String moveTaskToTaskAndChangeTaskOrderInProject(
@PathVariable("projectId") Project thisProject,
@PathVariable("taskId") Task sourceTask,
@PathVariable("destinationTaskId") Task destinationTask,
@@ -327,31 +342,36 @@ public String projectTaskChangeOrderToTaskGet(
log.info("-------------------------------------------------");
log.info(" destination Task: "+destinationTask.toString());
log.info("-------------------------------------------------");
- taskService.moveOrderIdProject(sourceTask, destinationTask);
+ projectControllerService.moveTaskToTaskAndChangeTaskOrderInProject(sourceTask, destinationTask);
log.info(" DONE: taskMoveService.moveOrderIdProject");
log.info("-------------------------------------------------");
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@RequestMapping(path = "/task/completed/move/to/trash", method = RequestMethod.GET)
public final String moveAllCompletedToTrash(
@PathVariable("projectId") Project thisProject,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
userSession.setLastProjectId(thisProject.getId());
Context context = super.getContext(userSession);
taskService.moveAllCompletedToTrash(context);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@RequestMapping(path = "/task/trash/empty", method = RequestMethod.GET)
public final String emptyTrash(
@PathVariable("projectId") Project thisProject,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
userSession.setLastProjectId(thisProject.getId());
Context context = super.getContext(userSession);
taskService.emptyTrash(context);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -373,6 +393,7 @@ public final String editTaskGet(
model.addAttribute("thisContext", thisContext);
model.addAttribute("task", task);
model.addAttribute("contexts", contexts);
+ model.addAttribute("userSession", userSession);
return "project/id/task/edit";
}
@@ -418,6 +439,7 @@ public final String editTaskPost(
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
userSession.setLastContextId(thisContext.getId());
+ model.addAttribute("userSession", userSession);
return "project/id/task/edit";
} else {
task.setProject(thisProject);
@@ -427,6 +449,7 @@ public final String editTaskPost(
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
}
@@ -435,13 +458,15 @@ public final String editTaskPost(
public final String setDoneTaskGet(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
userSession.setLastProjectId(thisProject.getId());
task.complete();
long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(TaskState.COMPLETED,task.getContext());
task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -449,13 +474,15 @@ public final String setDoneTaskGet(
public final String unsetDoneTaskGet(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
userSession.setLastProjectId(thisProject.getId());
task.incomplete();
long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState( task.getTaskState(), task.getContext());
task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -464,10 +491,12 @@ public final String setFocusGet(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
@PathVariable("taskId") Task task,
- @RequestParam(required=false) String back
+ @RequestParam(required=false) String back,
+ Model model
){
task.setFocus();
task = taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -476,10 +505,12 @@ public final String unsetFocusGet(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
@PathVariable("taskId") Task task,
- @RequestParam(required=false) String back
+ @RequestParam(required=false) String back,
+ Model model
){
task.unsetFocus();
task = taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -487,9 +518,11 @@ public final String unsetFocusGet(
public final String moveTaskToAnotherProject(
@PathVariable("projectId") Project thisProject,
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task = taskService.moveTaskToRootProject(task);
+ model.addAttribute("userSession", userSession);
return "redirect:/project/root";
}
@@ -498,9 +531,11 @@ public final String moveTaskToAnotherProject(
@PathVariable("projectId") Project thisProject,
@PathVariable("taskId") Task task,
@PathVariable("otherProjectId") Project otherProject,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task = taskService.moveTaskToAnotherProject(task,otherProject);
+ model.addAttribute("userSession", userSession);
return otherProject.getUrl();
}
@@ -508,11 +543,13 @@ public final String moveTaskToAnotherProject(
public final String moveTaskToInbox(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to inbox");
task.moveToInbox();
taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -520,11 +557,13 @@ public final String moveTaskToInbox(
public final String moveTaskToToday(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to today");
task.moveToToday();
taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -532,11 +571,13 @@ public final String moveTaskToToday(
public final String moveTaskToNext(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to next");
task.moveToNext();
taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -544,11 +585,13 @@ public final String moveTaskToNext(
public final String moveTaskToWaiting(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to waiting");
task.moveToWaiting();
taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -556,11 +599,13 @@ public final String moveTaskToWaiting(
public final String moveTaskToSomeday(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to someday");
task.moveToSomeday();
taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -568,11 +613,13 @@ public final String moveTaskToSomeday(
public final String moveTaskToFocus(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to focus");
task.moveToFocus();
taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -580,11 +627,13 @@ public final String moveTaskToFocus(
public final String moveTaskToCompleted(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to completed");
task.moveToCompletedTasks();
taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -592,7 +641,8 @@ public final String moveTaskToCompleted(
public final String moveTaskToTrash(
@PathVariable("projectId") Project thisProject,
@ModelAttribute("userSession") UserSessionBean userSession,
- @PathVariable("taskId") Task task
+ @PathVariable("taskId") Task task,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to trash");
task.moveToTrash();
@@ -600,6 +650,7 @@ public final String moveTaskToTrash(
userSession.setLastProjectId(thisProject.getId());
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
@@ -607,12 +658,13 @@ public final String moveTaskToTrash(
public final String transformTaskIntoProjectGet(
@PathVariable("projectId") Project thisProject,
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("transformTaskIntoProjectGet");
userSession.setLastProjectId(thisProject.getId());
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
- return taskStateControllerService.transformTaskIntoProjectGet(task);
+ return taskProjektService.transformTaskIntoProjectGet(task, userSession, model);
}
}
diff --git a/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerRoot.java b/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerRoot.java
index b1c1b42a..f9e10529 100644
--- a/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerRoot.java
+++ b/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerRoot.java
@@ -35,13 +35,13 @@ public class ProjectControllerRoot extends AbstractController {
private final ProjectControllerService projectControllerService;
private final TaskService taskService;
- private final TaskStateControllerService taskStateControllerService;
+ private final TaskProjektService taskProjektService;
@Autowired
- public ProjectControllerRoot(ProjectControllerService projectControllerService, TaskService taskService, TaskStateControllerService taskStateControllerService) {
+ public ProjectControllerRoot(ProjectControllerService projectControllerService, TaskService taskService, TaskProjektService taskProjektService) {
this.projectControllerService = projectControllerService;
this.taskService = taskService;
- this.taskStateControllerService = taskStateControllerService;
+ this.taskProjektService = taskProjektService;
}
@RequestMapping(path="", method = RequestMethod.GET)
@@ -65,6 +65,7 @@ public final String projectRoot(
model.addAttribute("isDeleted",isDeleted);
model.addAttribute("myTaskState","PROJECT");
}
+ model.addAttribute("userSession", userSession);
return "project/root/show";
}
@@ -76,6 +77,7 @@ public final String projectRootAddProjectGet(
log.info("/project/root/project/add (GET)");
Context context = super.getContext(userSession);
projectControllerService.addNewProjectToProjectRootForm(userSession, context, locale, model);
+ model.addAttribute("userSession", userSession);
return "project/root/project/add";
}
@@ -89,6 +91,7 @@ public final String projectRootAddProjectPost(
log.info("/project/root/add/project (POST)");
Context context = super.getContext(userSession);
if (result.hasErrors()) {
+ model.addAttribute("userSession", userSession);
return "project/root/project/add";
} else {
project.setUuid(UUID.randomUUID().toString());
@@ -135,6 +138,7 @@ public final String projectRootTaskAddGet(
model.addAttribute("thisProjectId", thisProject.getId());
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("task", task);
+ model.addAttribute("userSession", userSession);
return "project/root/task/add";
}
@@ -158,24 +162,13 @@ public final String projectRootTaskAddPost(
model.addAttribute("mustChooseArea", mustChooseArea);
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("task", task);
+ model.addAttribute("userSession", userSession);
return "project/root/task/add";
} else {
- task.setRootProject();
- /*
- if(task.getDueDate()==null){
- task.setTaskState(TaskState.INBOX);
- } else {
- task.setTaskState(TaskState.SCHEDULED);
- }
- */
- task.unsetFocus();
task.setContext(context);
- long maxOrderIdProject = taskService.getMaxOrderIdRootProject(context);
- task.setOrderIdProject(++maxOrderIdProject);
- long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
- task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskService.addToRootProject(task);
log.info(task.toString());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
}
@@ -204,6 +197,7 @@ public final String editTaskGet(
model.addAttribute("thisContext", thisContext);
model.addAttribute("task", task);
model.addAttribute("contexts", contexts);
+ model.addAttribute("userSession", userSession);
return "project/root/task/edit";
}
@@ -216,8 +210,6 @@ public final String editTaskPost(
Locale locale,
Model model
) {
- log.info("editTaskPost");
-
log.info("editTaskPost");
if(task.getTaskState()==TaskState.SCHEDULED && task.getDueDate()==null){
String objectName="task";
@@ -252,16 +244,18 @@ public final String editTaskPost(
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
userSession.setLastContextId(thisContext.getId());
+ model.addAttribute("userSession", userSession);
return "project/root/task/edit";
} else {
- task.unsetFocus();
+ //task.unsetFocus();
task.setRootProject();
Task persistentTask = taskService.findOne(task.getId());
persistentTask.merge(task);
- task = taskService.updatedViaProject(persistentTask);
+ task = taskService.updatedViaProjectRoot(persistentTask);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
}
@@ -279,22 +273,25 @@ public String changeTaskOrderId(
log.info("---------------------------------------------");
log.info("destination Task: "+destinationTask.toString());
log.info("---------------------------------------------");
- taskService.moveOrderIdTaskState(sourceTask, destinationTask);
+ projectControllerService.moveTaskToTaskAndChangeTaskOrderInProjectRoot(sourceTask, destinationTask);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(sourceTask.getTaskState());
userSession.setLastTaskId(sourceTask.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/move/to/project/root", method = RequestMethod.GET)
public final String moveTaskToProjectRoot(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task = taskService.moveTaskToRootProject(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@@ -302,244 +299,279 @@ public final String moveTaskToProjectRoot(
public final String moveTaskToProject(
@PathVariable("taskId") Task task,
@PathVariable("projectId") Project targetProject,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task = taskService.moveTaskToAnotherProject(task,targetProject);
userSession.setLastProjectId(targetProject.getId());
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return targetProject.getUrl();
}
@RequestMapping(path = "/task/{taskId}/move/to/taskstate/inbox", method = RequestMethod.GET)
public final String moveTaskToInbox(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to inbox");
task.moveToInbox();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/move/to/taskstate/today", method = RequestMethod.GET)
public final String moveTaskToToday(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to today");
task.moveToToday();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/move/to/taskstate/next", method = RequestMethod.GET)
public final String moveTaskToNext(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to next");
task.moveToNext();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/move/to/taskstate/waiting", method = RequestMethod.GET)
public final String moveTaskToWaiting(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to waiting");
task.moveToWaiting();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/move/to/taskstate/someday", method = RequestMethod.GET)
public final String moveTaskToSomeday(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to someday");
task.moveToSomeday();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/move/to/taskstate/focus", method = RequestMethod.GET)
public final String moveTaskToFocus(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to focus");
task.moveToFocus();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/move/to/taskstate/completed", method = RequestMethod.GET)
public final String moveTaskToCompleted(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to completed");
task.moveToCompletedTasks();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/move/to/trash", method = RequestMethod.GET)
public final String moveTaskToTrash(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("dragged and dropped "+task.getId()+" to trash");
task.moveToTrash();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/completed/move/to/trash", method = RequestMethod.GET)
public final String moveAllCompletedToTrash(
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
Context context = super.getContext(userSession);
taskService.moveAllCompletedToTrash(context);
userSession.setLastContextId(context.getId());
userSession.setLastProjectId(rootProjectId);
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/trash/empty", method = RequestMethod.GET)
public final String emptyTrash(
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
Context context = super.getContext(userSession);
taskService.emptyTrash(context);
userSession.setLastContextId(context.getId());
userSession.setLastProjectId(rootProjectId);
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/delete", method = RequestMethod.GET)
public final String deleteTaskGet(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("deleteTaskGet");
if(task!= null){
task.delete();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
}
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/undelete", method = RequestMethod.GET)
public final String undeleteTaskGet(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("undeleteTaskGet");
task.undelete();
- taskService.updatedViaProject(task);
+ taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/transform", method = RequestMethod.GET)
public final String transformTaskIntoProjectGet(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
log.info("transformTaskIntoProjectGet");
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
- return taskStateControllerService.transformTaskIntoProjectGet(task);
+ return taskProjektService.transformTaskIntoProjectGet(task, userSession, model);
}
@RequestMapping(path = "/task/{taskId}/complete", method = RequestMethod.GET)
public final String setDoneTaskGet(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task.complete();
- long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(TaskState.COMPLETED,task.getContext());
- task.setOrderIdTaskState(++maxOrderIdTaskState);
- task = taskService.updatedViaProject(task);
+ //long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(TaskState.COMPLETED,task.getContext());
+ //task.setOrderIdTaskState(++maxOrderIdTaskState);
+ task = taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/incomplete", method = RequestMethod.GET)
public final String unsetDoneTaskGet(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task.incomplete();
- long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
- task.setOrderIdTaskState(++maxOrderIdTaskState);
- task = taskService.updatedViaProject(task);
+ //long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
+ //task.setOrderIdTaskState(++maxOrderIdTaskState);
+ task = taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/setfocus", method = RequestMethod.GET)
public final String setFocusGet(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
){
task.setFocus();
- task = taskService.updatedViaProject(task);
+ task = taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
@RequestMapping(path = "/task/{taskId}/unsetfocus", method = RequestMethod.GET)
public final String unsetFocusGet(
@PathVariable("taskId") Task task,
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
){
task.unsetFocus();
- task = taskService.updatedViaProject(task);
+ task = taskService.updatedViaProjectRoot(task);
userSession.setLastProjectId(rootProjectId);
userSession.setLastTaskState(task.getTaskState());
userSession.setLastTaskId(task.getId());
+ model.addAttribute("userSession", userSession);
return rootProjectUrl;
}
}
diff --git a/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerService.java b/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerService.java
index c13aaad2..943b081f 100644
--- a/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerService.java
+++ b/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerService.java
@@ -3,6 +3,7 @@
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.woehlke.simpleworklist.context.Context;
+import org.woehlke.simpleworklist.task.Task;
import org.woehlke.simpleworklist.user.session.UserSessionBean;
import org.woehlke.simpleworklist.user.account.UserAccount;
@@ -50,4 +51,6 @@ Project getProject(
UserSessionBean userSession
);
+ void moveTaskToTaskAndChangeTaskOrderInProject(Task sourceTask, Task destinationTask);
+ void moveTaskToTaskAndChangeTaskOrderInProjectRoot(Task sourceTask, Task destinationTask);
}
diff --git a/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerServiceImpl.java b/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerServiceImpl.java
index 018f2d17..cfcacefa 100644
--- a/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerServiceImpl.java
+++ b/src/main/java/org/woehlke/simpleworklist/project/ProjectControllerServiceImpl.java
@@ -3,11 +3,15 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.woehlke.simpleworklist.application.breadcrumb.Breadcrumb;
import org.woehlke.simpleworklist.application.breadcrumb.BreadcrumbService;
import org.woehlke.simpleworklist.context.Context;
+import org.woehlke.simpleworklist.task.Task;
+import org.woehlke.simpleworklist.task.TaskService;
import org.woehlke.simpleworklist.user.session.UserSessionBean;
import org.woehlke.simpleworklist.user.account.UserAccount;
@@ -23,14 +27,16 @@ public class ProjectControllerServiceImpl implements ProjectControllerService {
private final ProjectService projectService;
private final BreadcrumbService breadcrumbService;
+ private final TaskService taskService;
@Autowired
public ProjectControllerServiceImpl(
ProjectService projectService,
- BreadcrumbService breadcrumbService
- ) {
+ BreadcrumbService breadcrumbService,
+ TaskService taskService) {
this.projectService = projectService;
this.breadcrumbService = breadcrumbService;
+ this.taskService = taskService;
}
public void addNewProjectToProjectIdForm(
@@ -43,13 +49,13 @@ public void addNewProjectToProjectIdForm(
log.info("addNewProject projectId="+projectId);
UserAccount userAccount = context.getUserAccount();
userSession.setLastProjectId(projectId);
- model.addAttribute("userSession",userSession);
Project thisProject = projectService.findByProjectId(projectId);
Project project = Project.newProjectFactoryForParentProject(thisProject);
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForShowOneProject(thisProject,locale);
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("thisProject", thisProject);
model.addAttribute("project", project);
+ model.addAttribute("userSession", userSession);
}
public String addNewProjectToProjectIdPersist(
@@ -70,14 +76,17 @@ public String addNewProjectToProjectIdPersist(
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("thisProject", thisProject);
model.addAttribute("project", project);
+ model.addAttribute("userSession", userSession);
return "project/id/show";
} else {
Project thisProject = projectService.findByProjectId(projectId);
project = thisProject.addOtherProjectToChildren(project);
+ project.setContext(context);
project = projectService.add(project);
thisProject = projectService.update(thisProject);
log.info("project: "+ project.toString());
log.info("thisProject: "+ thisProject.toString());
+ model.addAttribute("userSession", userSession);
return thisProject.getUrl();
}
}
@@ -108,6 +117,7 @@ public void addNewProjectToProjectRootForm(
model.addAttribute("thisProjectId", project.getId());
model.addAttribute("breadcrumb", breadcrumb);
userSession.setLastProjectId(rootProjectId);
+ model.addAttribute("userSession", userSession);
}
@Override
@@ -120,8 +130,68 @@ public String addNewProjectToProjectRootPersist(
Model model
) {
log.info("addNewProjectToRootPersist");
+ project.setContext(context);
project = projectService.add(project);
userSession.setLastProjectId(project.getId());
+ model.addAttribute("userSession", userSession);
return project.getUrl();
}
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public void moveTaskToTaskAndChangeTaskOrderInProject(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+ Project project = sourceTask.getProject();
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" START: moveTaskToTaskAndChangeTaskOrderInProject ");
+ log.info(" "+project.out()+":");
+ log.info(" "+sourceTask.outProject()+" -> "+destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+ boolean okProject = destinationTask.hasProject(project);
+ boolean sameContext = sourceTask.hasSameContextAs(destinationTask);
+ boolean sameProject = sourceTask.hasSameProjectAs(destinationTask);
+ boolean go = sameContext && sameProject && okProject;
+ if (go) {
+ boolean srcIsBelowDestinationTask = sourceTask.isBelowByProject(destinationTask);
+ log.info(" srcIsBelowDestinationTask: "+srcIsBelowDestinationTask);
+ log.info("-------------------------------------------------------------------------------");
+ if (srcIsBelowDestinationTask) {
+ this.taskService.moveTasksDownByProject(sourceTask, destinationTask);
+ } else {
+ this.taskService.moveTasksUpByProject(sourceTask, destinationTask);
+ }
+ }
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" DONE: moveTaskToTaskAndChangeTaskOrderInProject ");
+ log.info(" "+project.out()+":");
+ log.info(" "+sourceTask.outProject()+" -> "+destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public void moveTaskToTaskAndChangeTaskOrderInProjectRoot(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" START: moveTaskToTaskAndChangeTaskOrderIn Project Root");
+ log.info(" "+sourceTask.outProject()+" -> "+destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+ boolean sourceTaskRoot = destinationTask.isInRootProject();
+ boolean destinationTaskRoot = destinationTask.isInRootProject();
+ boolean sameContext = sourceTask.hasSameContextAs(destinationTask);
+ boolean sameProject = sourceTask.hasSameProjectAs(destinationTask);
+ boolean go = sameContext && sameProject && sourceTaskRoot && destinationTaskRoot;
+ if ( go ) {
+ boolean srcIsBelowDestinationTask = sourceTask.isBelowByProject(destinationTask);
+ log.info(" srcIsBelowDestinationTask: "+srcIsBelowDestinationTask);
+ log.info("-------------------------------------------------------------------------------");
+ if (srcIsBelowDestinationTask) {
+ this.taskService.moveTasksDownByProjectRoot(sourceTask, destinationTask);
+ } else {
+ this.taskService.moveTasksUpByProjectRoot(sourceTask, destinationTask);
+ }
+ }
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" DONE: moveTaskToTaskAndChangeTaskOrderIn Project Root");
+ log.info(" "+sourceTask.outProject()+" -> "+destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+ }
}
diff --git a/src/main/java/org/woehlke/simpleworklist/project/ProjectRepository.java b/src/main/java/org/woehlke/simpleworklist/project/ProjectRepository.java
index 4c67df67..89477763 100644
--- a/src/main/java/org/woehlke/simpleworklist/project/ProjectRepository.java
+++ b/src/main/java/org/woehlke/simpleworklist/project/ProjectRepository.java
@@ -2,6 +2,8 @@
import java.util.List;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.woehlke.simpleworklist.context.Context;
@@ -9,8 +11,14 @@
@Repository
public interface ProjectRepository extends JpaRepository {
+ //TODO: #245 change List to Page
+ @Deprecated
List findByContext(Context context);
+ Page findByContext(Context context, Pageable pageRequest);
+ //TODO: #245 change List to Page
+ @Deprecated
List findByParentIsNullAndContext(Context context);
+ Page findByParentIsNullAndContext(Context context, Pageable pageRequest);
}
diff --git a/src/main/java/org/woehlke/simpleworklist/project/ProjectService.java b/src/main/java/org/woehlke/simpleworklist/project/ProjectService.java
index a2a49d29..a9f8db6e 100644
--- a/src/main/java/org/woehlke/simpleworklist/project/ProjectService.java
+++ b/src/main/java/org/woehlke/simpleworklist/project/ProjectService.java
@@ -2,13 +2,21 @@
import java.util.List;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.woehlke.simpleworklist.context.Context;
public interface ProjectService {
+ //TODO: #245 change List to Page
+ @Deprecated
List findRootProjectsByContext(Context context);
+ Page findRootProjectsByContext(Context context, Pageable pageRequest);
+ //TODO: #245 change List to Page
+ @Deprecated
List findAllProjectsByContext(Context context);
+ Page findAllProjectsByContext(Context context, Pageable pageRequest);
Project moveProjectToAnotherProject(Project thisProject, Project targetProject);
diff --git a/src/main/java/org/woehlke/simpleworklist/project/ProjectServiceImpl.java b/src/main/java/org/woehlke/simpleworklist/project/ProjectServiceImpl.java
index 5ec82bd2..dc57bcad 100644
--- a/src/main/java/org/woehlke/simpleworklist/project/ProjectServiceImpl.java
+++ b/src/main/java/org/woehlke/simpleworklist/project/ProjectServiceImpl.java
@@ -7,6 +7,8 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -34,18 +36,36 @@ public ProjectServiceImpl(
this.taskRepository = taskRepository;
}
- @Override
+ //TODO: #245 change List to Page
+ @Deprecated
+ //@Override
public List findRootProjectsByContext(@NotNull Context context) {
log.info("findRootProjectsByContext");
+ //TODO: #245 change List to Page
return projectRepository.findByParentIsNullAndContext(context);
}
@Override
+ public Page findRootProjectsByContext(@NotNull Context context, Pageable pageRequest) {
+ log.info("findRootProjectsByContext");
+ return projectRepository.findByParentIsNullAndContext(context,pageRequest);
+ }
+
+ //TODO: #245 change List to Page
+ @Deprecated
+ //@Override
public List findAllProjectsByContext(@NotNull Context context) {
log.info("findAllProjectsByContext");
+ //TODO: #245 change List to Page
return projectRepository.findByContext(context);
}
+ @Override
+ public Page findAllProjectsByContext(Context context, Pageable pageRequest) {
+ log.info("findAllProjectsByContext");
+ return projectRepository.findByContext(context,pageRequest);
+ }
+
@Override
public Project findByProjectId(@Min(1L) long projectId) {
log.info("findByProjectId");
@@ -94,6 +114,7 @@ public Project moveProjectToAnotherContext(@NotNull Project thisProject, @NotNul
log.info("----------------------------------------------------");
thisProject.setParent(null);
thisProject = projectRepository.saveAndFlush(thisProject);
+ //TODO: remove Recursion, remove unbounded Recursion and List instead of Page.
List listProject = getAllChildrenOfProject(thisProject);
for(Project childProject : listProject){
List tasksOfChildProject = taskRepository.findByProject(childProject);
@@ -107,15 +128,18 @@ public Project moveProjectToAnotherContext(@NotNull Project thisProject, @NotNul
return thisProject;
}
+ //TODO: remove Recursion, remove unbounded Recursion and List instead of Page.
+ @Deprecated
private List getAllChildrenOfProject(@NotNull Project thisProject) {
log.info("getAllChildrenOfProject");
- List retVal = new ArrayList<>();
- retVal.add(thisProject);
+ List childrenOfProject = new ArrayList<>();
+ childrenOfProject.add(thisProject);
for(Project p : thisProject.getChildren()){
+ //TODO: remove Recursion, remove unbounded Recursion and List instead of Page.
List getNextGeneration = getAllChildrenOfProject(p);
- retVal.addAll(getNextGeneration);
+ childrenOfProject.addAll(getNextGeneration);
}
- return retVal;
+ return childrenOfProject;
}
@Override
diff --git a/src/main/java/org/woehlke/simpleworklist/task/Task.java b/src/main/java/org/woehlke/simpleworklist/task/Task.java
index 0c9059b8..09b1bde3 100644
--- a/src/main/java/org/woehlke/simpleworklist/task/Task.java
+++ b/src/main/java/org/woehlke/simpleworklist/task/Task.java
@@ -56,7 +56,7 @@
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
+@ToString(callSuper = true, exclude="text")
public class Task extends AuditModel implements Serializable, ComparableById {
private static final long serialVersionUID = 5247710652586269801L;
@@ -82,6 +82,18 @@ public class Task extends AuditModel implements Serializable, ComparableById {
+ //TODO: #244 change List to Page
+ @Deprecated
List findByProject(Project thisProject);
-
Page findByProject(Project thisProject, Pageable pageable);
-
Page findByFocusAndContext(boolean focus, Context context, Pageable request);
-
Page findByProjectIsNullAndContext(Context context, Pageable request);
+ //TODO: #244 change List to Page
+ @Deprecated
List findByContext(Context context);
+ Page findByContext(Context context, Pageable pageable);
- Task findTopByTaskStateAndContextOrderByOrderIdTaskStateDesc(TaskState inbox, Context context);
-
+ Task findTopByTaskStateAndContextOrderByOrderIdTaskStateDesc(TaskState taskState, Context context);
+ Task findTopByProjectIsNullAndContextOrderByOrderIdProjectDesc(Context context);
Task findTopByProjectAndContextOrderByOrderIdProjectDesc(Project project, Context context);
- Page findByTaskStateAndContext(TaskState taskState, Context context, Pageable request);
-
+ //TODO: #244 change List to Page>
+ @Deprecated
List findByTaskStateAndContext(TaskState taskState, Context context);
+ Page findByTaskStateAndContext(TaskState taskState, Context context, Pageable request);
- List findByTaskStateAndContextOrderByOrderIdTaskStateAsc(TaskState taskState, Context context);
+ //TODO: #244 change List to Page
+ @Deprecated
+ List findByTaskStateAndContextOrderByOrderIdTaskStateAsc(
+ TaskState taskState, Context context
+ );
+ Page findByTaskStateAndContextOrderByOrderIdTaskStateAsc(
+ TaskState taskState, Context context, Pageable request
+ );
+ //TODO: #244 change List to Page
+ //TODO: #249 move the JQL Query-String to Entity as Prepared Statement
+ @Deprecated
@Query("select t from Task t"
+ " where t.orderIdTaskState > :lowerOrderIdTaskState and t.orderIdTaskState < :higherOrderIdTaskState"
+ " and t.taskState = :taskState and t.context = :context")
@@ -43,15 +56,60 @@ List getTasksByOrderIdTaskStateBetweenLowerTaskAndHigherTask(
@Param("taskState") TaskState taskState,
@Param("context") Context context
);
+ //TODO: #249 move the JQL Query-String to Entity as Prepared Statement
+ @Query("select t from Task t"
+ + " where t.orderIdTaskState > :lowerOrderIdTaskState and t.orderIdTaskState < :higherOrderIdTaskState"
+ + " and t.taskState = :taskState and t.context = :context")
+ Page getTasksByOrderIdTaskStateBetweenLowerTaskAndHigherTask(
+ @Param("lowerOrderIdTaskState") long lowerOrderIdTaskState,
+ @Param("higherOrderIdTaskState") long higherOrderIdTaskState,
+ @Param("taskState") TaskState taskState,
+ @Param("context") Context context,
+ Pageable request
+ );
+ //TODO: #244 change List to Page
+ //TODO: #249 move the JQL Query-String to Entity as Prepared Statement
+ @Deprecated
@Query("select t from Task t"
+ " where t.orderIdProject > :lowerOrderIdProject and t.orderIdProject < :higherOrderIdProject"
- + " and t.project = :project and t.context = :context ")
+ + " and t.project = :project")
List getTasksByOrderIdProjectBetweenLowerTaskAndHigherTask(
+ @Param("lowerOrderIdProject") long lowerOrderIdProject,
+ @Param("higherOrderIdProject") long higherOrderIdProject,
+ @Param("project") Project project
+ );
+ //TODO: #249 move the JQL Query-String to Entity as Prepared Statement
+ @Query("select t from Task t"
+ + " where t.orderIdProject > :lowerOrderIdProject and t.orderIdProject < :higherOrderIdProject"
+ + " and t.project = :project")
+ Page getTasksByOrderIdProjectBetweenLowerTaskAndHigherTask(
@Param("lowerOrderIdProject") long lowerOrderIdProject,
@Param("higherOrderIdProject") long higherOrderIdProject,
@Param("project") Project project,
+ Pageable request
+ );
+
+ //TODO: #244 move from List to Page
+ //TODO: #249 move the JQL Query-String to Entity as Prepared Statement
+ @Deprecated
+ @Query("select t from Task t"
+ + " where t.orderIdProject > :lowerOrderIdProject and t.orderIdProject < :higherOrderIdProject"
+ + " and t.project is null and t.context = :context ")
+ List getTasksByOrderIdProjectRootBetweenLowerTaskAndHigherTask(
+ @Param("lowerOrderIdProject") long lowerOrderIdProject,
+ @Param("higherOrderIdProject") long higherOrderIdProject,
@Param("context") Context context
);
+ //TODO: #249 move the JQL Query-String to Entity as Prepared Statement
+ @Query("select t from Task t"
+ + " where t.orderIdProject > :lowerOrderIdProject and t.orderIdProject < :higherOrderIdProject"
+ + " and t.project is null and t.context = :context ")
+ Page getTasksByOrderIdProjectRootBetweenLowerTaskAndHigherTask(
+ @Param("lowerOrderIdProject") long lowerOrderIdProject,
+ @Param("higherOrderIdProject") long higherOrderIdProject,
+ @Param("context") Context context,
+ Pageable request
+ );
}
diff --git a/src/main/java/org/woehlke/simpleworklist/task/TaskService.java b/src/main/java/org/woehlke/simpleworklist/task/TaskService.java
index 2f67595e..8b41e5e2 100644
--- a/src/main/java/org/woehlke/simpleworklist/task/TaskService.java
+++ b/src/main/java/org/woehlke/simpleworklist/task/TaskService.java
@@ -7,33 +7,63 @@
public interface TaskService {
- Task findOne(long taskId);
- boolean projectHasNoTasks(Project project);
+ Task moveTaskToInbox(Task task);
+ Task moveTaskToToday(Task task);
+ Task moveTaskToNext(Task task);
+ Task moveTaskToWaiting(Task task);
+ Task moveTaskToSomeday(Task task);
+ Task moveTaskToFocus(Task task);
+ Task moveTaskToCompleted(Task task);
+ Task moveTaskToTrash(Task task);
- Page findbyTaskstate(TaskState taskState, Context context, Pageable request);
+ void moveAllCompletedToTrash(Context context);
+ void emptyTrash(Context context);
+
+ Task moveTaskToRootProject(Task task);
+ Task moveTaskToAnotherProject(Task task, Project project);
+
+ Task addToInbox(Task task);
+ Task addToProject(Task task);
+ Task addToRootProject(Task task);
+
+ Task updatedViaTaskstate(Task task);
+ Task updatedViaProject(Task task);
+ Task updatedViaProjectRoot(Task task);
+ //TODO: rename to findById
+ Task findOne(long taskId);
+ Page findbyTaskstate(TaskState taskState, Context context, Pageable request);
Page findByProject(Project thisProject, Pageable request);
+ //TODO: rename to findByProjectRoot
Page findByRootProject(Context context, Pageable request);
+ boolean projectHasNoTasks(Project project);
+
long getMaxOrderIdTaskState(TaskState taskState, Context context);
- long getMaxOrderIdRootProject(Context context);
long getMaxOrderIdProject(Project project, Context context);
+ long getMaxOrderIdProjectRoot(Context context);
+ /**
+ * Before: sourceTask is dragged from above down to destinationTask, so sourceTask is above destinationTask.
+ * After: sourceTask is placed to the position of destinationTask, all tasks between old position of sourceTask
+ * and destinationTask are moved one position up; destinationTask is the next Task above sourceTask.
+ * @param sourceTask Task
+ * @param destinationTask Task
+ */
+ void moveTasksUpByTaskState(Task sourceTask, Task destinationTask);
+ /**
+ * Before: sourceTask is dragged from below up to destinationTask, so sourceTask is below destinationTask.
+ * After: sourceTask is placed to the position of destinationTask, all tasks between old position of sourceTask
+ * are moved one position down; destinationTask is the next Task below sourceTask.
+ * @param sourceTask Task
+ * @param destinationTask Task
+ */
+ void moveTasksDownByTaskState(Task sourceTask, Task destinationTask);
- Task addToInbox(Task task);
- Task addToRootProject(Task task);
- Task addToProject(Task task);
-
- Task updatedViaTaskstate(Task task);
- Task updatedViaProject(Task task);
-
- Task moveTaskToRootProject(Task task);
- Task moveTaskToAnotherProject(Task task, Project project);
- void moveAllCompletedToTrash(Context context);
- void emptyTrash(Context context);
+ void moveTasksUpByProjectRoot(Task sourceTask, Task destinationTask);
+ void moveTasksDownByProjectRoot(Task sourceTask, Task destinationTask);
- void moveOrderIdTaskState(Task sourceTask, Task destinationTask);
- void moveOrderIdProject(Task sourceTask, Task destinationTask);
- void moveOrderIdRootProject(Task sourceTask, Task destinationTask);
+ void moveTasksUpByProject(Task sourceTask, Task destinationTask);
+ void moveTasksDownByProject(Task sourceTask, Task destinationTask);
}
diff --git a/src/main/java/org/woehlke/simpleworklist/task/TaskServiceImpl.java b/src/main/java/org/woehlke/simpleworklist/task/TaskServiceImpl.java
index 08c87a4b..e8d61ffb 100644
--- a/src/main/java/org/woehlke/simpleworklist/task/TaskServiceImpl.java
+++ b/src/main/java/org/woehlke/simpleworklist/task/TaskServiceImpl.java
@@ -32,6 +32,7 @@ public TaskServiceImpl(TaskRepository taskRepository ) {
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
public boolean projectHasNoTasks(Project project) {
log.info("projectHasNoTasks");
+ //TODO: #244 change List to Page
return taskRepository.findByProject(project).isEmpty();
}
@@ -83,8 +84,10 @@ public Task findOne(@Min(1L) long taskId) {
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public Task updatedViaTaskstate(@NotNull Task task) {
log.info("updatedViaTaskstate");
+ long maxOrderIdTaskState = this.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
+ task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskRepository.saveAndFlush(task);
- log.info("persisted: " + task.getId());
+ log.info("persisted: " + task.outTaskstate());
return task;
}
@@ -92,8 +95,38 @@ public Task updatedViaTaskstate(@NotNull Task task) {
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public Task updatedViaProject(@NotNull Task task) {
log.info("updatedViaProject");
+ long maxOrderIdProject = this.getMaxOrderIdProject(task.getProject(), task.getContext());
+ task.setOrderIdProject(++maxOrderIdProject);
+ task = taskRepository.saveAndFlush(task);
+ log.info("persisted Task: " + task.outProject());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task updatedViaProjectRoot(@NotNull Task task) {
+ log.info("updatedViaProject");
+ //long maxOrderIdProject = this.getMaxOrderIdProjectRoot(task.getContext());
+ //task.setOrderIdProject(++maxOrderIdProject);
task = taskRepository.saveAndFlush(task);
- log.info("persisted Task: " + task.getId());
+ log.info("persisted Task: " + task.outProject());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task addToInbox(@NotNull Task task) {
+ log.info("addToInbox");
+ task.setUuid(UUID.randomUUID().toString());
+ task.setRootProject();
+ task.unsetFocus();
+ task.setTaskState(TaskState.INBOX);
+ long maxOrderIdProject = this.getMaxOrderIdProjectRoot(task.getContext());
+ task.setOrderIdProject(++maxOrderIdProject);
+ long maxOrderIdTaskState = this.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
+ task.setOrderIdTaskState(++maxOrderIdTaskState);
+ task = taskRepository.saveAndFlush(task);
+ log.info("persisted: " + task.outTaskstate());
return task;
}
@@ -102,8 +135,13 @@ public Task updatedViaProject(@NotNull Task task) {
public Task addToProject(@NotNull Task task) {
log.info("addToProject");
task.setUuid(UUID.randomUUID().toString());
+ task.unsetFocus();
+ long maxOrderIdProject = this.getMaxOrderIdProject(task.getProject(),task.getContext());
+ task.setOrderIdProject(++maxOrderIdProject);
+ long maxOrderIdTaskState = this.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
+ task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskRepository.saveAndFlush(task);
- log.info("persisted: " + task.getId());
+ log.info("persisted: " + task.outProject());
return task;
}
@@ -112,19 +150,23 @@ public Task addToProject(@NotNull Task task) {
public Task addToRootProject(@NotNull Task task) {
log.info("addToRootProject");
task.setUuid(UUID.randomUUID().toString());
+ task.setRootProject();
task.unsetFocus();
+ task.moveToInbox();
+ long maxOrderIdProject = this.getMaxOrderIdProjectRoot(task.getContext());
+ task.setOrderIdProject(++maxOrderIdProject);
+ long maxOrderIdTaskState = this.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
+ task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskRepository.saveAndFlush(task);
- log.info("persisted: " + task.getId());
+ log.info("persisted: " + task.outProject());
return task;
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public Task moveTaskToRootProject(@NotNull Task task) {
- task.setRootProject();
- long maxOrderIdProject = this.getMaxOrderIdProject(
- task.getProject(), task.getContext()
- );
+ task.moveTaskToRootProject();
+ long maxOrderIdProject = this.getMaxOrderIdProjectRoot(task.getContext());
task.setOrderIdProject(++maxOrderIdProject);
return taskRepository.saveAndFlush(task);
}
@@ -134,7 +176,7 @@ public Task moveTaskToRootProject(@NotNull Task task) {
public Task moveTaskToAnotherProject(@NotNull Task task, @NotNull Project project) {
boolean okContext = task.hasSameContextAs(project);
if(okContext) {
- task.setProject(project);
+ task.moveTaskToAnotherProject(project);
long maxOrderIdProject = this.getMaxOrderIdProject(
task.getProject(),
task.getContext()
@@ -145,122 +187,15 @@ public Task moveTaskToAnotherProject(@NotNull Task task, @NotNull Project projec
return task;
}
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task moveTaskToInbox(@NotNull Task task) {
- long newOrderIdTaskState = this.getMaxOrderIdTaskState(
- TaskState.INBOX,
- task.getContext()
- );
- task.setTaskState(TaskState.INBOX);
- task.setOrderIdTaskState(++newOrderIdTaskState);
- task = taskRepository.saveAndFlush(task);
- log.info("moved " + task.getId() + " to inbox: " + task.toString());
- return task;
- }
-
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task moveTaskToToday(@NotNull Task task) {
- Date now = new Date();
- long newOrderIdTaskState = this.getMaxOrderIdTaskState(
- TaskState.TODAY,
- task.getContext()
- );
- task.setOrderIdTaskState(++newOrderIdTaskState);
- task.setTaskState(TaskState.TODAY);
- task.setDueDate(now);
- task = taskRepository.saveAndFlush(task);
- log.info("moved " + task.getId() + " to today: " + task.toString());
- return task;
- }
-
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task moveTaskToNext(@NotNull Task task) {
- long newOrderIdTaskState = this.getMaxOrderIdTaskState(
- TaskState.NEXT,
- task.getContext()
- );
- task.setOrderIdTaskState(++newOrderIdTaskState);
- task.setTaskState(TaskState.NEXT);
- task = taskRepository.saveAndFlush(task);
- log.info("moved " + task.getId() + " to next: " + task.toString());
- return task;
- }
-
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task moveTaskToWaiting(@NotNull Task task) {
- long newOrderIdTaskState = this.getMaxOrderIdTaskState(
- TaskState.WAITING,
- task.getContext()
- );
- task.setOrderIdTaskState(++newOrderIdTaskState);
- task.setTaskState(TaskState.WAITING);
- task = taskRepository.saveAndFlush(task);
- log.info("moved " + task.getId() + " to next: " + task.toString());
- return task;
- }
-
-
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task moveTaskToSomeday(@NotNull Task task) {
- long newOrderIdTaskState = this.getMaxOrderIdTaskState(
- TaskState.SOMEDAY,
- task.getContext()
- );
- task.setOrderIdTaskState(++newOrderIdTaskState);
- task.setTaskState(TaskState.SOMEDAY);
- task = taskRepository.saveAndFlush(task);
- log.info("moved " + task.getId() + " to someday: " + task.toString());
- return task;
- }
-
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task moveTaskToFocus(@NotNull Task task) {
- long newOrderIdTaskState = this.getMaxOrderIdTaskState(
- TaskState.FOCUS,
- task.getContext()
- );
- task.setOrderIdTaskState(++newOrderIdTaskState);
- task.setFocus(true);
- task = taskRepository.saveAndFlush(task);
- log.info("moved " + task.getId() + " to focus: " + task.toString());
- return task;
- }
-
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task moveTaskToCompleted(@NotNull Task task) {
- long newOrderIdTaskState = this.getMaxOrderIdTaskState(
- TaskState.COMPLETED,
- task.getContext()
- );
- task.setOrderIdTaskState(++newOrderIdTaskState);
- task.setTaskState(TaskState.COMPLETED);
- task = taskRepository.saveAndFlush(task);
- log.debug("moved " + task.getId() + " to completed: " + task.toString());
- return task;
- }
-
-
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task moveTaskToTrash(@NotNull Task task) {
- long newOrderIdTaskState = this.getMaxOrderIdTaskState(
- TaskState.TRASH,
- task.getContext()
- );
- task.setOrderIdTaskState(++newOrderIdTaskState);
- task.setTaskState(TaskState.TRASH);
- task = taskRepository.saveAndFlush(task);
- log.debug("moved " + task.getId() + " to trash: " + task.toString());
- return task;
- }
-
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public void moveAllCompletedToTrash(@NotNull Context context) {
- long maxOrderIdTaskState = this.getMaxOrderIdTaskStateFor(
+ long maxOrderIdTaskState = this.getMaxOrderIdTaskState(
TaskState.TRASH,
context
);
long newOrderIdTaskState = maxOrderIdTaskState;
+ //TODO: #244 change List to Page
List taskListCompleted = taskRepository.findByTaskStateAndContextOrderByOrderIdTaskStateAsc(
TaskState.COMPLETED,
context
@@ -276,10 +211,12 @@ public void moveAllCompletedToTrash(@NotNull Context context) {
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public void emptyTrash(@NotNull Context context) {
+ //TODO: #244 change List to Page
List taskList = taskRepository.findByTaskStateAndContext(
TaskState.TRASH,
context
);
+ //TODO: #244 change List to Page
List taskListChanged = new ArrayList<>(taskList.size());
for(Task task: taskList){
task.emptyTrash();
@@ -308,48 +245,10 @@ public long getMaxOrderIdProject(@NotNull Project project, @NotNull Context cont
return (task==null) ? 0 : task.getOrderIdProject();
}
- @Override
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public void moveOrderIdTaskState(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
- boolean notEqualsId = ! sourceTask.equalsById(destinationTask);
- boolean notEquals = ! sourceTask.equalsByUniqueConstraint(destinationTask);
- boolean sameContext = sourceTask.hasSameContextAs(destinationTask);
- boolean sameTaskType = sourceTask.hasSameTaskTypetAs(destinationTask);
- boolean srcIsBelowDestinationTask = sourceTask.isBelowByTaskState(destinationTask);
- if (
- notEqualsId && notEquals &&
- sameContext && sameTaskType
- ) {
- if (srcIsBelowDestinationTask) {
- this.moveTasksDownByTaskState( sourceTask, destinationTask );
- } else {
- this.moveTasksUpByTaskState( sourceTask, destinationTask );
- }
- }
- }
-
- @Override
- @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public void moveOrderIdRootProject(@NotNull Task sourceTask,@NotNull Task destinationTask ) {
- boolean sourceTaskRoot = destinationTask.isInRootProject();
- boolean destinationTaskRoot = destinationTask.isInRootProject();
- boolean sameContext = sourceTask.hasSameContextAs(destinationTask);
- boolean sameProject = sourceTask.hasSameProjectAs(destinationTask);
- boolean srcIsBelowDestinationTask = sourceTask.isBelowByProject(destinationTask);
- if (sameContext && sameProject && sourceTaskRoot && destinationTaskRoot) {
- if (srcIsBelowDestinationTask) {
- this.moveTasksDownByProject(sourceTask, destinationTask);
- } else {
- this.moveTasksUpByProject(sourceTask, destinationTask);
- }
- }
- }
-
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
- public long getMaxOrderIdRootProject(@NotNull Context context) {
- Task task = taskRepository.findTopByProjectAndContextOrderByOrderIdProjectDesc(
- null,
+ public long getMaxOrderIdProjectRoot(@NotNull Context context) {
+ Task task = taskRepository.findTopByProjectIsNullAndContextOrderByOrderIdProjectDesc(
context
);
return (task==null) ? 0 : task.getOrderIdProject();
@@ -357,151 +256,315 @@ public long getMaxOrderIdRootProject(@NotNull Context context) {
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public void moveOrderIdProject(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
- Project project = sourceTask.getProject();
- boolean okProject = destinationTask.hasProject(project);
- boolean sameContext = sourceTask.hasSameContextAs(destinationTask);
- boolean sameProject = sourceTask.hasSameProjectAs(destinationTask);
- boolean srcIsBelowDestinationTask = sourceTask.isBelowByProject(destinationTask);
- if (sameContext && sameProject && okProject) {
- if (srcIsBelowDestinationTask) {
- this.moveTasksDownByProject(sourceTask, destinationTask);
- } else {
- this.moveTasksUpByProject(sourceTask, destinationTask);
- }
- }
- }
-
- /**
- * Before: sourceTask is dragged from above down to destinationTask, so sourceTask is above destinationTask.
- * After: sourceTask is placed to the position of destinationTask, all tasks between old position of sourceTask
- * and destinationTask are moved one position up; destinationTask is the next Task above sourceTask.
- * @param sourceTask
- * @param destinationTask
- */
- private void moveTasksUpByTaskState(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+ public void moveTasksUpByTaskState(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
TaskState taskState = sourceTask.getTaskState();
Context context = sourceTask.getContext();
- long lowerOrderIdTaskState = destinationTask.getOrderIdTaskState();
- long higherOrderIdTaskState = sourceTask.getOrderIdTaskState();
+ final long lowerOrderIdTaskState = destinationTask.getOrderIdTaskState();
+ final long higherOrderIdTaskState = sourceTask.getOrderIdTaskState();
+ //TODO: #244 change List to Page
List tasks = taskRepository.getTasksByOrderIdTaskStateBetweenLowerTaskAndHigherTask(
lowerOrderIdTaskState,
higherOrderIdTaskState,
taskState,
context
);
+ //TODO: #244 change List to Page
+ List tasksMoved = new ArrayList<>(tasks.size()+2);
for(Task task:tasks){
task.moveUpByTaskState();
+ log.info(task.outTaskstate());
+ tasksMoved.add(task);
}
- sourceTask.setOrderIdTaskState( destinationTask.getOrderIdTaskState() );
- destinationTask.moveDownByTaskState();
- tasks.add(sourceTask);
- tasks.add(destinationTask);
- taskRepository.saveAll(tasks);
+ destinationTask.moveUpByTaskState();
+ log.info(destinationTask.outTaskstate());
+ tasksMoved.add(destinationTask);
+ sourceTask.setOrderIdTaskState( lowerOrderIdTaskState );
+ log.info(sourceTask.outTaskstate());
+ tasksMoved.add(sourceTask);
+ taskRepository.saveAll(tasksMoved);
}
- private long getMaxOrderIdTaskStateFor(@NotNull TaskState taskState, @NotNull Context context ){
- Task task = taskRepository.findTopByTaskStateAndContextOrderByOrderIdTaskStateDesc(
- taskState,
- context
- );
- return (task == null) ? 0 : task.getOrderIdTaskState();
- }
-
- /**
- * Before: sourceTask is dragged from below up to destinationTask, so sourceTask is below destinationTask.
- * After: sourceTask is placed to the position of destinationTask, all tasks between old position of sourceTask
- * are moved one position down; destinationTask is the next Task below sourceTask.
- * @param sourceTask
- * @param destinationTask
- */
- private void moveTasksDownByTaskState(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public void moveTasksDownByTaskState(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" moveTasks DOWN By TaskState: "+sourceTask.getId() +" -> "+ destinationTask.getId());
+ log.info("-------------------------------------------------------------------------------");
TaskState taskState = sourceTask.getTaskState();
Context context = sourceTask.getContext();
long lowerOrderIdTaskState = sourceTask.getOrderIdTaskState();
long higherOrderIdTaskState = destinationTask.getOrderIdTaskState();
+ //TODO: #244 change List to Page
List tasks = taskRepository.getTasksByOrderIdTaskStateBetweenLowerTaskAndHigherTask(
lowerOrderIdTaskState,
higherOrderIdTaskState,
taskState,
context
);
+ //TODO: #244 change List to Page
+ List tasksMoved = new ArrayList<>(tasks.size()+2);
for(Task task:tasks){
task.moveDownByTaskState();
+ log.info(task.outProject());
+ tasksMoved.add(task);
}
- sourceTask.setOrderIdTaskState(destinationTask.getOrderIdProject());
+ sourceTask.setOrderIdTaskState(higherOrderIdTaskState);
destinationTask.moveDownByTaskState();
- tasks.add(sourceTask);
- tasks.add(destinationTask);
- taskRepository.saveAll(tasks);
+ tasksMoved.add(sourceTask);
+ tasksMoved.add(destinationTask);
+ taskRepository.saveAll(tasksMoved);
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" DONE: moveTasks DOWN By TaskState("+taskState.name()+"): "+sourceTask.getId() +" -> "+ destinationTask.getId());
+ log.info("-------------------------------------------------------------------------------");
}
- private void moveTasksUpByProject(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public void moveTasksUpByProjectRoot(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" moveTasks UP By ProjectRoot: "+sourceTask.getId() +" -> "+ destinationTask.getId());
+ log.info("-------------------------------------------------------------------------------");
Context context = sourceTask.getContext();
- Project project = sourceTask.getProject();
long lowerOrderIdProject = destinationTask.getOrderIdProject();
long higherOrderIdProject = sourceTask.getOrderIdProject();
- List tasks = taskRepository.getTasksByOrderIdProjectBetweenLowerTaskAndHigherTask(
+ //TODO: #244 change List to Page
+ List tasks = taskRepository.getTasksByOrderIdProjectRootBetweenLowerTaskAndHigherTask(
lowerOrderIdProject,
higherOrderIdProject,
- project,
context
);
+ //TODO: #244 change List to Page
+ List tasksMoved = new ArrayList<>(tasks.size()+2);
for(Task task:tasks){
task.moveUpByProject();
+ log.info(task.outProject());
+ tasksMoved.add(task);
}
- sourceTask.setOrderIdProject(destinationTask.getOrderIdProject());
+ sourceTask.setOrderIdProject(lowerOrderIdProject);
destinationTask.moveUpByProject();
- tasks.add(sourceTask);
- tasks.add(destinationTask);
- taskRepository.saveAll(tasks);
+ tasksMoved.add(sourceTask);
+ tasksMoved.add(destinationTask);
+ taskRepository.saveAll(tasksMoved);
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" DONE: moveTasks UP By ProjectRoot: "+sourceTask.getId() +" -> "+ destinationTask.getId());
+ log.info("-------------------------------------------------------------------------------");
}
- private void moveTasksDownByProject(@NotNull Task sourceTask, @NotNull Task destinationTask) {
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public void moveTasksDownByProjectRoot(@NotNull Task sourceTask, @NotNull Task destinationTask) {
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" START moveTasks UP By Project Root");
+ log.info(" "+sourceTask.outProject() +" -> "+ destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
Context context = sourceTask.getContext();
- Project project = sourceTask.getProject();
- long lowerOrderIdProject = sourceTask.getOrderIdProject();
- long higherOrderIdProject = destinationTask.getOrderIdProject();
- List tasks = taskRepository.getTasksByOrderIdProjectBetweenLowerTaskAndHigherTask(
+ final long lowerOrderIdProject = sourceTask.getOrderIdProject();
+ final long higherOrderIdProject = destinationTask.getOrderIdProject();
+ //TODO: #244 change List to Page
+ List tasks = taskRepository.getTasksByOrderIdProjectRootBetweenLowerTaskAndHigherTask(
lowerOrderIdProject,
higherOrderIdProject,
- project,
context
);
+ //TODO: #244 change List to Page
+ List tasksMoved = new ArrayList<>(tasks.size()+2);
for(Task task:tasks){
task.moveDownByProject();
+ log.info(task.outProject());
+ tasksMoved.add(task);
}
- sourceTask.setOrderIdProject(destinationTask.getOrderIdProject());
+ sourceTask.setOrderIdProject(higherOrderIdProject);
destinationTask.moveDownByProject();
- tasks.add(sourceTask);
- tasks.add(destinationTask);
- taskRepository.saveAll(tasks);
+ tasksMoved.add(sourceTask);
+ tasksMoved.add(destinationTask);
+ taskRepository.saveAll(tasksMoved);
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" DONE moveTasks UP By Project Root");
+ log.info(" "+sourceTask.outProject() +" -> "+ destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public Task addToInbox(@NotNull Task task) {
- log.info("addToInbox");
- task.setUuid(UUID.randomUUID().toString());
- task.setRootProject();
- task.unsetFocus();
- task.setTaskState(TaskState.INBOX);
- /*
- if(task.getDueDate()==null){
- task.setTaskState(TaskState.INBOX);
- } else {
- task.setTaskState(TaskState.SCHEDULED);
+ public void moveTasksUpByProject(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+ Project project = sourceTask.getProject();
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" START moveTasks UP By Project("+project.out()+"):");
+ log.info(" "+sourceTask.outProject() +" -> "+ destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+ long lowerOrderIdProject = destinationTask.getOrderIdProject();
+ long higherOrderIdProject = sourceTask.getOrderIdProject();
+ //TODO: #244 change List to Page
+ List tasks = taskRepository.getTasksByOrderIdProjectBetweenLowerTaskAndHigherTask(
+ lowerOrderIdProject,
+ higherOrderIdProject,
+ project
+ );
+ //TODO: #244 change List to Page
+ List tasksMoved = new ArrayList<>(tasks.size()+2);
+ for(Task task:tasks){
+ task.moveUpByProject();
+ log.info(task.outProject());
+ tasksMoved.add(task);
}
- */
- //task.setFocus(false);
- //task.setContext(context);
- long maxOrderIdProject = this.getMaxOrderIdRootProject(task.getContext());
- task.setOrderIdProject(++maxOrderIdProject);
- long maxOrderIdTaskState = this.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
- task.setOrderIdTaskState(++maxOrderIdTaskState);
+ sourceTask.setOrderIdProject(lowerOrderIdProject);
+ destinationTask.moveUpByProject();
+ tasksMoved.add(sourceTask);
+ tasksMoved.add(destinationTask);
+ taskRepository.saveAll(tasksMoved);
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" DONE moveTasks UP By Project("+project.out()+"):");
+ log.info(" "+sourceTask.outProject() +" -> "+ destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public void moveTasksDownByProject(@NotNull Task sourceTask, @NotNull Task destinationTask) {
+ Project project = sourceTask.getProject();
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" START moveTasks DOWN By Project("+project.out()+"):");
+ log.info(" "+sourceTask.outProject() +" -> "+ destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+ final long lowerOrderIdProject = sourceTask.getOrderIdProject();
+ final long higherOrderIdProject = destinationTask.getOrderIdProject();
+ //TODO: #244 change List to Page
+ List tasks = taskRepository.getTasksByOrderIdProjectBetweenLowerTaskAndHigherTask(
+ lowerOrderIdProject,
+ higherOrderIdProject,
+ project
+ );
+ //TODO: #244 change List to Page
+ List tasksMoved = new ArrayList<>(tasks.size()+2);
+ for(Task task:tasks){
+ task.moveDownByProject();
+ log.info(task.outProject());
+ tasksMoved.add(task);
+ }
+ sourceTask.setOrderIdProject(higherOrderIdProject);
+ destinationTask.moveDownByProject();
+ tasksMoved.add(sourceTask);
+ tasksMoved.add(destinationTask);
+ taskRepository.saveAll(tasksMoved);
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" DONE smoveTasks DOWN By Project("+project.out()+"):");
+ log.info(" "+sourceTask.outProject() +" -> "+ destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task moveTaskToInbox(@NotNull Task task) {
+ long newOrderIdTaskState = this.getMaxOrderIdTaskState(
+ TaskState.INBOX,
+ task.getContext()
+ );
+ task.moveToInbox();
+ task.setOrderIdTaskState(++newOrderIdTaskState);
+ task = taskRepository.saveAndFlush(task);
+ log.info("moved to inbox: " + task.outTaskstate());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task moveTaskToToday(@NotNull Task task) {
+ Date now = new Date();
+ long newOrderIdTaskState = this.getMaxOrderIdTaskState(
+ TaskState.TODAY,
+ task.getContext()
+ );
+ task.moveToToday();
+ task.setOrderIdTaskState(++newOrderIdTaskState);
+ task = taskRepository.saveAndFlush(task);
+ log.info("moved to today: " + task.outTaskstate());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task moveTaskToNext(@NotNull Task task) {
+ long newOrderIdTaskState = this.getMaxOrderIdTaskState(
+ TaskState.NEXT,
+ task.getContext()
+ );
+ task.moveToNext();
+ task.setOrderIdTaskState(++newOrderIdTaskState);
+ task = taskRepository.saveAndFlush(task);
+ log.info("moved to next: " + task.outTaskstate());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task moveTaskToWaiting(@NotNull Task task) {
+ long newOrderIdTaskState = this.getMaxOrderIdTaskState(
+ TaskState.WAITING,
+ task.getContext()
+ );
+ task.moveToWaiting();
+ task.setOrderIdTaskState(++newOrderIdTaskState);
+ task = taskRepository.saveAndFlush(task);
+ log.info("moved to next: " + task.outTaskstate());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task moveTaskToSomeday(@NotNull Task task) {
+ long newOrderIdTaskState = this.getMaxOrderIdTaskState(
+ TaskState.SOMEDAY,
+ task.getContext()
+ );
+ task.moveToSomeday();
+ task.setOrderIdTaskState(++newOrderIdTaskState);
+ task = taskRepository.saveAndFlush(task);
+ log.info("moved to someday: " + task.outTaskstate());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task moveTaskToFocus(@NotNull Task task) {
+ long newOrderIdTaskState = this.getMaxOrderIdTaskState(
+ TaskState.FOCUS,
+ task.getContext()
+ );
+ task.moveToFocus();
+ task.setOrderIdTaskState(++newOrderIdTaskState);
+ task = taskRepository.saveAndFlush(task);
+ log.info("moved to focus: " + task.outTaskstate());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task moveTaskToCompleted(@NotNull Task task) {
+ long newOrderIdTaskState = this.getMaxOrderIdTaskState(
+ TaskState.COMPLETED,
+ task.getContext()
+ );
+ task.moveToCompletedTasks();
+ task.setOrderIdTaskState(++newOrderIdTaskState);
+ task = taskRepository.saveAndFlush(task);
+ log.debug("moved to completed: " + task.outTaskstate());
+ return task;
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public Task moveTaskToTrash(@NotNull Task task) {
+ long newOrderIdTaskState = this.getMaxOrderIdTaskState(
+ TaskState.TRASH,
+ task.getContext()
+ );
+ task.moveToTrash();
+ task.setOrderIdTaskState(++newOrderIdTaskState);
task = taskRepository.saveAndFlush(task);
- log.info("persisted: " + task.getId());
+ log.debug("moved to trash: " + task.outTaskstate());
return task;
}
}
diff --git a/src/main/java/org/woehlke/simpleworklist/task/TaskStateControllerService.java b/src/main/java/org/woehlke/simpleworklist/task/TaskStateControllerService.java
index fcae2756..f7686d9c 100644
--- a/src/main/java/org/woehlke/simpleworklist/task/TaskStateControllerService.java
+++ b/src/main/java/org/woehlke/simpleworklist/task/TaskStateControllerService.java
@@ -18,5 +18,5 @@ String getTaskStatePage(
Model model
);
- String transformTaskIntoProjectGet(Task task);
+ void moveTaskToTaskAndChangeTaskOrderInTaskstate(Task sourceTask, Task destinationTask);
}
diff --git a/src/main/java/org/woehlke/simpleworklist/task/TaskStateControllerServiceImpl.java b/src/main/java/org/woehlke/simpleworklist/task/TaskStateControllerServiceImpl.java
index deef5452..1b2698f6 100644
--- a/src/main/java/org/woehlke/simpleworklist/task/TaskStateControllerServiceImpl.java
+++ b/src/main/java/org/woehlke/simpleworklist/task/TaskStateControllerServiceImpl.java
@@ -5,12 +5,12 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.woehlke.simpleworklist.application.breadcrumb.Breadcrumb;
import org.woehlke.simpleworklist.application.breadcrumb.BreadcrumbService;
import org.woehlke.simpleworklist.context.Context;
-import org.woehlke.simpleworklist.project.Project;
-import org.woehlke.simpleworklist.project.ProjectService;
import org.woehlke.simpleworklist.user.session.UserSessionBean;
import javax.validation.constraints.NotNull;
@@ -22,17 +22,14 @@ public class TaskStateControllerServiceImpl implements TaskStateControllerServic
private final BreadcrumbService breadcrumbService;
private final TaskService taskService;
- private final ProjectService projectService;
@Autowired
public TaskStateControllerServiceImpl(
BreadcrumbService breadcrumbService,
- TaskService taskService,
- ProjectService projectService)
- {
+ TaskService taskService
+ ) {
this.breadcrumbService = breadcrumbService;
this.taskService = taskService;
- this.projectService = projectService;
}
@Override
@@ -56,23 +53,31 @@ public String getTaskStatePage(
}
@Override
- public String transformTaskIntoProjectGet(@NotNull Task task) {
- Project thisProject = new Project();
- thisProject.setName(task.getTitle());
- thisProject.setDescription(task.getText());
- thisProject.setUuid(task.getUuid());
- thisProject.setContext(task.getContext());
- if (task.getProject() != null) {
- long projectId = task.getProject().getId();
- Project parentProject = projectService.findByProjectId(projectId);
- thisProject.setParent(parentProject);
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
+ public void moveTaskToTaskAndChangeTaskOrderInTaskstate(@NotNull Task sourceTask, @NotNull Task destinationTask ) {
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" START: moveTaskToTask AndChangeTaskOrder In Taskstate ");
+ log.info(" "+sourceTask.getTaskState().name());
+ log.info(" "+sourceTask.outProject()+" -> "+destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
+ boolean notEqualsId = ! sourceTask.equalsById(destinationTask);
+ boolean notEquals = ! sourceTask.equalsByUniqueConstraint(destinationTask);
+ boolean sameContext = sourceTask.hasSameContextAs(destinationTask);
+ boolean sameTaskType = sourceTask.hasSameTaskTypetAs(destinationTask);
+ boolean go = notEqualsId && notEquals && sameContext && sameTaskType;
+ if ( go ) {
+ boolean srcIsBelowDestinationTask = sourceTask.isBelowByTaskState(destinationTask);
+ if (srcIsBelowDestinationTask) {
+ this.taskService.moveTasksDownByTaskState( sourceTask, destinationTask );
+ } else {
+ this.taskService.moveTasksUpByTaskState( sourceTask, destinationTask );
+ }
}
- thisProject = projectService.add(thisProject);
- task.setProject(null);
- task.moveToTrash();
- task.emptyTrash();
- taskService.updatedViaTaskstate(task);
- log.info("tried to transform Task " + task.getId() + " to new Project " + thisProject.getId());
- return thisProject.getUrl();
+ log.info("-------------------------------------------------------------------------------");
+ log.info(" DONE: moveTaskToTask AndChangeTaskOrder In Taskstate ");
+ log.info(" "+sourceTask.getTaskState().name());
+ log.info(" "+sourceTask.outProject()+" -> "+destinationTask.outProject());
+ log.info("-------------------------------------------------------------------------------");
}
+
}
diff --git a/src/main/java/org/woehlke/simpleworklist/task/TaskStateTabController.java b/src/main/java/org/woehlke/simpleworklist/task/TaskStateTabController.java
index b455adc7..ba2130f9 100644
--- a/src/main/java/org/woehlke/simpleworklist/task/TaskStateTabController.java
+++ b/src/main/java/org/woehlke/simpleworklist/task/TaskStateTabController.java
@@ -14,6 +14,7 @@
import org.woehlke.simpleworklist.context.Context;
import org.woehlke.simpleworklist.user.session.UserSessionBean;
+import javax.validation.constraints.NotNull;
import java.util.Locale;
@Slf4j
@@ -42,7 +43,7 @@ public final String inbox(
@RequestMapping(path = "/today", method = RequestMethod.GET)
public final String today(
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale,
Model model
) {
@@ -53,7 +54,7 @@ public final String today(
@RequestMapping(path = "/next", method = RequestMethod.GET)
public final String next(
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale,
Model model
) {
@@ -64,7 +65,7 @@ public final String next(
@RequestMapping(path = "/waiting", method = RequestMethod.GET)
public final String waiting(
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale,
Model model
) {
@@ -75,7 +76,7 @@ public final String waiting(
@RequestMapping(path = "/scheduled", method = RequestMethod.GET)
public final String scheduled(
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale,
Model model
) {
@@ -86,7 +87,7 @@ public final String scheduled(
@RequestMapping(path = "/someday", method = RequestMethod.GET)
public final String someday(
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale,
Model model
) {
@@ -97,7 +98,7 @@ public final String someday(
@RequestMapping(path = "/completed", method = RequestMethod.GET)
public final String completed(
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale,
Model model
) {
@@ -108,7 +109,7 @@ public final String completed(
@RequestMapping(path = "/trash", method = RequestMethod.GET)
public final String trash(
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale,
Model model
) {
@@ -119,7 +120,7 @@ public final String trash(
@RequestMapping(path = "/focus", method = RequestMethod.GET)
public final String focus(
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale,
Model model
) {
diff --git a/src/main/java/org/woehlke/simpleworklist/task/TaskStateTaskController.java b/src/main/java/org/woehlke/simpleworklist/task/TaskStateTaskController.java
index 7d1bd488..bf95ce6e 100644
--- a/src/main/java/org/woehlke/simpleworklist/task/TaskStateTaskController.java
+++ b/src/main/java/org/woehlke/simpleworklist/task/TaskStateTaskController.java
@@ -29,21 +29,22 @@
@RequestMapping(path = "/taskstate/task")
public class TaskStateTaskController extends AbstractController {
-
private final TaskStateControllerService taskStateControllerService;
private final TaskService taskService;
+ private final TaskProjektService taskProjektService;
@Autowired
public TaskStateTaskController(
- TaskStateControllerService taskStateControllerService, TaskService taskService
- ) {
+ TaskStateControllerService taskStateControllerService, TaskService taskService,
+ TaskProjektService taskProjektService) {
this.taskStateControllerService = taskStateControllerService;
this.taskService = taskService;
+ this.taskProjektService = taskProjektService;
}
@RequestMapping(path = "/add", method = RequestMethod.GET)
public final String addNewTaskToInboxGet(
- @ModelAttribute("userSession") UserSessionBean userSession,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Locale locale, Model model
) {
log.info("addNewTaskToInboxGet");
@@ -66,6 +67,7 @@ public final String addNewTaskToInboxGet(
model.addAttribute("mustChooseArea", mustChooseContext);
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("task", task);
+ model.addAttribute("userSession", userSession);
return "taskstate/task/add";
}
@@ -89,10 +91,12 @@ public final String addNewTaskToInboxPost(
model.addAttribute("mustChooseArea", mustChooseArea);
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("task", task);
+ model.addAttribute("userSession", userSession);
return "taskstate/task/add";
} else {
task = taskService.addToInbox(task);
log.info(task.toString());
+ model.addAttribute("userSession", userSession);
return "redirect:/taskstate/" + task.getTaskState().name().toLowerCase();
}
}
@@ -104,27 +108,24 @@ public final String editTaskGet(
Locale locale, Model model
) {
log.info("editTaskGet");
- if(task != null) {
- UserAccount userAccount = userAccountLoginSuccessService.retrieveCurrentUser();
- List contexts = contextService.getAllForUser(userAccount);
- Project thisProject;
- if (task.getContext() == null) {
- thisProject = new Project();
- thisProject.setId(0L);
- } else {
- thisProject = task.getProject();
- }
- Context thisContext = task.getContext();
- Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForTaskstate(task.getTaskState(),locale);
- model.addAttribute("breadcrumb", breadcrumb);
- model.addAttribute("thisProject", thisProject);
- model.addAttribute("thisContext", thisContext);
- model.addAttribute("task", task);
- model.addAttribute("contextss", contexts);
- return "taskstate/task/edit";
+ UserAccount userAccount = userAccountLoginSuccessService.retrieveCurrentUser();
+ List contexts = contextService.getAllForUser(userAccount);
+ Project thisProject;
+ if (task.getContext() == null) {
+ thisProject = new Project();
+ thisProject.setId(0L);
} else {
- return "redirect:/taskstate/inbox";
+ thisProject = task.getProject();
}
+ Context thisContext = task.getContext();
+ Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForTaskstate(task.getTaskState(),locale);
+ model.addAttribute("breadcrumb", breadcrumb);
+ model.addAttribute("thisProject", thisProject);
+ model.addAttribute("thisContext", thisContext);
+ model.addAttribute("task", task);
+ model.addAttribute("contexts", contexts);
+ model.addAttribute("userSession", userSession);
+ return "taskstate/task/edit";
}
@RequestMapping(path = "/{taskId}/edit", method = RequestMethod.POST)
@@ -171,6 +172,7 @@ public final String editTaskPost(
model.addAttribute("thisContext", thisContext);
model.addAttribute("task", task);
model.addAttribute("contexts", contexts);
+ model.addAttribute("userSession", userSession);
return "taskstate/task/edit";
} else {
task.unsetFocus();
@@ -178,6 +180,7 @@ public final String editTaskPost(
Task persistentTask = taskService.findOne(task.getId());
persistentTask.merge(task);
task = taskService.updatedViaTaskstate(persistentTask);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
}
@@ -189,170 +192,234 @@ public String changeTaskOrderId(
@NotNull @ModelAttribute("userSession") UserSessionBean userSession,
Model model
){
- userSession.setLastTaskState(sourceTask.getTaskState());
- model.addAttribute("userSession", userSession);
log.info("------------- changeTaskOrderId -------------");
log.info("source Task: "+sourceTask.toString());
log.info("---------------------------------------------");
log.info("destination Task: "+destinationTask.toString());
log.info("---------------------------------------------");
- taskService.moveOrderIdTaskState(sourceTask, destinationTask);
+ taskStateControllerService.moveTaskToTaskAndChangeTaskOrderInTaskstate(sourceTask, destinationTask);
+ userSession.setLastTaskState(sourceTask.getTaskState());
+ model.addAttribute("userSession", userSession);
return sourceTask.getTaskState().getUrl();
}
@RequestMapping(path = "/{taskId}/move/to/project/{projectId}", method = RequestMethod.GET)
public final String moveTaskToAnotherProject(
@NotNull @PathVariable("taskId") Task task,
- @NotNull @PathVariable("projectId") Project project
+ @NotNull @PathVariable("projectId") Project project,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task = taskService.moveTaskToAnotherProject(task,project);
+ userSession.setLastProjectId(project.getId());
+ model.addAttribute("userSession",userSession);
return project.getUrl();
}
@RequestMapping(path = "/{taskId}/move/to/taskstate/inbox", method = RequestMethod.GET)
- public final String moveTaskToInbox(@NotNull @PathVariable("taskId") Task task) {
+ public final String moveTaskToInbox(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("dragged and dropped "+task.getId()+" to inbox");
- task.moveToInbox();
- task = taskService.updatedViaTaskstate(task);
+ task = taskService.moveTaskToInbox(task);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
@RequestMapping(path = "/{taskId}/move/to/taskstate/today", method = RequestMethod.GET)
- public final String moveTaskToToday(@NotNull @PathVariable("taskId") Task task) {
+ public final String moveTaskToToday(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("dragged and dropped "+task.getId()+" to today");
- task.moveToToday();
- task = taskService.updatedViaTaskstate(task);
+ task = taskService.moveTaskToToday(task);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
@RequestMapping(path = "/{taskId}/move/to/taskstate/next", method = RequestMethod.GET)
- public final String moveTaskToNext(@NotNull @PathVariable("taskId") Task task) {
+ public final String moveTaskToNext(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("dragged and dropped "+task.getId()+" to next");
- task.moveToNext();
- task = taskService.updatedViaTaskstate(task);
+ task = taskService.moveTaskToNext(task);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
@RequestMapping(path = "/{taskId}/move/to/taskstate/waiting", method = RequestMethod.GET)
- public final String moveTaskToWaiting(@NotNull @PathVariable("taskId") Task task) {
+ public final String moveTaskToWaiting(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("dragged and dropped "+task.getId()+" to waiting");
- task.moveToWaiting();
- task = taskService.updatedViaTaskstate(task);
+ task = taskService.moveTaskToWaiting(task);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
@RequestMapping(path = "/{taskId}/move/to/taskstate/someday", method = RequestMethod.GET)
- public final String moveTaskToSomeday(@NotNull @PathVariable("taskId") Task task) {
+ public final String moveTaskToSomeday(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("dragged and dropped "+task.getId()+" to someday");
- task.moveToSomeday();
- task = taskService.updatedViaTaskstate(task);
+ task = taskService.moveTaskToSomeday(task);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
@RequestMapping(path = "/{taskId}/move/to/taskstate/focus", method = RequestMethod.GET)
- public final String moveTaskToFocus(@NotNull @PathVariable("taskId") Task task) {
+ public final String moveTaskToFocus(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("dragged and dropped "+task.getId()+" to focus");
- task.moveToFocus();
- task = taskService.updatedViaTaskstate(task);
+ task = taskService.moveTaskToFocus(task);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
@RequestMapping(path = "/{taskId}/move/to/taskstate/completed", method = RequestMethod.GET)
- public final String moveTaskToCompleted(@NotNull @PathVariable("taskId") Task task) {
+ public final String moveTaskToCompleted(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("dragged and dropped "+task.getId()+" to completed");
- task.moveToCompletedTasks();
- task = taskService.updatedViaTaskstate(task);
+ task = taskService.moveTaskToCompleted(task);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
- @RequestMapping(path = "/{taskId}/move/to/trash", method = RequestMethod.GET)
- public final String moveTaskToTrash(@NotNull @PathVariable("taskId") Task task) {
+ @RequestMapping(path = "/{taskId}/move/to/taskstate/trash", method = RequestMethod.GET)
+ public final String moveTaskToTrash(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("dragged and dropped "+task.getId()+" to trash");
- task.moveToTrash();
- task = taskService.updatedViaTaskstate(task);
+ task = taskService.moveTaskToTrash(task);
+ model.addAttribute("userSession", userSession);
return task.getTaskState().getUrl();
}
@RequestMapping(path = "/completed/move/to/trash", method = RequestMethod.GET)
public final String moveAllCompletedToTrash(
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
Context context = super.getContext(userSession);
taskService.moveAllCompletedToTrash(context);
+ model.addAttribute("userSession", userSession);
return "redirect:/taskstate/trash";
}
@RequestMapping(path = "/trash/empty", method = RequestMethod.GET)
public final String emptyTrash(
- @ModelAttribute("userSession") UserSessionBean userSession
+ @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
Context context = super.getContext(userSession);
taskService.emptyTrash(context);
+ model.addAttribute("userSession", userSession);
return "redirect:/taskstate/trash";
}
@RequestMapping(path = "/{taskId}/delete", method = RequestMethod.GET)
- public final String deleteTaskGet(@NotNull @PathVariable("taskId") Task task) {
+ public final String deleteTaskGet(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("deleteTaskGet");
- if(task!= null){
- task.delete();
- taskService.updatedViaTaskstate(task);
- }
+ task.delete();
+ taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return "redirect:/taskstate/trash";
}
@RequestMapping(path = "/{taskId}/undelete", method = RequestMethod.GET)
- public final String undeleteTaskGet(@NotNull @PathVariable("taskId") Task task) {
+ public final String undeleteTaskGet(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("undeleteTaskGet");
task.undelete();
taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return "redirect:/taskstate/completed";
}
@RequestMapping(path = "/{taskId}/transform", method = RequestMethod.GET)
- public final String transformTaskIntoProjectGet(@NotNull @PathVariable("taskId") Task task) {
+ public final String transformTaskIntoProjectGet(
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
+ ) {
log.info("transformTaskIntoProjectGet");
- return taskStateControllerService.transformTaskIntoProjectGet(task);
+ return taskProjektService.transformTaskIntoProjectGet(task, userSession, model);
}
@RequestMapping(path = "/{taskId}/complete", method = RequestMethod.GET)
public final String setDoneTaskGet(
- @NotNull @PathVariable("taskId") Task task
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task.complete();
long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(TaskState.COMPLETED,task.getContext());
task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return task.getUrl();
}
@RequestMapping(path = "/{taskId}/incomplete", method = RequestMethod.GET)
public final String unsetDoneTaskGet(
- @NotNull @PathVariable("taskId") Task task
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
) {
task.incomplete();
long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
task.setOrderIdTaskState(++maxOrderIdTaskState);
task = taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return task.getUrl();
}
@RequestMapping(path = "/{taskId}/setfocus", method = RequestMethod.GET)
public final String setFocusGet(
- @NotNull @PathVariable("taskId") Task task
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
){
task.setFocus();
task = taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return task.getUrl();
}
@RequestMapping(path = "/{taskId}/unsetfocus", method = RequestMethod.GET)
public final String unsetFocusGet(
- @NotNull @PathVariable("taskId") Task task
+ @NotNull @PathVariable("taskId") Task task,
+ @NotNull @ModelAttribute("userSession") UserSessionBean userSession,
+ Model model
){
task.unsetFocus();
task = taskService.updatedViaTaskstate(task);
+ model.addAttribute("userSession", userSession);
return task.getUrl();
}
}
diff --git a/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageController.java b/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageController.java
index 40951615..0dc63ec4 100644
--- a/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageController.java
+++ b/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageController.java
@@ -51,6 +51,7 @@ public final String getLastMessagesBetweenCurrentAndOtherUser(
model.addAttribute("refreshMessages",true);
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForMessagesBetweenCurrentAndOtherUser(locale);
model.addAttribute("breadcrumb",breadcrumb);
+ model.addAttribute("userSession", userSession);
return "user/messages/all";
}
@@ -78,9 +79,11 @@ public final String sendNewMessageToOtherUser(
Page user2UserMessagePage = user2UserMessageService.readAllMessagesBetweenCurrentAndOtherUser(thisUser,otherUser,request);
model.addAttribute("otherUser", otherUser);
model.addAttribute("user2UserMessagePage", user2UserMessagePage);
+ model.addAttribute("userSession", userSession);
return "user/messages/all";
} else {
user2UserMessageService.sendNewUserMessage(thisUser, otherUser, user2UserMessageFormBean);
+ model.addAttribute("userSession", userSession);
return "redirect:/user/messages/" + otherUser.getId();
}
}
diff --git a/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageRepository.java b/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageRepository.java
index 11e9a508..eece531a 100644
--- a/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageRepository.java
+++ b/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageRepository.java
@@ -16,7 +16,10 @@
@Repository
public interface User2UserMessageRepository extends JpaRepository {
- String JQL = "select m from User2UserMessage m where (m.sender = :thisUser and m.receiver = :otherUser) or (m.sender = :otherUser and m.receiver = :thisUser)";
+ //TODO: #247 move the JQL Query-String to Entity as Prepared Statement
+ String JQL = "select m from User2UserMessage m "
+ + "where (m.sender = :thisUser and m.receiver = :otherUser) "
+ + "or (m.sender = :otherUser and m.receiver = :thisUser)";
@Query(JQL)
Page findAllMessagesBetweenCurrentAndOtherUser(
@@ -25,12 +28,24 @@ Page findAllMessagesBetweenCurrentAndOtherUser(
Pageable request
);
+ //TODO: #246 change List to Page
+ @Deprecated
List findByReceiverAndReadByReceiver(
UserAccount receiver,
boolean readByReceiver
);
+ Page findByReceiverAndReadByReceiver(
+ UserAccount receiver,
+ boolean readByReceiver,
+ Pageable request
+ );
+ //TODO: #246 change List to Page
+ @Deprecated
List findBySenderAndReceiverAndReadByReceiver(
UserAccount sender, UserAccount receiver, boolean readByReceiver
);
+ Page findBySenderAndReceiverAndReadByReceiver(
+ UserAccount sender, UserAccount receiver, boolean readByReceiver, Pageable request
+ );
}
diff --git a/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageService.java b/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageService.java
index 81c24217..b14848d6 100644
--- a/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageService.java
+++ b/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageService.java
@@ -9,10 +9,16 @@
*/
public interface User2UserMessageService {
- void sendNewUserMessage(UserAccount thisUser, UserAccount otherUser, User2UserMessageFormBean user2UserMessageFormBean);
+ User2UserMessage sendNewUserMessage(
+ UserAccount thisUser,
+ UserAccount otherUser,
+ User2UserMessageFormBean user2UserMessageFormBean
+ );
int getNumberOfNewIncomingMessagesForUser(UserAccount user);
- Page readAllMessagesBetweenCurrentAndOtherUser(UserAccount receiver, UserAccount sender, Pageable request);
+ Page readAllMessagesBetweenCurrentAndOtherUser(
+ UserAccount receiver, UserAccount sender, Pageable request
+ );
}
diff --git a/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageServiceImpl.java b/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageServiceImpl.java
index 52a69d28..22c78aba 100644
--- a/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageServiceImpl.java
+++ b/src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageServiceImpl.java
@@ -28,7 +28,7 @@ public User2UserMessageServiceImpl(User2UserMessageRepository userMessageReposit
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
- public void sendNewUserMessage(
+ public User2UserMessage sendNewUserMessage(
UserAccount thisUser,
UserAccount otherUser,
User2UserMessageFormBean user2UserMessageFormBean
@@ -39,7 +39,7 @@ public void sendNewUserMessage(
m.setReceiver(otherUser);
m.setReadByReceiver(false);
m.setMessageText(user2UserMessageFormBean.getMessageText());
- userMessageRepository.saveAndFlush(m);
+ return userMessageRepository.saveAndFlush(m);
}
@Override
@@ -48,6 +48,7 @@ public int getNumberOfNewIncomingMessagesForUser(
) {
log.info("getNumberOfNewIncomingMessagesForUser");
boolean readByReceiver = false;
+ //TODO: #246 change List to Page
List user2UserMessageList =
userMessageRepository.findByReceiverAndReadByReceiver(receiver, readByReceiver);
return user2UserMessageList.size();
diff --git a/src/main/java/org/woehlke/simpleworklist/user/register/UserRegistrationController.java b/src/main/java/org/woehlke/simpleworklist/user/register/UserRegistrationController.java
index c2f51c1b..3d38f916 100644
--- a/src/main/java/org/woehlke/simpleworklist/user/register/UserRegistrationController.java
+++ b/src/main/java/org/woehlke/simpleworklist/user/register/UserRegistrationController.java
@@ -32,7 +32,7 @@ public UserRegistrationController(UserAccountService userAccountService, UserReg
* Register as new user by entering the email-address which is
* unique and the login identifier.
*
- * @param model
+ * @param model Model
* @return Formular for entering Email-Address for Registration
*/
@RequestMapping(path = "", method = RequestMethod.GET)
@@ -46,9 +46,9 @@ public final String registerGet(Model model) {
/**
* Register new User: Store the Request and send Email for Verification.
*
- * @param userRegistrationForm
- * @param result
- * @param model
+ * @param userRegistrationForm UserRegistrationForm
+ * @param result BindingResult
+ * @param model Model
* @return info page at success or return to form with error messages.
*/
@RequestMapping(path = "", method = RequestMethod.POST)
@@ -88,8 +88,8 @@ public final String registerPost(
/**
* Register as new user: The URL in the Verification Email clicked by User.
*
- * @param confirmId
- * @param model
+ * @param confirmId String
+ * @param model Model
* @return Formular for Entering Account Task or Error Messages.
*/
@RequestMapping(path = "/confirm/{confirmId}", method = RequestMethod.GET)
@@ -114,10 +114,10 @@ public final String registerConfirmGet(
/**
* Saving Account Task from Formular and forward to login page.
*
- * @param userAccountForm
- * @param result
- * @param confirmId
- * @param model
+ * @param userAccountForm UserAccountForm
+ * @param result BindingResult
+ * @param confirmId String
+ * @param model Model
* @return login page at success or page with error messages.
*/
@RequestMapping(path = "/confirm/{confirmId}", method = RequestMethod.POST)
diff --git a/src/main/java/org/woehlke/simpleworklist/user/selfservice/UserSelfserviceController.java b/src/main/java/org/woehlke/simpleworklist/user/selfservice/UserSelfserviceController.java
index c6039be6..c442fc3a 100644
--- a/src/main/java/org/woehlke/simpleworklist/user/selfservice/UserSelfserviceController.java
+++ b/src/main/java/org/woehlke/simpleworklist/user/selfservice/UserSelfserviceController.java
@@ -66,6 +66,7 @@ public String userProfileAndMenu(
model.addAttribute("usersToNewMessages", usersToNewMessages);
model.addAttribute("users", users);
model.addAttribute("thisUser", user);
+ model.addAttribute("userSession", userSession);
return "user/selfservice/profile";
}
@@ -83,6 +84,7 @@ public String userNameForm(
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("username", bean);
model.addAttribute("thisUser", user);
+ model.addAttribute("userSession", userSession);
return "user/selfservice/name";
}
@@ -102,10 +104,12 @@ public String userNameStore(
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("username", username);
model.addAttribute("thisUser", user);
+ model.addAttribute("userSession", userSession);
return "user/selfservice/name";
} else {
user.setUserFullname(username.getUserFullname());
userAccountService.saveAndFlush(user);
+ model.addAttribute("userSession", userSession);
return "redirect:/user/selfservice/profile";
}
}
@@ -124,6 +128,7 @@ public String userPasswordForm(
model.addAttribute("breadcrumb", breadcrumb);
model.addAttribute("thisUser", user);
model.addAttribute("userChangePasswordForm", userChangePasswordForm);
+ model.addAttribute("userSession", userSession);
return "user/selfservice/password";
}
@@ -149,6 +154,7 @@ public String userPasswordStore(
for(ObjectError error : result.getAllErrors()){
log.info(error.toString());
}
+ model.addAttribute("userSession", userSession);
return "user/selfservice/password";
} else {
if(! userChangePasswordForm.passwordsAreTheSame()){
@@ -161,6 +167,7 @@ public String userPasswordStore(
for(ObjectError error : result.getAllErrors()){
log.info(error.toString());
}
+ model.addAttribute("userSession", userSession);
return "user/selfservice/password";
}
if(!userAccountAccessService.confirmUserByLoginAndPassword(
@@ -175,10 +182,12 @@ public String userPasswordStore(
for(ObjectError error : result.getAllErrors()){
log.info(error.toString());
}
+ model.addAttribute("userSession", userSession);
return "user/selfservice/password";
}
log.info("OK");
userAccountAccessService.changeUsersPassword(userChangePasswordForm,user);
+ model.addAttribute("userSession", userSession);
return "redirect:/user/selfservice/profile";
}
}
@@ -200,6 +209,7 @@ public String userContextsForm(
model.addAttribute("contexts", contexts);
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForUserContexts(locale);
model.addAttribute("breadcrumb", breadcrumb);
+ model.addAttribute("userSession", userSession);
return "user/selfservice/context/all";
}
@@ -223,6 +233,7 @@ public String userContextsSave(
for(ObjectError error : result.getAllErrors()){
log.info(error.toString());
}
+ model.addAttribute("userSession", userSession);
return "user/selfservice/context/all";
} else {
if(user.getId() == thisUser.getId()){
@@ -231,6 +242,7 @@ public String userContextsSave(
userSession.setLastContextId(thisUser.getDefaultContext().getId());
model.addAttribute("userSession", userSession);
}
+ model.addAttribute("userSession", userSession);
return "redirect:/user/selfservice/contexts";
}
}
@@ -249,6 +261,7 @@ public String userNewContextGet(
model.addAttribute("newContext", newContext);
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForUserContextAdd(locale);
model.addAttribute("breadcrumb", breadcrumb);
+ model.addAttribute("userSession", userSession);
return "user/selfservice/context/add";
}
@@ -271,9 +284,11 @@ public String userNewContextPost(
for(ObjectError error : result.getAllErrors()){
log.info(error.toString());
}
+ model.addAttribute("userSession", userSession);
return "user/selfservice/context/add";
} else {
contextService.createNewContext(newContext,user);
+ model.addAttribute("userSession", userSession);
return "redirect:/user/selfservice/contexts";
}
}
@@ -295,6 +310,7 @@ public String userContextEditGet(
model.addAttribute("editContext", editContext);
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForUserContextEdit(locale, context);
model.addAttribute("breadcrumb", breadcrumb);
+ model.addAttribute("userSession", userSession);
return "user/selfservice/context/edit";
}
@@ -315,11 +331,13 @@ public String userContextEditPost(
for(ObjectError error : result.getAllErrors()){
log.info(error.toString());
}
+ model.addAttribute("userSession", userSession);
return "user/selfservice/context/edit";
} else {
context.setNameDe(editContext.getNameDe());
context.setNameEn(editContext.getNameEn());
contextService.updateContext(context);
+ model.addAttribute("userSession", userSession);
return "redirect:/user/selfservice/contexts";
}
}
@@ -355,6 +373,7 @@ public String userDeleteContextGet(
}
}
}
+ model.addAttribute("userSession", userSession);
return "redirect:/user/selfservice/contexts";
}
@@ -371,6 +390,7 @@ public String userLanguageGet(
model.addAttribute("userChangeLanguageForm",new UserChangeLanguageForm(user.getDefaultLanguage()));
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForUserChangeLanguage(locale);
model.addAttribute("breadcrumb", breadcrumb);
+ model.addAttribute("userSession", userSession);
return "user/selfservice/language";
}
@@ -391,6 +411,7 @@ public String userLanguagePost(
for(ObjectError error : result.getAllErrors()){
log.info(error.toString());
}
+ model.addAttribute("userSession", userSession);
return "user/selfservice/language";
} else {
user.setDefaultLanguage(userChangeLanguageForm.getDefaultLanguage());
@@ -400,6 +421,7 @@ public String userLanguagePost(
case DE: returnUrl="redirect:/user/selfservice/profile?lang=de"; break;
default: returnUrl="redirect:/user/selfservice/profile?lang=en"; break;
}
+ model.addAttribute("userSession", userSession);
return returnUrl;
}
}
diff --git a/src/main/resources/templates/layout/page.html b/src/main/resources/templates/layout/page.html
index f8f8cae0..192a20bd 100644
--- a/src/main/resources/templates/layout/page.html
+++ b/src/main/resources/templates/layout/page.html
@@ -90,56 +90,56 @@
function drop2inbox(ev) {
ev.preventDefault();
var taskId = ev.dataTransfer.getData("task").split("_")[1];
- var myUrl = '[(@{/task/move/})]'+taskId+'/to/inbox';
+ var myUrl = '[(@{/taskstate/task/})]'+taskId+'/move/to/taskstate/inbox';
window.location.replace(myUrl);
}
function drop2today(ev) {
ev.preventDefault();
var taskId = ev.dataTransfer.getData("task").split("_")[1];
- var myUrl = '[(@{/task/move/})]'+taskId+'/to/today';
+ var myUrl = '[(@{/taskstate/task/})]'+taskId+'/move/to/taskstate/today';
window.location.replace(myUrl);
}
function drop2next(ev) {
ev.preventDefault();
var taskId = ev.dataTransfer.getData("task").split("_")[1];
- var myUrl = '[(@{/task/move/})]'+taskId+'/to/next';
+ var myUrl = '[(@{/taskstate/task/})]'+taskId+'/move/to/taskstate/next';
window.location.replace(myUrl);
}
function drop2waiting(ev) {
ev.preventDefault();
var taskId = ev.dataTransfer.getData("task").split("_")[1];
- var myUrl = '[(@{/task/move/})]'+taskId+'/to/waiting';
+ var myUrl = '[(@{/taskstate/task/})]'+taskId+'/move/to/taskstate/waiting';
window.location.replace(myUrl);
}
function drop2someday(ev) {
ev.preventDefault();
var taskId = ev.dataTransfer.getData("task").split("_")[1];
- var myUrl = '[(@{/task/move/})]'+taskId+'/to/someday';
+ var myUrl = '[(@{/taskstate/task/})]'+taskId+'/move/to/taskstate/someday';
window.location.replace(myUrl);
}
function drop2focus(ev) {
ev.preventDefault();
var taskId = ev.dataTransfer.getData("task").split("_")[1];
- var myUrl = '[(@{/task/move/})]'+taskId+'/to/focus';
+ var myUrl = '[(@{/taskstate/task/})]'+taskId+'/move/to/taskstate/focus';
window.location.replace(myUrl);
}
function drop2completed(ev) {
ev.preventDefault();
var taskId = ev.dataTransfer.getData("task").split("_")[1];
- var myUrl = '[(@{/task/move/})]'+taskId+'/to/completed';
+ var myUrl = '[(@{/taskstate/task/})]'+taskId+'/move/to/completed';
window.location.replace(myUrl);
}
function drop2trash(ev) {
ev.preventDefault();
var taskId = ev.dataTransfer.getData("task").split("_")[1];
- var myUrl = '[(@{/task/move/})]'+taskId+'/to/trash';
+ var myUrl = '[(@{/taskstate/task/})]'+taskId+'/move/to/taskstate/trash';
window.location.replace(myUrl);
}
@@ -150,10 +150,10 @@
var targetProjectIdInfo = ev.target.id;
var targetProjectId = targetProjectIdInfo.split("_")[1];
if(srcType == 'task') {
- var myUrl = '[(@{/task/move/})]' + srcId + '/to/project/' + targetProjectId;
+ var myUrl = '[(@{/taskstate/task/})]' + srcId + '/move/to/project/' + targetProjectId;
window.location.replace(myUrl);
} else if(srcType == 'project') {
- var myUrl = '[(@{/project/})]' + srcId + '/move/to/' + targetProjectId;
+ var myUrl = '[(@{/project/})]' + srcId + '/project/move/to/project/' + targetProjectId;
window.location.replace(myUrl);
}
}
@@ -163,16 +163,17 @@
var myUrl = '';
var requestPath = '[(@{{url}(url=${#request.getRequestURI()})})]';
var requestPathFirst = requestPath.split("/")[1];
+ var requestPathSecond = requestPath.split("/")[2];
var srcType = ev.dataTransfer.getData("task").split("_")[0];
var sourceTaskId = ev.dataTransfer.getData("task").split("_")[1];
var destinationTaskIdInfo = ev.target.id;
var destinationTaskId = destinationTaskIdInfo.split("_")[1];
if(srcType === 'task') {
if(requestPathFirst === 'taskstate'){
- myUrl = '[(@{/taskstate/})]' + sourceTaskId + '/changeorderto/' + destinationTaskId;
+ myUrl = '[(@{/taskstate/task/})]' + sourceTaskId + '/changeorderto/' + destinationTaskId;
window.location.replace(myUrl);
} else if(requestPathFirst === 'project'){
- myUrl = '[(@{/project/task/})]' + sourceTaskId + '/changeorderto/' + destinationTaskId;
+ myUrl = '[(@{/project/})]' + requestPathSecond + "/task/"+ sourceTaskId + '/changeorderto/' + destinationTaskId;
window.location.replace(myUrl);
}
}