Commit 24a36abb authored by Saroj Singh's avatar Saroj Singh
Browse files

delete form

1 merge request!10Delete form
Showing with 18 additions and 2 deletions
+18 -2
......@@ -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,
......
......@@ -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;
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment