diff --git a/datavault-common/src/main/java/org/datavaultplatform/common/model/VaultReview.java b/datavault-common/src/main/java/org/datavaultplatform/common/model/VaultReview.java index 9596ca0ce..7ba95357b 100644 --- a/datavault-common/src/main/java/org/datavaultplatform/common/model/VaultReview.java +++ b/datavault-common/src/main/java/org/datavaultplatform/common/model/VaultReview.java @@ -74,7 +74,9 @@ public class VaultReview { @Column(name = "comment", nullable = true, columnDefinition = "TEXT") private String comment; + public VaultReview() { + } public String getId() { return id; diff --git a/datavault-webapp/src/main/java/org/datavaultplatform/webapp/controllers/VaultsController.java b/datavault-webapp/src/main/java/org/datavaultplatform/webapp/controllers/VaultsController.java index f17c04a8b..bdf212e55 100644 --- a/datavault-webapp/src/main/java/org/datavaultplatform/webapp/controllers/VaultsController.java +++ b/datavault-webapp/src/main/java/org/datavaultplatform/webapp/controllers/VaultsController.java @@ -252,11 +252,10 @@ public String getVault(ModelMap model, @PathVariable("vaultid") String vaultID, VaultReview currentReview = restService.getVaultReview(reviewInfo.getVaultReviewId()); VaultReviewModel vaultReviewModel = new VaultReviewModel(currentReview); - List depositReviewModels = new ArrayList<>(); for (int i = 0; i < reviewInfo.getDepositIds().size(); i++) { DepositInfo depositInfo = restService.getDeposit(reviewInfo.getDepositIds().get(i)); - DepositReview depositReview = restService.getDepositReview(reviewInfo.getDepositReviewIds().get(i)); + DepositReview depositReview = restService.getDepositReview(reviewInfo.getDepositIds().get(i)); DepositReviewModel drm = new DepositReviewModel(); // Set DepositReview stuff diff --git a/datavault-webapp/src/main/java/org/datavaultplatform/webapp/controllers/admin/AdminReviewsController.java b/datavault-webapp/src/main/java/org/datavaultplatform/webapp/controllers/admin/AdminReviewsController.java index 558cd7c06..b77584c11 100644 --- a/datavault-webapp/src/main/java/org/datavaultplatform/webapp/controllers/admin/AdminReviewsController.java +++ b/datavault-webapp/src/main/java/org/datavaultplatform/webapp/controllers/admin/AdminReviewsController.java @@ -120,13 +120,15 @@ public String showReview(ModelMap model, } + // Process the completed review page - @PostMapping("/admin/vaults/{vaultid}/reviews/{reviewid}") - public String processReview(@RequestBody VaultReviewModel vaultReviewModel, + @RequestMapping(value = "/admin/vaults/{vaultid}/reviews/{reviewid}", method = RequestMethod.POST) + public String processReview(@ModelAttribute VaultReviewModel vaultReviewModel, + ModelMap model, + RedirectAttributes redirectAttributes, @PathVariable("vaultid") String vaultID, @PathVariable("reviewid") String reviewID, - @RequestParam String action, - RedirectAttributes redirectAttributes ) { + @RequestParam String action) { // Note - The ModelAttributes made available here are not the same objects as those passed to the View, // they only contain the values entered on screen. With that in mind, fetch the original objects again and @@ -175,7 +177,7 @@ public String processReview(@RequestBody VaultReviewModel vaultReviewModel, if (vaultReviewModel.getDepositReviewModels() != null) { for (DepositReviewModel drm : vaultReviewModel.getDepositReviewModels()) { - DepositReview originalDepositReview = restService.getDepositReview(drm.getDepositReviewId()); + DepositReview originalDepositReview = restService.getDepositReview(drm.getDepositId()); originalDepositReview.setDeleteStatus(drm.getDeleteStatus()); originalDepositReview.setComment(drm.getComment()); diff --git a/datavault-webapp/src/main/webapp/WEB-INF/templates/admin/reviews/create.html b/datavault-webapp/src/main/webapp/WEB-INF/templates/admin/reviews/create.html index f4d72d7f3..369313483 100644 --- a/datavault-webapp/src/main/webapp/WEB-INF/templates/admin/reviews/create.html +++ b/datavault-webapp/src/main/webapp/WEB-INF/templates/admin/reviews/create.html @@ -8,7 +8,7 @@ diff --git a/datavault-webapp/src/test/java/org/datavaultplatform/webapp/controllers/admin/AdminReviewsControllerTest.java b/datavault-webapp/src/test/java/org/datavaultplatform/webapp/controllers/admin/AdminReviewsControllerTest.java index 3c05fa8db..f259fb190 100644 --- a/datavault-webapp/src/test/java/org/datavaultplatform/webapp/controllers/admin/AdminReviewsControllerTest.java +++ b/datavault-webapp/src/test/java/org/datavaultplatform/webapp/controllers/admin/AdminReviewsControllerTest.java @@ -349,7 +349,7 @@ void testProcessReview_ActionCancel() throws Exception { RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID) .queryParam("action", "Cancel") - .content(toJson(mVaultReviewModel)) + .flashAttr("VaultReviewModel", mVaultReviewModel) .contentType(MediaType.APPLICATION_JSON) .with(csrf()); // Act @@ -368,12 +368,12 @@ void testProcessReview_ActionSave() throws Exception { RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID) .queryParam("action", "Save") - .content(toJson(mVaultReviewModel)) + .flashAttr("vaultReviewModel", mVaultReviewModel) .contentType(MediaType.APPLICATION_JSON) .with(csrf()); // Act MvcResult mvcResult = mockMvc.perform(requestBuilder).andReturn(); - //Assert + // Assert assertThat(mvcResult.getModelAndView().getViewName()).isEqualTo("redirect:/admin/reviews"); verify(mRestService).getVaultReview(TEST_VAULT_REVIEW_ID); @@ -396,7 +396,7 @@ void testProcessReview_Submit_WithNoReviewDate_AndNoRetainedDeposits() throws Ex RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID) .queryParam("action", "Submit") - .content(toJson(mVaultReviewModel)) + .flashAttr("vaultReviewModel", mVaultReviewModel) .contentType(MediaType.APPLICATION_JSON) .with(csrf()); // Act @@ -421,7 +421,7 @@ void testProcessReview_Submit_WithNoRetainedDeposits_AndReviewDateNotNull() thro RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID) .queryParam("action", "Submit") - .content(toJson(mVaultReviewModel)) + .flashAttr("vaultReviewModel", mVaultReviewModel) .contentType(MediaType.APPLICATION_JSON) .with(csrf()); // Act @@ -451,7 +451,7 @@ void testProcessReview_Submit_WithNoReviewDate_AndRetainedDeposits_ThenError() t RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID) .queryParam("action", "Submit") - .content(toJson(mVaultReviewModel)) + .flashAttr("vaultReviewModel", mVaultReviewModel) .contentType(MediaType.APPLICATION_JSON) .with(csrf()); // Act