Skip to content

Commit 1e71929

Browse files
committed
work in progres
1 parent d31ddf2 commit 1e71929

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/main/java/org/woehlke/simpleworklist/project/ProjectController.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public final String projectAddProjectGet(
155155
log.info("private addNewProjectGet (GET) projectId="+projectId);
156156
Context context = super.getContext(userSession);
157157
projectControllerService.addNewProject(projectId, userSession, context, locale, model);
158-
return "project/id/add/project";
158+
return "project/id/project/add";
159159
}
160160

161161
@RequestMapping(path = "/project/add", method = {RequestMethod.POST})
@@ -175,7 +175,7 @@ public final String projectAddProjectPost(
175175
result,
176176
locale,
177177
model ,
178-
"/add/project"
178+
"project/id/project/add"
179179
);
180180
}
181181

@@ -191,8 +191,8 @@ public final String projectMoveToProjectGet(
191191
userSession.setLastProjectId(thisProject.getId());
192192
model.addAttribute("userSession",userSession);
193193
Project targetProject = projectService.findByProjectId(targetProjectId);
194-
projectService.moveProjectToAnotherProject(thisProject, targetProject );
195-
return "redirect:/project/" + thisProject.getId();
194+
thisProject = projectService.moveProjectToAnotherProject(thisProject, targetProject );
195+
return thisProject.getUrl();
196196
}
197197

198198
@RequestMapping(path = "/edit", method = RequestMethod.GET)
@@ -225,29 +225,32 @@ public final String projectEditPost(
225225
Context context = super.getContext(userSession);
226226
UserAccount thisUser = context.getUserAccount();
227227
model.addAttribute("userSession", userSession);
228+
Project thisProject;
228229
if (result.hasErrors()) {
229230
for (ObjectError e : result.getAllErrors()) {
230231
log.info(e.toString());
231232
}
232-
Project thisProject = projectService.findByProjectId(projectId);
233+
thisProject = projectService.findByProjectId(projectId);
233234
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForShowOneProject(thisProject,locale);
234235
model.addAttribute("breadcrumb", breadcrumb);
235236
return "project/id/edit";
236237
} else {
237-
Project thisProject = projectService.findByProjectId(project.getId());
238+
thisProject = projectService.findByProjectId(project.getId());
238239
thisProject.setName(project.getName());
239240
thisProject.setDescription(project.getDescription());
240241
Context newContext = project.getContext();
241242
boolean contextChanged = (newContext.getId().longValue() != thisProject.getContext().getId().longValue());
242243
if(contextChanged){
243244
long newContextId = newContext.getId();
244245
newContext = contextService.findByIdAndUserAccount(newContextId, thisUser);
245-
projectService.moveProjectToAnotherContext(thisProject, newContext);
246-
model.addAttribute("userSession", new UserSessionBean(newContextId));
246+
thisProject = projectService.moveProjectToAnotherContext(thisProject, newContext);
247+
userSession.setLastContextId(newContextId);
247248
} else {
248-
projectService.saveAndFlush(thisProject);
249+
thisProject = projectService.saveAndFlush(thisProject);
249250
}
250-
return "redirect:/project/" + projectId;
251+
userSession.setLastProjectId(thisProject.getId());
252+
model.addAttribute("userSession", userSession);
253+
return thisProject.getUrl();
251254
}
252255
}
253256

src/main/java/org/woehlke/simpleworklist/project/ProjectService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface ProjectService {
1717
//@Deprecated
1818
//List<Project> findAllProjectsByUserAccount(UserAccount user);
1919

20-
void moveProjectToAnotherProject(Project thisProject, Project targetProject);
20+
Project moveProjectToAnotherProject(Project thisProject, Project targetProject);
2121

2222
Project findByProjectId(long categoryId);
2323

src/main/java/org/woehlke/simpleworklist/project/ProjectServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private List<Project> getAllChildrenOfProject(Project thisProject) {
121121

122122
@Override
123123
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
124-
public void moveProjectToAnotherProject(
124+
public Project moveProjectToAnotherProject(
125125
Project thisProject,
126126
Project targetProject
127127
) {
@@ -132,6 +132,6 @@ public void moveProjectToAnotherProject(
132132
projectRepository.saveAndFlush(oldParent);
133133
}
134134
thisProject.setParent(targetProject);
135-
projectRepository.saveAndFlush(thisProject);
135+
return projectRepository.saveAndFlush(thisProject);
136136
}
137137
}

0 commit comments

Comments
 (0)