diff --git a/src/main/java/com/tarento/formservice/controllers/FormsController.java b/src/main/java/com/tarento/formservice/controllers/FormsController.java index ab41ae9749a187f657243c9e4bcad73197c63609..a891c23e2ced1dd653d34d78e256f81251edaade 100644 --- a/src/main/java/com/tarento/formservice/controllers/FormsController.java +++ b/src/main/java/com/tarento/formservice/controllers/FormsController.java @@ -78,6 +78,20 @@ public class FormsController { } return ResponseGenerator.successResponse(formsService.getFormById(formId)); } + + @PostMapping(value = PathRoutes.FormServiceApi.GET_FORM_BY_ID, produces = MediaType.APPLICATION_JSON_VALUE) + public String deleteFormById( + @RequestHeader(value = Constants.Parameters.X_USER_INFO, required = false) String xUserInfo, + @RequestParam(value = Constants.ID, required = true) String id) throws JsonProcessingException { + Long formId = null; + if (id.length() <= 13) { + formId = Long.parseLong(id); + } else if (id instanceof String) { + FormData fData = decodeValue(String.valueOf(id)); + formId = fData.getId(); + } + return ResponseGenerator.successResponse(formsService.getFormById(formId)); + } @PostMapping(value = PathRoutes.FormServiceApi.CREATE_FORM) public String createForm(@RequestBody FormDetail form, diff --git a/src/main/java/com/tarento/formservice/model/Status.java b/src/main/java/com/tarento/formservice/model/Status.java index 80a30848ce59c2a9bbf196f77fc9a4b8ec6efc02..772485555fab8d7b2d62ba3fc809862c291f98b7 100644 --- a/src/main/java/com/tarento/formservice/model/Status.java +++ b/src/main/java/com/tarento/formservice/model/Status.java @@ -4,7 +4,8 @@ import com.fasterxml.jackson.annotation.JsonValue; public enum Status { DRAFT("Draft"), NEW("New"), REVIEW("Review"), PUBLISH("Publish"), UNPUBLISH("Unpublish"), INSCOMPLETED( - "INSCOMPLETED"), LEADINSCOMPLETED("LEADINSCOMPLETED"), SENTFORINS("SENTFORINS"); + "INSCOMPLETED"), LEADINSCOMPLETED("LEADINSCOMPLETED"), SENTFORINS("SENTFORINS"), + DELETED("Deleted"),DUPLICATE("Duplicate"); private String value; 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 da78424d794f5a3374cbe4bf715f72d012e62950..49fc4a62c5355fe5c314078f6f4829a5cf03e528 100644 --- a/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java +++ b/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java @@ -286,13 +286,14 @@ public class FormsServiceImpl implements FormsService { } else { boolQuery.must(QueryBuilders.matchPhraseQuery(Constants.STATUS, Status.PUBLISH.name())); } + boolQuery.mustNot(QueryBuilders.matchPhraseQuery(Constants.STATUS, Status.DELETED.name())); return boolQuery; } private SearchRequest buildQueryForGetQueryById(Long id) { SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0) - .query(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("id", id))) + .query(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("id", id)).mustNot(QueryBuilders.matchPhraseQuery(Constants.STATUS, Status.DELETED.name()))) .aggregation(AggregationBuilders.terms("UniqueFormId").field("id").size(100) .subAggregation(AggregationBuilders.topHits("LatestVersion").from(0).size(1) .version(Boolean.FALSE).explain(Boolean.FALSE)