From e794918097a864eb29591ba74c8f61887bcb26a3 Mon Sep 17 00:00:00 2001 From: nivetha <nivetha.mariappan@tarento.com> Date: Tue, 5 Apr 2022 14:46:46 +0530 Subject: [PATCH] status log for newly created application --- .../controllers/FormsController.java | 17 ++++++++++------- .../service/impl/FormsServiceImpl.java | 7 +++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/tarento/formservice/controllers/FormsController.java b/src/main/java/com/tarento/formservice/controllers/FormsController.java index 5cccc68..2e6b926 100644 --- a/src/main/java/com/tarento/formservice/controllers/FormsController.java +++ b/src/main/java/com/tarento/formservice/controllers/FormsController.java @@ -123,7 +123,9 @@ public class FormsController { incomingData.setUpdatedBy(userInfo.getEmailId()); } } - if (formsService.saveFormSubmitv1(incomingData, userInfo, null)) { + if (formsService.saveFormSubmitv1(incomingData, userInfo, + StringUtils.isBlank(incomingData.getApplicationId()) ? Status.NEW.name() + : Status.REVIEW.name())) { return ResponseGenerator.successResponse(Boolean.TRUE); } } catch (Exception e) { @@ -440,24 +442,24 @@ public class FormsController { } return ResponseGenerator.failureResponse(); } - + @PostMapping(value = PathRoutes.FormServiceApi.SAVE_PLAIN_FORM) public String savePlainForm(@RequestBody IncomingData incomingData) throws IOException { try { - if(incomingData != null) { + if (incomingData != null) { incomingData.setFormId(9999l); if (formsService.savePlainForm(incomingData)) { return ResponseGenerator.successResponse(Boolean.TRUE); } } - + } catch (Exception e) { logger.error(String.format(Constants.EXCEPTION, "savePlainForm", e.getMessage())); return ResponseGenerator.failureResponse(Constants.ResponseMessages.CHECK_REQUEST_PARAMS); } return ResponseGenerator.failureResponse(); } - + @GetMapping(value = PathRoutes.FormServiceApi.GET_ALL_PLAIN_FORMS, produces = MediaType.APPLICATION_JSON_VALUE) public String getAllPlainForms() throws JsonProcessingException { List<Map<String, Object>> responseData = new ArrayList<>(); @@ -467,9 +469,10 @@ public class FormsController { } return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); } - + @GetMapping(value = PathRoutes.FormServiceApi.GET_PLAIN_FORM_BY_ID, produces = MediaType.APPLICATION_JSON_VALUE) - public String getPlainFormById(@RequestParam(value = Constants.APPLICATION_ID, required = true) String applicationId) + public String getPlainFormById( + @RequestParam(value = Constants.APPLICATION_ID, required = true) String applicationId) throws JsonProcessingException { List<Map<String, Object>> responseData = formsService.getPlainFormsById(applicationId); if (responseData != null) { diff --git a/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java b/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java index f2882bc..d8d9dfc 100644 --- a/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java +++ b/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java @@ -185,7 +185,6 @@ public class FormsServiceImpl implements FormsService { form = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), Form.class); } form.setNumberOfRecords((long) randInt(1, 1000)); - LOGGER.info("Each Form : {}", gson.toJson(form)); formList.add(form); } } @@ -943,7 +942,11 @@ public class FormsServiceImpl implements FormsService { IncomingData updatedAppData = objectMapper.convertValue(updatedAppMap, IncomingData.class); // update activity logs - activityService.applicationActivity(applicationData, updatedAppData, userInfo); + if (action.equalsIgnoreCase(Status.NEW.name())) { + activityService.applicationActivity(null, updatedAppData, userInfo); + } else { + activityService.applicationActivity(applicationData, updatedAppData, userInfo); + } // send notification if (action.equals(Constants.WorkflowActions.ASSIGN_INSPECTOR)) { -- GitLab