diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..55511c5ba98dde7cd433468b642187f88c3f51a7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,232 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>com.tarento</groupId> + <artifactId>form-service</artifactId> + <version>0.0.1-SNAPSHOT</version> + + <name>Form Service</name> + <description>Project for handling the data for project portfolio</description> + <url>http://maven.apache.org</url> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.5.5</version> + <relativePath></relativePath> + </parent> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + <cxf.version>3.0.1</cxf.version> + </properties> + + <dependencies> + <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-jdbc</artifactId> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20210307</version> + </dependency> + <dependency> + <groupId>com.sun.mail</groupId> + <artifactId>javax.mail</artifactId> + <version>1.6.0</version> + </dependency> + + <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi</artifactId> + <version>5.0.0</version> + </dependency> + + <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi-ooxml</artifactId> + <version>5.0.0</version> + </dependency> + <!-- https://mvnrepository.com/artifact/org.springframework.kafka/spring-kafka --> + <dependency> + <groupId>org.springframework.kafka</groupId> + <artifactId>spring-kafka</artifactId> + <version>2.5.5.RELEASE</version> + </dependency> + + <!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients --> + <dependency> + <groupId>org.apache.kafka</groupId> + <artifactId>kafka-clients</artifactId> + <version>2.8.0</version> + </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.elasticsearch.client</groupId> + <artifactId>elasticsearch-rest-high-level-client</artifactId> + <version>7.10.0</version> + </dependency> + <dependency> + <groupId>org.elasticsearch</groupId> + <artifactId>elasticsearch</artifactId> + <version>7.10.0</version> + </dependency> + + <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jersey --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-jersey</artifactId> + </dependency> + <!-- https://mvnrepository.com/artifact/junit/junit --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + <version>1.1.1</version> + </dependency> + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-tools-java2ws</artifactId> + <version>${cxf.version}</version> + </dependency> + <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>8.0.26</version> + </dependency> + <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.12.0</version> + </dependency> + <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-text --> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>1.9</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-yaml</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + </dependency> + <!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path --> + <dependency> + <groupId>com.jayway.jsonpath</groupId> + <artifactId>json-path</artifactId> + <version>2.6.0</version> + </dependency> + + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.8.0</version> + </dependency> + <!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz --> + <dependency> + <groupId>org.quartz-scheduler</groupId> + <artifactId>quartz</artifactId> + <version>2.1.5</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>okhttp</artifactId> + <version>4.1.1</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-hibernate5</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-hppc</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-json-org</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-jsr310</artifactId> + </dependency> + <dependency> + <groupId>io.jsonwebtoken</groupId> + <artifactId>jjwt-api</artifactId> + <version>0.11.1</version> + </dependency> + <dependency> + <groupId>io.jsonwebtoken</groupId> + <artifactId>jjwt-impl</artifactId> + <version>0.11.1</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>io.jsonwebtoken</groupId> + <artifactId>jjwt-jackson</artifactId> + <version>0.11.1</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + + </dependencies> + <build> + <plugins> + <plugin><!-- Include if you want to make an executable jar[FAT JAR which + includes all dependencies along with sprinboot loader] that you can run on + commandline using java -jar NAME --> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> +</project> diff --git a/src/main/java/META-INF/additional-spring-configuration-metadata.json b/src/main/java/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/main/java/com/tarento/formservice/FormService.java b/src/main/java/com/tarento/formservice/FormService.java new file mode 100644 index 0000000000000000000000000000000000000000..0796c90ce8e03efb2e31d3beb0bb943057067a2c --- /dev/null +++ b/src/main/java/com/tarento/formservice/FormService.java @@ -0,0 +1,28 @@ +package com.tarento.formservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import com.tarento.formservice.utils.Constants; + +/** + * + * @author Darshan Nagesh + * + */ +@SpringBootApplication +public class FormService { + public static void main(String[] args) { + SpringApplication.run(FormService.class, args); + } + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } + +} diff --git a/src/main/java/com/tarento/formservice/config/CORSConfig.java b/src/main/java/com/tarento/formservice/config/CORSConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..8bb4a1592662bdb75b528c817c671e22d9170f10 --- /dev/null +++ b/src/main/java/com/tarento/formservice/config/CORSConfig.java @@ -0,0 +1,24 @@ +package com.tarento.formservice.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import com.tarento.formservice.utils.Constants; + +@Configuration +public class CORSConfig { + + @Bean + public WebMvcConfigurer corsConfigurer() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods(Constants.RequestMethods.GET, Constants.RequestMethods.POST, + Constants.RequestMethods.PUT, Constants.RequestMethods.DELETE, Constants.RequestMethods.OPTIONS) + .allowedOrigins("*").allowedHeaders("*"); + } + }; + } +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/config/CORSFilter.java b/src/main/java/com/tarento/formservice/config/CORSFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..e058705dd13e84d5e42d07e9f161fbccc48c6ec9 --- /dev/null +++ b/src/main/java/com/tarento/formservice/config/CORSFilter.java @@ -0,0 +1,46 @@ +package com.tarento.formservice.config; + +import java.io.IOException; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +@Component +@Order(Ordered.HIGHEST_PRECEDENCE) +public class CORSFilter implements Filter { + + @Override + public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) + throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) req; + HttpServletResponse response = (HttpServletResponse) res; + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Allow-Credentials", "true"); + response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE"); + response.setHeader("Access-Control-Max-Age", "3600"); + response.setHeader("Access-Control-Allow-Headers", + "X-Requested-With, Content-Type, Authorization, Origin, Accept, Access-Control-Request-Method, Access-Control-Request-Headers, locale, rootOrg, hostPath, org, Referer, sec-ch-ua-mobile, sec-ch-ua, User-Agent, wid, WID"); + chain.doFilter(req, res); + } + + @Override + public void init(FilterConfig filterConfig) { + + } + + @Override + public void destroy() { + + } + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/controllers/FormsController.java b/src/main/java/com/tarento/formservice/controllers/FormsController.java new file mode 100644 index 0000000000000000000000000000000000000000..adcf3098afe3782282b2c16e197376d3993c6d54 --- /dev/null +++ b/src/main/java/com/tarento/formservice/controllers/FormsController.java @@ -0,0 +1,298 @@ +package com.tarento.formservice.controllers; + +import org.springframework.http.MediaType; +import java.io.File; +import java.io.IOException; +import org.apache.tomcat.util.codec.binary.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.google.gson.Gson; +import com.tarento.formservice.model.FormData; +import com.tarento.formservice.model.FormModel; +import com.tarento.formservice.model.IncomingData; +import com.tarento.formservice.model.OverviewCount; +import com.tarento.formservice.model.ReplyFeedbackDto; +import com.tarento.formservice.model.Role; +import com.tarento.formservice.model.UserInfo; +import com.tarento.formservice.model.VerifyFeedbackDto; +import com.tarento.formservice.model.VoteFeedbackDto; +import com.tarento.formservice.models.Form; +import com.tarento.formservice.models.FormDetail; +import com.tarento.formservice.service.FormsService; +import com.tarento.formservice.service.JsonFormsService; +import com.tarento.formservice.utils.Constants; +import com.tarento.formservice.utils.PathRoutes; +import com.tarento.formservice.utils.ResponseGenerator; + +/** + * + * @author Darshan Nagesh + * + */ +@RestController +@RequestMapping(PathRoutes.FormServiceApi.FORMS_ROOT) +public class FormsController { + + public static final Logger logger = LoggerFactory.getLogger(FormsController.class); + + @Autowired + private FormsService formsService; + + @Value("${file.config.path}") + public String fileDirectory; + + @Value("${file.config.name}") + public String fileName; + + @Autowired + private JsonFormsService jsonFormsService; + + @GetMapping(value = PathRoutes.FormServiceApi.GET_ALL_FORMS, produces = MediaType.APPLICATION_JSON_VALUE) + public String getAllForms(@RequestHeader(value = "x-user-info", required = false) String xUserInfo) + throws JsonProcessingException { + return ResponseGenerator.successResponse(formsService.getAllForms()); + } + + @GetMapping(value = PathRoutes.FormServiceApi.GET_FORM_BY_ID, produces = MediaType.APPLICATION_JSON_VALUE) + public String getFormById(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestParam(value = "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) throws IOException { + Form createdForm = formsService.createForm(form); + if (createdForm.getId() != null) { + return ResponseGenerator.successResponse(form); + } else { + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + } + + @PostMapping(value = PathRoutes.FormServiceApi.SAVE_FORM_SUBMIT) + public String saveFormSubmit(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestBody IncomingData incomingData) throws IOException { + Boolean status = false; + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + UserInfo userInfo = new UserInfo(); + FormData fData = new FormData(); + FormModel formModel; + Boolean matchConfigStatus = false; + if (incomingData != null) { + logger.info("Incomming Data : {}", incomingData); + if (userInfo != null) + incomingData.setCustomerId(userInfo.getId()); + if (StringUtils.isNotBlank(incomingData.getFormData())) { + fData = decodeValue(incomingData.getFormData()); + userInfo.setId(fData.getCustomer()); + incomingData.setAgentId(fData.getAgent()); + } + formModel = mapper.readValue(new File(fileDirectory + fileName), + // mapper.readValue(ResourceUtils.getFile("classpath:schema/FormConfig.yml"), + // , + FormModel.class); + Form plainForm = new Form(); + com.tarento.formservice.model.FormDetail fDetails = new com.tarento.formservice.model.FormDetail(); + for (int k = 0; k < formModel.getFormDetails().size(); k++) { + if (formModel.getFormDetails().get(k).getFormId().equals(Long.toString(incomingData.getId()))) { + fDetails = formModel.getFormDetails().get(k); + matchConfigStatus = true; + break; + } else { + plainForm.setSecondaryId(fDetails.getFormId()); + } + } + plainForm.setSecondaryId(fDetails.getFormId()); + plainForm.setVersion(incomingData.getVersion()); + if (matchConfigStatus) + status = jsonFormsService.processJsonForms(incomingData.getDataObject(), plainForm, fDetails); + else + status = formsService.saveFormSubmit(incomingData); + } + if (status) { + return ResponseGenerator.successResponse(status); + } else { + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + } + + @PostMapping(value = PathRoutes.FormServiceApi.VERIFY_FEEDBACK) + public String verifyFeedback(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestBody VerifyFeedbackDto verifyFeedbackDto) throws IOException { + UserInfo userInfo = new Gson().fromJson(xUserInfo, UserInfo.class); + Boolean stat = formsService.verifyFeedback(userInfo, verifyFeedbackDto); + if (stat) { + return ResponseGenerator.successResponse(stat); + } else { + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + } + + @PostMapping(value = PathRoutes.FormServiceApi.VOTE_FEEDBACK) + public String voteFeedback(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestBody VoteFeedbackDto voteFeedbackDto) throws IOException { + UserInfo userInfo = new Gson().fromJson(xUserInfo, UserInfo.class); + if (voteFeedbackDto.getCustomerId() == null) { + voteFeedbackDto.setCustomerId(userInfo.getId()); + } + Boolean stat = formsService.voteFeedback(userInfo, voteFeedbackDto); + if (stat) { + return ResponseGenerator.successResponse(stat); + } else { + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + } + + @PostMapping(value = PathRoutes.FormServiceApi.REPLY_FEEDBACK) + public String replyFeedback(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestBody ReplyFeedbackDto replyFeedbackDto) throws IOException { + if (StringUtils.isNotBlank(xUserInfo)) { + UserInfo userInfo = new Gson().fromJson(xUserInfo, UserInfo.class); + String userRole = ""; + for (Role role : userInfo.getRoles()) { + userRole = role.getName(); + } + if (userRole.equals("Agent")) { + return ResponseGenerator.successResponse(formsService.replyFeedback(userInfo, replyFeedbackDto)); + } + } + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + + } + + @PostMapping(value = PathRoutes.FormServiceApi.CHALLENGE_FEEDBACK) + public String challengeFeedbacks(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestBody VerifyFeedbackDto verifyFeedbackDto) throws IOException { + Boolean stat = formsService.challengeFeedback(verifyFeedbackDto.getId(), + verifyFeedbackDto.getReasonForChallenge()); + if (stat) { + return ResponseGenerator.successResponse(stat); + } else { + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + } + + @PostMapping(value = PathRoutes.FormServiceApi.REQUEST_FEEDBACK) + public String requestFeedback(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestBody FormData formData) throws IOException { + FormData fDataDecoded = decodeValue(formData.getFormData()); + fDataDecoded.setFormData(formData.getFormData()); + Boolean stat = formsService.requestFeedback(fDataDecoded); + if (stat) { + return ResponseGenerator.successResponse(stat); + } else { + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + } + + @GetMapping(value = PathRoutes.FormServiceApi.GET_FEEDBACKS, produces = MediaType.APPLICATION_JSON_VALUE) + public String getFeedbacks(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestParam(value = "formId", required = false) Long formId, + @RequestParam(value = "agentId", required = false) Long agentId, + @RequestParam(value = "customerId", required = false) Long customerId, + @RequestParam(value = "approved", required = false) String approved, + @RequestParam(value = "challenged", required = false) String challenged, + @RequestParam(value = "challengeStatus", required = false) Boolean challengeStatus) + throws JsonProcessingException { + UserInfo userInfo = null; + if (xUserInfo != null) { + userInfo = new Gson().fromJson(xUserInfo, UserInfo.class); + } + List<IncomingData> formFeedback = null; + formFeedback = formsService.getFeedbacksByFormId(formId, approved, challenged, agentId, customerId, userInfo, + challengeStatus); + if (formFeedback != null) + return ResponseGenerator.successResponse(formFeedback); + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + + @GetMapping(value = PathRoutes.FormServiceApi.GET_FEEDBACK_BY_ID, produces = MediaType.APPLICATION_JSON_VALUE) + public String getFeedbackById(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestParam(value = "formId", required = false) Long formId) throws JsonProcessingException { + List<IncomingData> formFeedback = null; + formFeedback = formsService.getFeedbacksByFormId(formId); + if (formFeedback != null) + return ResponseGenerator.successResponse(formFeedback); + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + + @GetMapping(value = PathRoutes.FormServiceApi.GET_ALL_FEEDBACKS, produces = MediaType.APPLICATION_JSON_VALUE) + public String getFeedbacks(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestParam(value = "approved", required = false) String approved, + @RequestParam(value = "challenged", required = false) String challenged, + @RequestParam(value = "challengeStatus", required = false) Boolean challengeStatus, + @RequestParam(value = "count", required = true) Boolean count) throws JsonProcessingException { + List<IncomingData> formFeedback = null; + formFeedback = formsService.getFeedbacks(approved, challenged, challengeStatus); + if (formFeedback != null) { + if (count) + return ResponseGenerator.successResponse(formFeedback.size()); + else + return ResponseGenerator.successResponse(formFeedback); + } + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + + @GetMapping(value = PathRoutes.FormServiceApi.GET_OVERVIEW_COUNT, produces = MediaType.APPLICATION_JSON_VALUE) + public String getOverviewCount(@RequestHeader(value = "x-user-info", required = false) String xUserInfo) + throws JsonProcessingException { + OverviewCount overviewCount = null; + if (StringUtils.isNotBlank(xUserInfo)) { + UserInfo userInfo = new Gson().fromJson(xUserInfo, UserInfo.class); + overviewCount = formsService.getOverviewCount(userInfo); + } else { + overviewCount = formsService.getOverviewCount(null); + } + + if (overviewCount != null) { + return ResponseGenerator.successResponse(overviewCount); + } + return ResponseGenerator.failureResponse(Constants.ResponseMessages.ERROR_MESSAGE); + } + + @PostMapping(value = PathRoutes.FormServiceApi.SAVE_FORM_SUBMIT_BULK) + public String saveFormSubmitBulk(@RequestBody List<IncomingData> incomingDataList) throws IOException { + if (incomingDataList != null && incomingDataList.size() > 0) { + for (IncomingData incomingData : incomingDataList) { + incomingData.setCustomerId(null); + incomingData.setAgentId(null); + formsService.saveFormSubmit(incomingData); + } + } + + return ResponseGenerator.successResponse(Boolean.TRUE); + + } + + private FormData decodeValue(String encodedValue) { + byte[] decodedString = Base64.decodeBase64(encodedValue); + FormData fData = new Gson().fromJson(new String(decodedString), FormData.class); + return fData; + } + +} diff --git a/src/main/java/com/tarento/formservice/controllers/JsonFormsController.java b/src/main/java/com/tarento/formservice/controllers/JsonFormsController.java new file mode 100644 index 0000000000000000000000000000000000000000..efcf87e4c89923f3c67c5889f495c0fc159edcdb --- /dev/null +++ b/src/main/java/com/tarento/formservice/controllers/JsonFormsController.java @@ -0,0 +1,68 @@ +package com.tarento.formservice.controllers; + +import java.io.File; +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.tarento.formservice.model.FormModel; +import com.tarento.formservice.models.Form; +import com.tarento.formservice.service.JsonFormsService; +import com.tarento.formservice.utils.PathRoutes; +import com.tarento.formservice.utils.ResponseGenerator; + +@RestController +@RequestMapping(PathRoutes.JsonFormServiceApi.JSON_FORM_ROOT) +public class JsonFormsController { + + public static final Logger logger = LoggerFactory.getLogger(JsonFormsController.class); + + @Value("${file.config.path}") + public String fileDirectory; + + @Value("${file.config.name}") + public String fileName; + + @Autowired + private JsonFormsService jsonFormsService; + + @RequestMapping(path = PathRoutes.JsonFormServiceApi.FORMS, method = RequestMethod.POST) + public String uploadFormJsonData(@RequestHeader(value = "x-user-info", required = false) String xUserInfo, + @RequestParam String id, @RequestBody Object jsonForm) throws IOException { + Boolean status = Boolean.FALSE; + logger.info("Received JSON Form {}", jsonForm); + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + FormModel formModel; + if (jsonForm != null) { + logger.info("Form ID : {}", id); + formModel = mapper.readValue(new File(fileDirectory + fileName) + // ResourceUtils.getFile("classpath:schema/FormConfig.yml") + , FormModel.class); + Form plainForm = new Form(); + com.tarento.formservice.model.FormDetail fDetails = new com.tarento.formservice.model.FormDetail(); + for (int k = 0; k < formModel.getFormDetails().size(); k++) { + if (formModel.getFormDetails().get(k).getFormId().equals(id)) { + fDetails = formModel.getFormDetails().get(k); + } else { + plainForm.setSecondaryId(fDetails.getFormId()); + } + } + plainForm.setSecondaryId(fDetails.getFormId()); + plainForm.setVersion(1); + status = jsonFormsService.processJsonForms(jsonForm, plainForm, fDetails); + } + return ResponseGenerator.successResponse(status); + + } +} diff --git a/src/main/java/com/tarento/formservice/dao/FormsDao.java b/src/main/java/com/tarento/formservice/dao/FormsDao.java new file mode 100644 index 0000000000000000000000000000000000000000..4efe86aa59b7b77ceb45b341f8455fc21ab02d48 --- /dev/null +++ b/src/main/java/com/tarento/formservice/dao/FormsDao.java @@ -0,0 +1,68 @@ +package com.tarento.formservice.dao; + +import java.io.IOException; +import java.util.Map; + +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.action.search.MultiSearchResponse; +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.springframework.http.HttpHeaders; + +import com.tarento.formservice.model.FormData; +import com.tarento.formservice.model.IncomingData; +import com.tarento.formservice.models.FormDetail; + +/** + * This interface for Portfolio contains the method which executes the Search + * Request and Delete Request on Elastic Search Repositories + * + * @author Darshan Nagesh + * + */ +public interface FormsDao { + + /** + * This method receives the Search Request which already contains a query to be + * searched with. Method will execute the Search Request by using the + * RestHighLevelClient and sends the reponse back + * + * @param searchRequest + * @return + */ + public MultiSearchResponse executeMultiSearchRequest(SearchRequest searchRequest); + + /** + * This method receives a list of Project Information records to be deleted. It + * gets invoked when a project information update is fired. On update, it + * removes the existing record and replaces with a new record. + * + * @param deleteRequestList + * @return + */ + public Boolean addNewForm(FormDetail newForm, HttpHeaders httpHeaders) throws IOException; + + public Boolean addInteraction(FormData fData, HttpHeaders httpHeaders) throws IOException; + + public SearchResponse executeSearchRequest(SearchRequest searchRequest); + + public Boolean saveFormSubmit(IncomingData incomingData, HttpHeaders httpHeaders) throws IOException; + + public Boolean verifyFeedback(Map<String, Object> jsonMap, String id) throws IOException; + + public Boolean challengeFeedback(Map<String, Object> jsonMap, String id) throws IOException; + + public Boolean voteFeedback(Map<String, Object> jsonMap, String id) throws IOException; + + public Boolean replyFeedback(Map<String, Object> jsonMap, String id) throws IOException; + + public Boolean updateInteractions(Map<String, Object> jsonMap, String id) throws IOException; + + Boolean updateInteraction(Map<String, Object> jsonMap, String id, HttpHeaders httpHeaders) throws IOException; + + UpdateRequest addBulkUpdateRequest(String id, Map<String, Object> jsonMap) throws IOException; + + public Boolean updateBulkRequest(BulkRequest request) throws IOException; + +} diff --git a/src/main/java/com/tarento/formservice/dao/impl/FormsDaoImpl.java b/src/main/java/com/tarento/formservice/dao/impl/FormsDaoImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8012e03328f27047793ccb955958141f57b596d7 --- /dev/null +++ b/src/main/java/com/tarento/formservice/dao/impl/FormsDaoImpl.java @@ -0,0 +1,233 @@ +package com.tarento.formservice.dao.impl; + +import java.io.IOException; +import java.util.Date; +import java.util.Map; + +import org.apache.http.HttpHost; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.action.bulk.BulkResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.search.MultiSearchRequest; +import org.elasticsearch.action.search.MultiSearchResponse; +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.update.UpdateResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback; +import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.common.xcontent.XContentType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Repository; + +import com.google.gson.Gson; +import com.tarento.formservice.dao.FormsDao; +import com.tarento.formservice.model.FormData; +import com.tarento.formservice.model.IncomingData; +import com.tarento.formservice.models.FormDetail; +import com.tarento.formservice.utils.Constants; + +@Repository(Constants.ServiceRepositories.FORM_REPO) +public class FormsDaoImpl implements FormsDao { + + public static final Logger logger = LoggerFactory.getLogger(FormsDaoImpl.class); + String daoImplMarker = Constants.ServiceRepositories.FORM_REPO + Constants.Markers.DAO_IMPL; + Marker marker = MarkerFactory.getMarker(daoImplMarker); + private RestHighLevelClient client; + private String elasticHost; + @SuppressWarnings("unused") + private int elasticPort; + private String elasticUsername; + private String elasticPassword; + private String formsIndexName; + private String interactionIndexName; + private String formsDocumentType; + + public FormsDaoImpl(@Value("${services.esindexer.host}") String elasticHost, + @Value("${services.esindexer.username}") String elasticUsername, + @Value("${services.esindexer.password}") String elasticPassword, + @Value("${es.fs.forms.index.name}") String formsIndexName, + @Value("${es.fs.interactions.index.name}") String interactionIndexName, + @Value("${es.fs.forms.document.type}") String formsDocumentType, + @Value("${services.esindexer.host.port}") int elasticPort) { + this.elasticUsername = elasticUsername; + this.elasticPassword = elasticPassword; + this.elasticHost = elasticHost; + this.elasticPort = elasticPort; + this.formsIndexName = formsIndexName; + this.interactionIndexName = interactionIndexName; + this.formsDocumentType = formsDocumentType; + this.client = connectToElasticSearch(); + } + + private RestHighLevelClient connectToElasticSearch() { + final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + credentialsProvider.setCredentials(AuthScope.ANY, + new UsernamePasswordCredentials(elasticUsername, elasticPassword)); + // SET SSL CONTEXT + // RestClient restClient = RestClient.builder(new HttpHost(esHost, esPort, + // "https")) + // .setHttpClientConfigCallback(httpClientBuilder -> { + // HttpAsyncClientBuilder httpAsyncClientBuilder = + // httpClientBuilder.setSSLContext(sslcontext); + // return httpAsyncClientBuilder; + // }) + // .build(); + + HttpClientConfigCallback httpClientConfigCallback = new HttpClientConfigCallback() { + @Override + public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { + return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); + } + }; + return new RestHighLevelClient(RestClient.builder(new HttpHost(elasticHost, elasticPort, "https")) + .setHttpClientConfigCallback(httpClientConfigCallback)); + } + + @Override + public MultiSearchResponse executeMultiSearchRequest(SearchRequest searchRequest) { + MultiSearchRequest multiRequest = new MultiSearchRequest(); + MultiSearchResponse response = null; + // logger.info(marker, "ES Query is : {}", searchRequest.source()); + multiRequest.add(searchRequest); + try { + response = client.msearch(multiRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + logger.error(marker, "Encountered an error while connecting : ", e); + logger.error(marker, "Error Message to report :{} ", e.getMessage()); + } + return response; + } + + @Override + public Boolean addNewForm(FormDetail newForm, HttpHeaders httpHeaders) throws IOException { + if (newForm.getId() != null) { + newForm.setUpdatedDate(new Date().getTime()); + } else { + newForm.setId(new Date().getTime()); + newForm.setUpdatedDate(new Date().getTime()); + newForm.setVersion(1); + } + IndexRequest indexRequest = new IndexRequest().index(formsIndexName).type(formsDocumentType) + .source(new Gson().toJson(newForm), XContentType.JSON); + logger.info("Index Request Description: {} ", indexRequest.getDescription()); + IndexResponse response = null; + response = client.index(indexRequest, RequestOptions.DEFAULT); + + return (response != null); + } + + @Override + public SearchResponse executeSearchRequest(SearchRequest searchRequest) { + SearchResponse response = null; + logger.info(marker, "ES Query is : {}", searchRequest.source()); + try { + response = client.search(searchRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + logger.error(marker, "Encountered an error while connecting : ", e); + logger.error(marker, "Error Message to report : {}", e.getMessage()); + } + return response; + } + + @Override + public Boolean saveFormSubmit(IncomingData incomingData, HttpHeaders httpHeaders) throws IOException { + incomingData.setReasonForApprovalRejection(""); + incomingData.setApprovedTime(0L); + incomingData.setApprovedBy(0L); + incomingData.setApproval(""); + incomingData.setChallenge(""); + incomingData.setChallengeVerifiedBy(0L); + incomingData.setChallengeVerifiedTime(0L); + incomingData.setChallengeStatus(false); + incomingData.setReasonForChallenge(""); + IndexRequest indexRequest = new IndexRequest().index("fs-forms-data").type(formsDocumentType) + .source(new Gson().toJson(incomingData), XContentType.JSON); + logger.info("Index Request Description: {} ", indexRequest.getDescription()); + IndexResponse response = null; + response = client.index(indexRequest, RequestOptions.DEFAULT); + return (response != null); + } + + @Override + public Boolean verifyFeedback(Map<String, Object> jsonMap, String id) throws IOException { + UpdateRequest request = new UpdateRequest().index("fs-forms-data").type(formsDocumentType).id(id).doc(jsonMap); + UpdateResponse response = client.update(request, RequestOptions.DEFAULT); + return (response != null); + } + + @Override + public Boolean addInteraction(FormData fData, HttpHeaders httpHeaders) throws IOException { + IndexRequest indexRequest = new IndexRequest().index(interactionIndexName).type(formsDocumentType) + .source(new Gson().toJson(fData), XContentType.JSON); + logger.info("Index Request Description: {} ", indexRequest.getDescription()); + IndexResponse response = null; + response = client.index(indexRequest, RequestOptions.DEFAULT); + return (response != null); + } + + @Override + public UpdateRequest addBulkUpdateRequest(String id, Map<String, Object> jsonMap) throws IOException { + return new UpdateRequest().index(interactionIndexName).type(formsDocumentType).id(id).doc(jsonMap); + } + + @Override + public Boolean updateInteraction(Map<String, Object> jsonMap, String id, HttpHeaders httpHeaders) + throws IOException { + UpdateRequest request = new UpdateRequest().index(interactionIndexName).type(formsDocumentType).id(id) + .doc(jsonMap); + UpdateResponse response = client.update(request, RequestOptions.DEFAULT); + return (response != null); + } + + @Override + public Boolean challengeFeedback(Map<String, Object> jsonMap, String id) throws IOException { + UpdateRequest request = new UpdateRequest().index("fs-forms-data").type(formsDocumentType).id(id).doc(jsonMap); + UpdateResponse response = client.update(request, RequestOptions.DEFAULT); + return (response != null); + } + + @Override + public Boolean voteFeedback(Map<String, Object> jsonMap, String id) throws IOException { + UpdateRequest request = new UpdateRequest().index("fs-forms-data").type(formsDocumentType).id(id) + .doc(new Gson().toJson(jsonMap), XContentType.JSON); + UpdateResponse response = client.update(request, RequestOptions.DEFAULT); + return (response != null); + } + + @Override + public Boolean replyFeedback(Map<String, Object> jsonMap, String id) throws IOException { + UpdateRequest request = new UpdateRequest().index("fs-forms-data").type(formsDocumentType).id(id) + .doc(new Gson().toJson(jsonMap), XContentType.JSON); + UpdateResponse response = client.update(request, RequestOptions.DEFAULT); + return (response != null); + } + + @Override + public Boolean updateInteractions(Map<String, Object> jsonMap, String id) throws IOException { + UpdateRequest request = new UpdateRequest().index("fs-interactions").type(formsDocumentType).id(id) + .doc(new Gson().toJson(jsonMap), XContentType.JSON); + UpdateResponse response = client.update(request, RequestOptions.DEFAULT); + return (response != null); + } + + @Override + public Boolean updateBulkRequest(BulkRequest request) throws IOException { + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + return !bulkResponse.hasFailures(); + } + +} diff --git a/src/main/java/com/tarento/formservice/datamapper/SqlDataMapper.java b/src/main/java/com/tarento/formservice/datamapper/SqlDataMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..4fea762478c1d95aada4349bb0406f5f4a2a5026 --- /dev/null +++ b/src/main/java/com/tarento/formservice/datamapper/SqlDataMapper.java @@ -0,0 +1,5 @@ +package com.tarento.formservice.datamapper; + +public interface SqlDataMapper { + +} diff --git a/src/main/java/com/tarento/formservice/exception/AINException.java b/src/main/java/com/tarento/formservice/exception/AINException.java new file mode 100644 index 0000000000000000000000000000000000000000..05943e35d8c35ac01ac585495b131569c587a379 --- /dev/null +++ b/src/main/java/com/tarento/formservice/exception/AINException.java @@ -0,0 +1,30 @@ +package com.tarento.formservice.exception; + +public class AINException extends Exception{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + final String errorCode; + + final String errorMessage; + + public AINException(String errorCode, String errorMessage) { + this.errorCode= errorCode; + this.errorMessage = errorMessage; + } + + public String getErrorCode() { + return errorCode; + } + + + public String getErrorMessage() { + return errorMessage; + } + + + +} diff --git a/src/main/java/com/tarento/formservice/executor/MasterDataManager.java b/src/main/java/com/tarento/formservice/executor/MasterDataManager.java new file mode 100644 index 0000000000000000000000000000000000000000..efa6a93901f5ca957b80546dd0fbe80d0e2f339d --- /dev/null +++ b/src/main/java/com/tarento/formservice/executor/MasterDataManager.java @@ -0,0 +1,37 @@ +package com.tarento.formservice.executor; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +import com.tarento.formservice.model.ResponseData; + +@Component +public class MasterDataManager implements ApplicationRunner { + + public static final Logger LOGGER = LoggerFactory.getLogger(MasterDataManager.class); + + protected static ConcurrentMap<Long, ResponseData> userData = new ConcurrentHashMap<>(); + + @Override + public void run(ApplicationArguments args) throws Exception { + } + + public static void flushMasterData() { + getUserData().clear(); + } + + public static ConcurrentMap<Long, ResponseData> getUserData() { + return userData; + } + + public static void setUserData(ConcurrentMap<Long, ResponseData> userData) { + MasterDataManager.userData = userData; + } + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/model/AgentOverview.java b/src/main/java/com/tarento/formservice/model/AgentOverview.java new file mode 100644 index 0000000000000000000000000000000000000000..18001913dc33f899c712155fe55cc8aabd0f78a5 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/AgentOverview.java @@ -0,0 +1,24 @@ +package com.tarento.formservice.model; + +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.ALWAYS) +public class AgentOverview { + private Double averageRating; + private Long totalRating; + private Map<Integer, Double> ratingSplit; + private Map<String, Double> featureListing; +} diff --git a/src/main/java/com/tarento/formservice/model/Chart.java b/src/main/java/com/tarento/formservice/model/Chart.java new file mode 100644 index 0000000000000000000000000000000000000000..8cb4b40cba28f16adc2150a14cf5fc5cd38ac1b8 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Chart.java @@ -0,0 +1,201 @@ + +package com.tarento.formservice.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "chartType", "subChartType", "visualizationCode", "chartFormat", "drillDownChartId", "filterKeys", + "customData", "dates", "filter", "data", "title", "description", "image" }) +public class Chart { + @JsonProperty("id") + private Long id; + @JsonProperty("chartType") + private String chartType; + @JsonProperty("subChartType") + private String subChartType; + @JsonProperty("visualizationCode") + private String visualizationCode; + @JsonProperty("chartFormat") + private String chartFormat; + @JsonProperty("drillDownChartId") + private String drillDownChartId; + @JsonProperty("filterKeys") + private String filterKeys; + @JsonProperty("customData") + private String customData; + @JsonProperty("dates") + private String dates; + @JsonProperty("filter") + private String filter; + @JsonProperty("data") + private List<Data> data = null; + @JsonProperty("title") + private String title; + @JsonProperty("description") + private String description; + @JsonProperty("image") + private String image; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("chartType") + public String getChartType() { + return chartType; + } + + @JsonProperty("chartType") + public void setChartType(String chartType) { + this.chartType = chartType; + } + + @JsonProperty("subChartType") + public String getSubChartType() { + return subChartType; + } + + @JsonProperty("subChartType") + public void setSubChartType(String subChartType) { + this.subChartType = subChartType; + } + + @JsonProperty("visualizationCode") + public String getVisualizationCode() { + return visualizationCode; + } + + @JsonProperty("visualizationCode") + public void setVisualizationCode(String visualizationCode) { + this.visualizationCode = visualizationCode; + } + + @JsonProperty("chartFormat") + public String getChartFormat() { + return chartFormat; + } + + @JsonProperty("chartFormat") + public void setChartFormat(String chartFormat) { + this.chartFormat = chartFormat; + } + + @JsonProperty("drillDownChartId") + public String getDrillDownChartId() { + return drillDownChartId; + } + + @JsonProperty("drillDownChartId") + public void setDrillDownChartId(String drillDownChartId) { + this.drillDownChartId = drillDownChartId; + } + + @JsonProperty("filterKeys") + public String getFilterKeys() { + return filterKeys; + } + + @JsonProperty("filterKeys") + public void setFilterKeys(String filterKeys) { + this.filterKeys = filterKeys; + } + + @JsonProperty("customData") + public String getCustomData() { + return customData; + } + + @JsonProperty("customData") + public void setCustomData(String customData) { + this.customData = customData; + } + + @JsonProperty("dates") + public String getDates() { + return dates; + } + + @JsonProperty("dates") + public void setDates(String dates) { + this.dates = dates; + } + + @JsonProperty("filter") + public String getFilter() { + return filter; + } + + @JsonProperty("filter") + public void setFilter(String filter) { + this.filter = filter; + } + + @JsonProperty("data") + public List<Data> getData() { + return data; + } + + @JsonProperty("data") + public void setData(List<Data> data) { + this.data = data; + } + + @JsonProperty("title") + public String getTitle() { + return title; + } + + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + @JsonProperty("image") + public String getImage() { + return image; + } + + @JsonProperty("image") + public void setImage(String image) { + this.image = image; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + +} diff --git a/src/main/java/com/tarento/formservice/model/Dashboard.java b/src/main/java/com/tarento/formservice/model/Dashboard.java new file mode 100644 index 0000000000000000000000000000000000000000..ae7803bf92031c0ec2225fae7111c2013acd62c4 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Dashboard.java @@ -0,0 +1,101 @@ + +package com.tarento.formservice.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "id", + "title", + "description", + "layout", + "chartCount" +}) +public class Dashboard { + + @JsonProperty("id") + private Long id; + @JsonProperty("title") + private String title; + @JsonProperty("description") + private String description; + @JsonProperty("layout") + private List<Layout> layout = null; + @JsonProperty("chartCount") + private Integer chartCount; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("id") + public Long getId() { + return id; + } + + @JsonProperty("id") + public void setId(Long id) { + this.id = id; + } + + @JsonProperty("title") + public String getTitle() { + return title; + } + + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + @JsonProperty("layout") + public List<Layout> getLayout() { + return layout; + } + + @JsonProperty("layout") + public void setLayout(List<Layout> layout) { + this.layout = layout; + } + + @JsonProperty("chartCount") + public Integer getChartCount() { + return chartCount; + } + + @JsonProperty("chartCount") + public void setChartCount(Integer chartCount) { + this.chartCount = chartCount; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/model/Data.java b/src/main/java/com/tarento/formservice/model/Data.java new file mode 100644 index 0000000000000000000000000000000000000000..9e2d1dca880700c413bf46ec5bf6080082ad0af9 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Data.java @@ -0,0 +1,139 @@ +package com.tarento.formservice.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "id", + "vizType", + "headerName", + "headerValue", + "headerSymbol", + "colorPaletteCode", + "colorPaletteId", + "plots" +}) +public class Data { + + @JsonProperty("id") + private Integer id; + @JsonProperty("vizType") + private String vizType; + @JsonProperty("headerName") + private String headerName; + @JsonProperty("headerValue") + private String headerValue; + @JsonProperty("headerSymbol") + private String headerSymbol; + @JsonProperty("colorPaletteCode") + private String colorPaletteCode; + @JsonProperty("colorPaletteId") + private Object colorPaletteId; + @JsonProperty("plots") + private List<Plot> plots = null; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("id") + public Integer getId() { + return id; + } + + @JsonProperty("id") + public void setId(Integer id) { + this.id = id; + } + + @JsonProperty("vizType") + public String getVizType() { + return vizType; + } + + @JsonProperty("vizType") + public void setVizType(String vizType) { + this.vizType = vizType; + } + + @JsonProperty("headerName") + public String getHeaderName() { + return headerName; + } + + @JsonProperty("headerName") + public void setHeaderName(String headerName) { + this.headerName = headerName; + } + + @JsonProperty("headerValue") + public String getHeaderValue() { + return headerValue; + } + + @JsonProperty("headerValue") + public void setHeaderValue(String headerValue) { + this.headerValue = headerValue; + } + + @JsonProperty("headerSymbol") + public String getHeaderSymbol() { + return headerSymbol; + } + + @JsonProperty("headerSymbol") + public void setHeaderSymbol(String headerSymbol) { + this.headerSymbol = headerSymbol; + } + + @JsonProperty("colorPaletteCode") + public String getColorPaletteCode() { + return colorPaletteCode; + } + + @JsonProperty("colorPaletteCode") + public void setColorPaletteCode(String colorPaletteCode) { + this.colorPaletteCode = colorPaletteCode; + } + + @JsonProperty("colorPaletteId") + public Object getColorPaletteId() { + return colorPaletteId; + } + + @JsonProperty("colorPaletteId") + public void setColorPaletteId(Object colorPaletteId) { + this.colorPaletteId = colorPaletteId; + } + + @JsonProperty("plots") + public List<Plot> getPlots() { + return plots; + } + + @JsonProperty("plots") + public void setPlots(List<Plot> plots) { + this.plots = plots; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/model/Datum.java b/src/main/java/com/tarento/formservice/model/Datum.java new file mode 100644 index 0000000000000000000000000000000000000000..726201ae27aebc5482e9c4082d1ca95b43f8c823 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Datum.java @@ -0,0 +1,143 @@ + +package com.tarento.formservice.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Generated; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "id", + "vizType", + "headerName", + "headerValue", + "headerSymbol", + "colorPaletteCode", + "colorPaletteId", + "plots" +}) +@Generated("jsonschema2pojo") +public class Datum { + + @JsonProperty("id") + private Integer id; + @JsonProperty("vizType") + private String vizType; + @JsonProperty("headerName") + private String headerName; + @JsonProperty("headerValue") + private String headerValue; + @JsonProperty("headerSymbol") + private String headerSymbol; + @JsonProperty("colorPaletteCode") + private String colorPaletteCode; + @JsonProperty("colorPaletteId") + private Object colorPaletteId; + @JsonProperty("plots") + private List<Plot> plots = null; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("id") + public Integer getId() { + return id; + } + + @JsonProperty("id") + public void setId(Integer id) { + this.id = id; + } + + @JsonProperty("vizType") + public String getVizType() { + return vizType; + } + + @JsonProperty("vizType") + public void setVizType(String vizType) { + this.vizType = vizType; + } + + @JsonProperty("headerName") + public String getHeaderName() { + return headerName; + } + + @JsonProperty("headerName") + public void setHeaderName(String headerName) { + this.headerName = headerName; + } + + @JsonProperty("headerValue") + public String getHeaderValue() { + return headerValue; + } + + @JsonProperty("headerValue") + public void setHeaderValue(String headerValue) { + this.headerValue = headerValue; + } + + @JsonProperty("headerSymbol") + public String getHeaderSymbol() { + return headerSymbol; + } + + @JsonProperty("headerSymbol") + public void setHeaderSymbol(String headerSymbol) { + this.headerSymbol = headerSymbol; + } + + @JsonProperty("colorPaletteCode") + public String getColorPaletteCode() { + return colorPaletteCode; + } + + @JsonProperty("colorPaletteCode") + public void setColorPaletteCode(String colorPaletteCode) { + this.colorPaletteCode = colorPaletteCode; + } + + @JsonProperty("colorPaletteId") + public Object getColorPaletteId() { + return colorPaletteId; + } + + @JsonProperty("colorPaletteId") + public void setColorPaletteId(Object colorPaletteId) { + this.colorPaletteId = colorPaletteId; + } + + @JsonProperty("plots") + public List<Plot> getPlots() { + return plots; + } + + @JsonProperty("plots") + public void setPlots(List<Plot> plots) { + this.plots = plots; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/model/FormData.java b/src/main/java/com/tarento/formservice/model/FormData.java new file mode 100644 index 0000000000000000000000000000000000000000..cce32b986c6453188dc5728186116e6b8be282cc --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/FormData.java @@ -0,0 +1,29 @@ +package com.tarento.formservice.model; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.ALWAYS) +public class FormData { + private String eid; + private Long id; + private Long customer; + private String customerName; + private String customerEmail; + private Long agent; + private String agentName; + private Long interactionDate; + private Long linkSentDate; + private String urlCode; + private String formData; +} diff --git a/src/main/java/com/tarento/formservice/model/FormDetail.java b/src/main/java/com/tarento/formservice/model/FormDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..7e639712d2caa088c7dc841870b8242d1b8dfca2 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/FormDetail.java @@ -0,0 +1,207 @@ + +package com.tarento.formservice.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "file_name", "fileCode", "form_id", "file_format", "isFormIdPresentFileName", "esIndexName", + "esIndexDocType", "kafkaTopic", "kakfkaKey", "description", "action" }) +public class FormDetail implements Serializable { + + @JsonProperty("file_name") + private String fileName; + @JsonProperty("fileCode") + private String fileCode; + @JsonProperty("form_id") + private String formId; + @JsonProperty("file_format") + private String fileFormat; + @JsonProperty("isFormIdPresentFileName") + private Boolean isFormIdPresentFileName; + @JsonProperty("esIndexName") + private String esIndexName; + @JsonProperty("esIndexDocType") + private String esIndexDocType; + @JsonProperty("kafkaTopic") + private String kafkaTopic; + @JsonProperty("kakfkaKey") + private String kakfkaKey; + @JsonProperty("description") + private String description; + @JsonProperty("action") + private String action; + private static final long serialVersionUID = 366110758009975933L; + + @JsonProperty("file_name") + public String getFileName() { + return fileName; + } + + @JsonProperty("file_name") + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public FormDetail withFileName(String fileName) { + this.fileName = fileName; + return this; + } + + @JsonProperty("fileCode") + public String getFileCode() { + return fileCode; + } + + @JsonProperty("fileCode") + public void setFileCode(String fileCode) { + this.fileCode = fileCode; + } + + public FormDetail withFileCode(String fileCode) { + this.fileCode = fileCode; + return this; + } + + @JsonProperty("form_id") + public String getFormId() { + return formId; + } + + @JsonProperty("form_id") + public void setFormId(String formId) { + this.formId = formId; + } + + public FormDetail withFormId(String formId) { + this.formId = formId; + return this; + } + + @JsonProperty("file_format") + public String getFileFormat() { + return fileFormat; + } + + @JsonProperty("file_format") + public void setFileFormat(String fileFormat) { + this.fileFormat = fileFormat; + } + + public FormDetail withFileFormat(String fileFormat) { + this.fileFormat = fileFormat; + return this; + } + + @JsonProperty("isFormIdPresentFileName") + public Boolean getIsFormIdPresentFileName() { + return isFormIdPresentFileName; + } + + @JsonProperty("isFormIdPresentFileName") + public void setIsFormIdPresentFileName(Boolean isFormIdPresentFileName) { + this.isFormIdPresentFileName = isFormIdPresentFileName; + } + + public FormDetail withIsFormIdPresentFileName(Boolean isFormIdPresentFileName) { + this.isFormIdPresentFileName = isFormIdPresentFileName; + return this; + } + + @JsonProperty("esIndexName") + public String getEsIndexName() { + return esIndexName; + } + + @JsonProperty("esIndexName") + public void setEsIndexName(String esIndexName) { + this.esIndexName = esIndexName; + } + + public FormDetail withEsIndexName(String esIndexName) { + this.esIndexName = esIndexName; + return this; + } + + @JsonProperty("esIndexDocType") + public String getEsIndexDocType() { + return esIndexDocType; + } + + @JsonProperty("esIndexDocType") + public void setEsIndexDocType(String esIndexDocType) { + this.esIndexDocType = esIndexDocType; + } + + public FormDetail withEsIndexDocType(String esIndexDocType) { + this.esIndexDocType = esIndexDocType; + return this; + } + + @JsonProperty("kafkaTopic") + public String getKafkaTopic() { + return kafkaTopic; + } + + @JsonProperty("kafkaTopic") + public void setKafkaTopic(String kafkaTopic) { + this.kafkaTopic = kafkaTopic; + } + + public FormDetail withKafkaTopic(String kafkaTopic) { + this.kafkaTopic = kafkaTopic; + return this; + } + + @JsonProperty("kakfkaKey") + public String getKakfkaKey() { + return kakfkaKey; + } + + @JsonProperty("kakfkaKey") + public void setKakfkaKey(String kakfkaKey) { + this.kakfkaKey = kakfkaKey; + } + + public FormDetail withKakfkaKey(String kakfkaKey) { + this.kakfkaKey = kakfkaKey; + return this; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + public FormDetail withDescription(String description) { + this.description = description; + return this; + } + + @JsonProperty("action") + public String getAction() { + return action; + } + + @JsonProperty("action") + public void setAction(String action) { + this.action = action; + } + + public FormDetail withAction(String action) { + this.action = action; + return this; + } + +} diff --git a/src/main/java/com/tarento/formservice/model/FormModel.java b/src/main/java/com/tarento/formservice/model/FormModel.java new file mode 100644 index 0000000000000000000000000000000000000000..471ee3b25bc4209016e25e2f798bc56e9cfff331 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/FormModel.java @@ -0,0 +1,37 @@ + +package com.tarento.formservice.model; + +import java.io.Serializable; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "formDetails" }) +public class FormModel implements Serializable { + + @JsonProperty("formDetails") + private List<FormDetail> formDetails = null; + private static final long serialVersionUID = -1434084318938862789L; + + @JsonProperty("formDetails") + public List<FormDetail> getFormDetails() { + return formDetails; + } + + @JsonProperty("formDetails") + public void setFormDetails(List<FormDetail> formDetails) { + this.formDetails = formDetails; + } + + public FormModel withFormDetails(List<FormDetail> formDetails) { + this.formDetails = formDetails; + return this; + } + +} diff --git a/src/main/java/com/tarento/formservice/model/IncomingData.java b/src/main/java/com/tarento/formservice/model/IncomingData.java new file mode 100644 index 0000000000000000000000000000000000000000..9b0f21e1f06138cd09814955800716e6488900c6 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/IncomingData.java @@ -0,0 +1,47 @@ +package com.tarento.formservice.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.ALWAYS) +public class IncomingData { + + private Long id; + private String recordId; + private Long customerId; + private String customerName; + private Long agentId; + private String agentName; + private String approval; + private Long approvedBy; + private Long approvedTime; + private String challenge; + private Long challengeVerifiedBy; + private Boolean challengeStatus; + private Long challengeVerifiedTime; + private String reasonForChallenge; + private String reasonForApprovalRejection; + private String adminReply; + private Long adminReplyTime; + private int version; + private Long timestamp; + private Object dataObject; + private String formData; + private Long upvoteCount; + private Long downvoteCount; + private List<Vote> upvotes; + private List<Vote> downvotes; + private List<ReplyFeedbackDto> replies; +} diff --git a/src/main/java/com/tarento/formservice/model/Layout.java b/src/main/java/com/tarento/formservice/model/Layout.java new file mode 100644 index 0000000000000000000000000000000000000000..d72a9e1fa026dee16206dd6c12854d47e073247c --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Layout.java @@ -0,0 +1,65 @@ + +package com.tarento.formservice.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Generated; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "id", + "rowDetails" +}) +@Generated("jsonschema2pojo") +public class Layout { + + @JsonProperty("id") + private Integer id; + @JsonProperty("rowDetails") + private List<RowDetail> rowDetails = null; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("id") + public Integer getId() { + return id; + } + + @JsonProperty("id") + public void setId(Integer id) { + this.id = id; + } + + @JsonProperty("rowDetails") + public List<RowDetail> getRowDetails() { + return rowDetails; + } + + @JsonProperty("rowDetails") + public void setRowDetails(List<RowDetail> rowDetails) { + this.rowDetails = rowDetails; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/model/OverviewCount.java b/src/main/java/com/tarento/formservice/model/OverviewCount.java new file mode 100644 index 0000000000000000000000000000000000000000..504cd337f791710564163784201738a50e5d80c0 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/OverviewCount.java @@ -0,0 +1,28 @@ +package com.tarento.formservice.model; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class OverviewCount { + + private int pendingApproval; + private int approvalSum; + private int pendingChallenge; + private int challengeSum; + + private int reviewsReceived; + private double averageRating; + private int reviewsChallenged; + private int customersInteracted; +} diff --git a/src/main/java/com/tarento/formservice/model/Plot.java b/src/main/java/com/tarento/formservice/model/Plot.java new file mode 100644 index 0000000000000000000000000000000000000000..dbc4a8aed33945514e9be8a79803ed5ecf0d7b4f --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Plot.java @@ -0,0 +1,155 @@ + +package com.tarento.formservice.model; + +import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Generated; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "label", + "name", + "value", + "valueLabel", + "symbol", + "parentName", + "parentLabel", + "isPercentage", + "colorCode" +}) +@Generated("jsonschema2pojo") +public class Plot { + + @JsonProperty("label") + private String label; + @JsonProperty("name") + private String name; + @JsonProperty("value") + private Integer value; + @JsonProperty("valueLabel") + private String valueLabel; + @JsonProperty("symbol") + private String symbol; + @JsonProperty("parentName") + private Object parentName; + @JsonProperty("parentLabel") + private Object parentLabel; + @JsonProperty("isPercentage") + private Boolean isPercentage; + @JsonProperty("colorCode") + private String colorCode; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("label") + public String getLabel() { + return label; + } + + @JsonProperty("label") + public void setLabel(String label) { + this.label = label; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("value") + public Integer getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(Integer value) { + this.value = value; + } + + @JsonProperty("valueLabel") + public String getValueLabel() { + return valueLabel; + } + + @JsonProperty("valueLabel") + public void setValueLabel(String valueLabel) { + this.valueLabel = valueLabel; + } + + @JsonProperty("symbol") + public String getSymbol() { + return symbol; + } + + @JsonProperty("symbol") + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + @JsonProperty("parentName") + public Object getParentName() { + return parentName; + } + + @JsonProperty("parentName") + public void setParentName(Object parentName) { + this.parentName = parentName; + } + + @JsonProperty("parentLabel") + public Object getParentLabel() { + return parentLabel; + } + + @JsonProperty("parentLabel") + public void setParentLabel(Object parentLabel) { + this.parentLabel = parentLabel; + } + + @JsonProperty("isPercentage") + public Boolean getIsPercentage() { + return isPercentage; + } + + @JsonProperty("isPercentage") + public void setIsPercentage(Boolean isPercentage) { + this.isPercentage = isPercentage; + } + + @JsonProperty("colorCode") + public String getColorCode() { + return colorCode; + } + + @JsonProperty("colorCode") + public void setColorCode(String colorCode) { + this.colorCode = colorCode; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/model/ReplyFeedbackDto.java b/src/main/java/com/tarento/formservice/model/ReplyFeedbackDto.java new file mode 100644 index 0000000000000000000000000000000000000000..f95a5c7268010a3ee6cf66fabdf7d58721bb5b0f --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/ReplyFeedbackDto.java @@ -0,0 +1,24 @@ +package com.tarento.formservice.model; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ReplyFeedbackDto { + private String recordId; + private String reply; + private Long userId; + private String username; + private Long replyDate; + +} diff --git a/src/main/java/com/tarento/formservice/model/ResponseData.java b/src/main/java/com/tarento/formservice/model/ResponseData.java new file mode 100644 index 0000000000000000000000000000000000000000..cb84782ebf45818fd15ce17b09cf14d13efcdef0 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/ResponseData.java @@ -0,0 +1,380 @@ +package com.tarento.formservice.model; + +import java.util.List; + +import javax.annotation.Generated; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "id", "username", "password", "emailId", "phoneNo", "orgId", "countryCode", "timeZone", + "avatarUrl", "isActive", "isDeleted", "profileId", "firstName", "lastName", "age", "dob", "gender", "startDate", + "endDate", "salary", "country", "registrationDate", "employmentType", "createdDate", "createdBy", "updatedDate", + "updatedBy", "roles", "countryId", "authToken" }) +@Generated("jsonschema2pojo") +public class ResponseData { + + @JsonProperty("id") + private Long id; + @JsonProperty("username") + private String username; + @JsonProperty("password") + private Object password; + @JsonProperty("emailId") + private String emailId; + @JsonProperty("phoneNo") + private String phoneNo; + @JsonProperty("orgId") + private Object orgId; + @JsonProperty("countryCode") + private Object countryCode; + @JsonProperty("timeZone") + private String timeZone; + @JsonProperty("avatarUrl") + private Object avatarUrl; + @JsonProperty("isActive") + private Boolean isActive; + @JsonProperty("isDeleted") + private Boolean isDeleted; + @JsonProperty("profileId") + private Object profileId; + @JsonProperty("firstName") + private String firstName; + @JsonProperty("lastName") + private String lastName; + @JsonProperty("age") + private Long age; + @JsonProperty("dob") + private Object dob; + @JsonProperty("gender") + private Object gender; + @JsonProperty("startDate") + private Object startDate; + @JsonProperty("endDate") + private Object endDate; + @JsonProperty("salary") + private Object salary; + @JsonProperty("country") + private Object country; + @JsonProperty("registrationDate") + private Object registrationDate; + @JsonProperty("employmentType") + private Object employmentType; + @JsonProperty("createdDate") + private Object createdDate; + @JsonProperty("createdBy") + private Long createdBy; + @JsonProperty("updatedDate") + private Object updatedDate; + @JsonProperty("updatedBy") + private Long updatedBy; + @JsonProperty("roles") + private List<Role> roles = null; + @JsonProperty("countryId") + private Object countryId; + @JsonProperty("authToken") + private Object authToken; + + @JsonProperty("id") + public Long getId() { + return id; + } + + @JsonProperty("id") + public void setId(Long id) { + this.id = id; + } + + @JsonProperty("username") + public String getUsername() { + return username; + } + + @JsonProperty("username") + public void setUsername(String username) { + this.username = username; + } + + @JsonProperty("password") + public Object getPassword() { + return password; + } + + @JsonProperty("password") + public void setPassword(Object password) { + this.password = password; + } + + @JsonProperty("emailId") + public String getEmailId() { + return emailId; + } + + @JsonProperty("emailId") + public void setEmailId(String emailId) { + this.emailId = emailId; + } + + @JsonProperty("phoneNo") + public String getPhoneNo() { + return phoneNo; + } + + @JsonProperty("phoneNo") + public void setPhoneNo(String phoneNo) { + this.phoneNo = phoneNo; + } + + @JsonProperty("orgId") + public Object getOrgId() { + return orgId; + } + + @JsonProperty("orgId") + public void setOrgId(Object orgId) { + this.orgId = orgId; + } + + @JsonProperty("countryCode") + public Object getCountryCode() { + return countryCode; + } + + @JsonProperty("countryCode") + public void setCountryCode(Object countryCode) { + this.countryCode = countryCode; + } + + @JsonProperty("timeZone") + public String getTimeZone() { + return timeZone; + } + + @JsonProperty("timeZone") + public void setTimeZone(String timeZone) { + this.timeZone = timeZone; + } + + @JsonProperty("avatarUrl") + public Object getAvatarUrl() { + return avatarUrl; + } + + @JsonProperty("avatarUrl") + public void setAvatarUrl(Object avatarUrl) { + this.avatarUrl = avatarUrl; + } + + @JsonProperty("isActive") + public Boolean getIsActive() { + return isActive; + } + + @JsonProperty("isActive") + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + @JsonProperty("isDeleted") + public Boolean getIsDeleted() { + return isDeleted; + } + + @JsonProperty("isDeleted") + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + @JsonProperty("profileId") + public Object getProfileId() { + return profileId; + } + + @JsonProperty("profileId") + public void setProfileId(Object profileId) { + this.profileId = profileId; + } + + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + + @JsonProperty("firstName") + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + + @JsonProperty("lastName") + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @JsonProperty("age") + public Long getAge() { + return age; + } + + @JsonProperty("age") + public void setAge(Long age) { + this.age = age; + } + + @JsonProperty("dob") + public Object getDob() { + return dob; + } + + @JsonProperty("dob") + public void setDob(Object dob) { + this.dob = dob; + } + + @JsonProperty("gender") + public Object getGender() { + return gender; + } + + @JsonProperty("gender") + public void setGender(Object gender) { + this.gender = gender; + } + + @JsonProperty("startDate") + public Object getStartDate() { + return startDate; + } + + @JsonProperty("startDate") + public void setStartDate(Object startDate) { + this.startDate = startDate; + } + + @JsonProperty("endDate") + public Object getEndDate() { + return endDate; + } + + @JsonProperty("endDate") + public void setEndDate(Object endDate) { + this.endDate = endDate; + } + + @JsonProperty("salary") + public Object getSalary() { + return salary; + } + + @JsonProperty("salary") + public void setSalary(Object salary) { + this.salary = salary; + } + + @JsonProperty("country") + public Object getCountry() { + return country; + } + + @JsonProperty("country") + public void setCountry(Object country) { + this.country = country; + } + + @JsonProperty("registrationDate") + public Object getRegistrationDate() { + return registrationDate; + } + + @JsonProperty("registrationDate") + public void setRegistrationDate(Object registrationDate) { + this.registrationDate = registrationDate; + } + + @JsonProperty("employmentType") + public Object getEmploymentType() { + return employmentType; + } + + @JsonProperty("employmentType") + public void setEmploymentType(Object employmentType) { + this.employmentType = employmentType; + } + + @JsonProperty("createdDate") + public Object getCreatedDate() { + return createdDate; + } + + @JsonProperty("createdDate") + public void setCreatedDate(Object createdDate) { + this.createdDate = createdDate; + } + + @JsonProperty("createdBy") + public Long getCreatedBy() { + return createdBy; + } + + @JsonProperty("createdBy") + public void setCreatedBy(Long createdBy) { + this.createdBy = createdBy; + } + + @JsonProperty("updatedDate") + public Object getUpdatedDate() { + return updatedDate; + } + + @JsonProperty("updatedDate") + public void setUpdatedDate(Object updatedDate) { + this.updatedDate = updatedDate; + } + + @JsonProperty("updatedBy") + public Long getUpdatedBy() { + return updatedBy; + } + + @JsonProperty("updatedBy") + public void setUpdatedBy(Long updatedBy) { + this.updatedBy = updatedBy; + } + + @JsonProperty("roles") + public List<Role> getRoles() { + return roles; + } + + @JsonProperty("roles") + public void setRoles(List<Role> roles) { + this.roles = roles; + } + + @JsonProperty("countryId") + public Object getCountryId() { + return countryId; + } + + @JsonProperty("countryId") + public void setCountryId(Object countryId) { + this.countryId = countryId; + } + + @JsonProperty("authToken") + public Object getAuthToken() { + return authToken; + } + + @JsonProperty("authToken") + public void setAuthToken(Object authToken) { + this.authToken = authToken; + } + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/model/Result.java b/src/main/java/com/tarento/formservice/model/Result.java new file mode 100644 index 0000000000000000000000000000000000000000..21d216f1ad828c4ca3f490d55b7c5234a6da413a --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Result.java @@ -0,0 +1,32 @@ +package com.tarento.formservice.model; + +import org.apache.commons.lang.builder.ToStringBuilder; + +public class Result { + + private StatusInfo statusInfo; + private ResponseData responseData; + + public StatusInfo getStatusInfo() { + return statusInfo; + } + + public void setStatusInfo(StatusInfo statusInfo) { + this.statusInfo = statusInfo; + } + + public ResponseData getResponseData() { + return responseData; + } + + public void setResponseData(ResponseData responseData) { + this.responseData = responseData; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("statusInfo", statusInfo).append("responseData", responseData) + .toString(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/model/Role.java b/src/main/java/com/tarento/formservice/model/Role.java new file mode 100644 index 0000000000000000000000000000000000000000..1c5678bc68e9ac6756a443e4fd9dda4ea201fd87 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Role.java @@ -0,0 +1,42 @@ +package com.tarento.formservice.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "id", "description", "code", "name", "orgId", "createdBy", "admin", "superAdmin", "isAdmin" }) +public class Role { + + @JsonProperty("id") + public Long id; + @JsonProperty("description") + public String description; + @JsonProperty("code") + public Object code; + @JsonProperty("name") + public String name; + @JsonProperty("orgId") + public Object orgId; + @JsonProperty("createdBy") + public Object createdBy; + @JsonProperty("admin") + public Boolean admin; + @JsonProperty("superAdmin") + public Boolean superAdmin; + @JsonProperty("isAdmin") + public Boolean isAdmin; + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/model/RowDetail.java b/src/main/java/com/tarento/formservice/model/RowDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..b937a829e06151c371a5e52eb4f1a4b7cb87b7c0 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/RowDetail.java @@ -0,0 +1,90 @@ + +package com.tarento.formservice.model; + +import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Generated; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "id", + "title", + "description", + "data" +}) +@Generated("jsonschema2pojo") +public class RowDetail { + + @JsonProperty("id") + private Integer id; + @JsonProperty("title") + private String title; + @JsonProperty("description") + private String description; + @JsonProperty("chart") + private Chart chart; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("id") + public Integer getId() { + return id; + } + + @JsonProperty("id") + public void setId(Integer id) { + this.id = id; + } + + @JsonProperty("title") + public String getTitle() { + return title; + } + + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + @JsonProperty("chart") + public Chart getChart() { + return chart; + } + + @JsonProperty("chart") + public void setChart(Chart chart) { + this.chart = chart; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/model/StatusInfo.java b/src/main/java/com/tarento/formservice/model/StatusInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..913ff9765062278091e76ef543e56c911de50433 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/StatusInfo.java @@ -0,0 +1,40 @@ +package com.tarento.formservice.model; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class StatusInfo { + + private Long statusCode; + private String statusMessage; + private String errorMessage; + + public Long getStatusCode() { + return statusCode; + } + + public void setStatusCode(Long statusCode) { + this.statusCode = statusCode; + } + + public String getStatusMessage() { + return statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("statusCode", statusCode).append("statusMessage", statusMessage) + .append("errorMessage", errorMessage).toString(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/model/User.java b/src/main/java/com/tarento/formservice/model/User.java new file mode 100644 index 0000000000000000000000000000000000000000..7aac107556155d26a6e6d19bec4d9e8096fa4be2 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/User.java @@ -0,0 +1,124 @@ +package com.tarento.formservice.model; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * This class holds the information about the User's basic authentication along + * with Mail ID. + * + * @author Darshan Nagesh + * + */ +public class User { + + private Long id; + private String username; + private String password; + private String emailId; + private String phoneNo; + private String orgId; + private String countryCode; + private String timeZone; + private String avatarUrl; + private Boolean isActive; + private Boolean isDeleted; + + public String getAvatarUrl() { + return avatarUrl; + } + + public void setAvatarUrl(String avatarUrl) { + this.avatarUrl = avatarUrl; + } + + public String getTimeZone() { + return timeZone; + } + + public void setTimeZone(String timeZone) { + this.timeZone = timeZone; + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + @JsonProperty("authToken") + private String authToken; + + public String getOrgId() { + return orgId; + } + + public void setOrgId(String orgId) { + this.orgId = orgId; + } + + public String getAuthToken() { + return authToken; + } + + public void setAuthToken(String authToken) { + this.authToken = authToken; + } + + public Boolean getIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + public Boolean getIsDeleted() { + return isDeleted; + } + + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public String getPhoneNo() { + return phoneNo; + } + + public void setPhoneNo(String phoneNo) { + this.phoneNo = phoneNo; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getEmailId() { + return emailId; + } + + public void setEmailId(String emailId) { + this.emailId = emailId; + } + +} diff --git a/src/main/java/com/tarento/formservice/model/UserInfo.java b/src/main/java/com/tarento/formservice/model/UserInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..03c69ec120eb956ac9d33d0c8da53212da10b6ae --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/UserInfo.java @@ -0,0 +1,47 @@ +package com.tarento.formservice.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "timeZone", "id", "userName", "name", "type", "mobileNumber", "authToken", "emailId", "orgId", + "roles" }) +public class UserInfo { + + @JsonProperty("timeZone") + public Object timeZone; + @JsonProperty("id") + public Long id; + @JsonProperty("userName") + public String userName; + @JsonProperty("name") + public Object name; + @JsonProperty("type") + public Object type; + @JsonProperty("mobileNumber") + public Object mobileNumber; + @JsonProperty("authToken") + public String authToken; + @JsonProperty("emailId") + public String emailId; + @JsonProperty("orgId") + public String orgId; + @JsonProperty("roles") + public List<Role> roles = null; + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/model/UserProfile.java b/src/main/java/com/tarento/formservice/model/UserProfile.java new file mode 100644 index 0000000000000000000000000000000000000000..f291ac56bc0edefd9456a7f296b137c07ed24ffd --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/UserProfile.java @@ -0,0 +1,38 @@ +package com.tarento.formservice.model; + +import java.util.Date; +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class UserProfile extends User { + private Long profileId; + private String firstName; + private String lastName; + private int age; + private String dob; + private String gender; + private String avatarUrl; + private Date startDate; + private Date endDate; + private Long salary; + private String country; + private Date registrationDate; + private String employmentType; + private Date createdDate; + private Long createdBy; + private Date updatedDate; + private Long updatedBy; + private List<Role> roles; + private String countryCode; + private Long countryId; +} diff --git a/src/main/java/com/tarento/formservice/model/VerifyFeedbackDto.java b/src/main/java/com/tarento/formservice/model/VerifyFeedbackDto.java new file mode 100644 index 0000000000000000000000000000000000000000..dda1071d731272c1d128a3ed1ca6cfe0c2ae08a4 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/VerifyFeedbackDto.java @@ -0,0 +1,23 @@ +package com.tarento.formservice.model; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.ALWAYS) +public class VerifyFeedbackDto { + private String id; + private String condition; + private String status; + private String reasonForChallenge; + private String reasonForApprovalRejection; +} diff --git a/src/main/java/com/tarento/formservice/model/Vote.java b/src/main/java/com/tarento/formservice/model/Vote.java new file mode 100644 index 0000000000000000000000000000000000000000..f49977680c5f5375809919adb4c992927e3e0ec5 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/Vote.java @@ -0,0 +1,21 @@ +package com.tarento.formservice.model; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.ALWAYS) +public class Vote { + private Long customerId; + private Long voteDate; + private String vote; +} diff --git a/src/main/java/com/tarento/formservice/model/VoteFeedbackDto.java b/src/main/java/com/tarento/formservice/model/VoteFeedbackDto.java new file mode 100644 index 0000000000000000000000000000000000000000..2ab30075740a29060cb5a515ddaf21b42ee78512 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/VoteFeedbackDto.java @@ -0,0 +1,22 @@ +package com.tarento.formservice.model; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.ALWAYS) +public class VoteFeedbackDto { + private String recordId; + private Long customerId; + private String action; + private String vote; +} diff --git a/src/main/java/com/tarento/formservice/model/VotesList.java b/src/main/java/com/tarento/formservice/model/VotesList.java new file mode 100644 index 0000000000000000000000000000000000000000..8e9c2973f7800030720e5acb38fd06925dfd0154 --- /dev/null +++ b/src/main/java/com/tarento/formservice/model/VotesList.java @@ -0,0 +1,23 @@ +package com.tarento.formservice.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.ALWAYS) +public class VotesList { + + private List<Vote> votes; + +} diff --git a/src/main/java/com/tarento/formservice/models/Collection.java b/src/main/java/com/tarento/formservice/models/Collection.java new file mode 100644 index 0000000000000000000000000000000000000000..d7846bcf75b449ca8abc7e6ff4fc118389efb5eb --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/Collection.java @@ -0,0 +1,113 @@ +package com.tarento.formservice.models; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Collection { + + @JsonProperty("id") + private Long id; + @JsonProperty("name") + private String name; + @JsonProperty("description") + private String description; + @JsonProperty("isActive") + private Boolean isActive; + @JsonProperty("isDeleted") + private Boolean isDeleted; + @JsonProperty("isPrimary") + private Boolean isPrimary; + @JsonProperty("backgroundImage") + private String backgroundImage; + @JsonProperty("backgroundColor") + private String backgroundColor; + @JsonProperty("projectList") + private List<Long> projectList; + @JsonProperty("projectInfoList") + private List<Object> projectInfoList; + @JsonProperty("serviceList") + private List<Long> serviceList; + @JsonProperty("serviceInfoList") + private List<Object> serviceInfoList; + + public List<Long> getServiceList() { + return serviceList; + } + public void setServiceList(List<Long> serviceList) { + this.serviceList = serviceList; + } + public List<Object> getServiceInfoList() { + return serviceInfoList; + } + public void setServiceInfoList(List<Object> serviceInfoList) { + this.serviceInfoList = serviceInfoList; + } + public Boolean getIsPrimary() { + return isPrimary; + } + public void setIsPrimary(Boolean isPrimary) { + this.isPrimary = isPrimary; + } + public String getBackgroundImage() { + return backgroundImage; + } + public void setBackgroundImage(String backgroundImage) { + this.backgroundImage = backgroundImage; + } + public String getBackgroundColor() { + return backgroundColor; + } + public void setBackgroundColor(String backgroundColor) { + this.backgroundColor = backgroundColor; + } + public List<Object> getProjectInfoList() { + return projectInfoList; + } + public void setProjectInfoList(List<Object> projectInfoList) { + this.projectInfoList = projectInfoList; + } + public List<Long> getProjectList() { + return projectList; + } + public void setProjectList(List<Long> projectList) { + this.projectList = projectList; + } + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public Boolean getIsActive() { + return isActive; + } + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + public Boolean getIsDeleted() { + return isDeleted; + } + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/models/Content.java b/src/main/java/com/tarento/formservice/models/Content.java new file mode 100644 index 0000000000000000000000000000000000000000..1a3035782c739211e49747f013b0d7723dd81dc4 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/Content.java @@ -0,0 +1,80 @@ +package com.tarento.formservice.models; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "key", "value", "type", "dataNodes" }) +public class Content { + + @JsonProperty("key") + private String key; + @JsonProperty("value") + private String value; + @JsonProperty("type") + private String type; + @JsonProperty("dataNodes") + private List<DataNode> dataNodes; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + public String getType() { + return type; + } + + @JsonProperty("dataNodes") + public List<DataNode> getDataNodes() { + return dataNodes; + } + + @JsonProperty("dataPoints") + public void setDataNodes(List<DataNode> dataNodes) { + this.dataNodes = dataNodes; + } + + public void setType(String type) { + this.type = type; + } + + @JsonProperty("key") + public String getKey() { + return key; + } + + @JsonProperty("key") + public void setKey(String key) { + this.key = key; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/models/DataNode.java b/src/main/java/com/tarento/formservice/models/DataNode.java new file mode 100644 index 0000000000000000000000000000000000000000..502d4aa31fc7c84f44fbb90a963b1111f3cc4b51 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/DataNode.java @@ -0,0 +1,42 @@ +package com.tarento.formservice.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class DataNode { + + @JsonProperty("key") + private String key; + + @JsonProperty("value") + private String value; + + @JsonProperty("dataType") + private String dataType; + + @JsonProperty("key") + public String getKey() { + return key; + } + @JsonProperty("key") + public void setKey(String key) { + this.key = key; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + @JsonProperty("dataType") + public String getDataType() { + return dataType; + } + @JsonProperty("dataType") + public void setDataType(String dataType) { + this.dataType = dataType; + } +} diff --git a/src/main/java/com/tarento/formservice/models/DataObject.java b/src/main/java/com/tarento/formservice/models/DataObject.java new file mode 100644 index 0000000000000000000000000000000000000000..290a01b578ec570da8a6bccd985dcaf2ba885ab6 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/DataObject.java @@ -0,0 +1,44 @@ +package com.tarento.formservice.models; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class DataObject { + + @JsonProperty("dataContext") + private String dataContext; + + @JsonProperty("dataContextVersion") + private String dataContextVersion; + + @JsonProperty("contents") + private List<Content> contents; + + @JsonProperty("dataContext") + public String getDataContext() { + return dataContext; + } + @JsonProperty("dataContext") + public void setDataContext(String dataContext) { + this.dataContext = dataContext; + } + + @JsonProperty("dataContextVersion") + public String getDataContextVersion() { + return dataContextVersion; + } + @JsonProperty("dataContextVersion") + public void setDataContextVersion(String dataContextVersion) { + this.dataContextVersion = dataContextVersion; + } + + @JsonProperty("contents") + public List<Content> getContents() { + return contents; + } + @JsonProperty("contents") + public void setContents(List<Content> contents) { + this.contents = contents; + } +} diff --git a/src/main/java/com/tarento/formservice/models/Field.java b/src/main/java/com/tarento/formservice/models/Field.java new file mode 100644 index 0000000000000000000000000000000000000000..a22fc8dc191c82a57d432fa1209ff3f045eab83a --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/Field.java @@ -0,0 +1,126 @@ +package com.tarento.formservice.models; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "refApi", "logicalGroupCode", "name", "fieldType", "values", "order" }) +public class Field { + + @JsonProperty("refApi") + private String refApi; + @JsonProperty("logicalGroupCode") + private String logicalGroupCode; + @JsonProperty("name") + private String name; + @JsonProperty("fieldType") + private String fieldType; + @JsonProperty("values") + private List<Value> values = null; + @JsonProperty("isRequired") + private Boolean isRequired; + @JsonProperty("order") + private Integer order; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("isRequired") + public Boolean getIsRequired() { + return isRequired; + } + + @JsonProperty("isRequired") + public void setIsRequired(Boolean isRequired) { + this.isRequired = isRequired; + } + + @JsonProperty("refApi") + public String getRefApi() { + return refApi; + } + + @JsonProperty("refApi") + public void setRefApi(String refApi) { + this.refApi = refApi; + } + + @JsonProperty("logicalGroupCode") + public String getLogicalGroupCode() { + return logicalGroupCode; + } + + @JsonProperty("logicalGroupCode") + public void setLogicalGroupCode(String logicalGroupCode) { + this.logicalGroupCode = logicalGroupCode; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("fieldType") + public String getFieldType() { + return fieldType; + } + + @JsonProperty("fieldType") + public void setFieldType(String fieldType) { + this.fieldType = fieldType; + } + + @JsonProperty("values") + public List<Value> getValues() { + return values; + } + + @JsonProperty("values") + public void setValues(List<Value> values) { + this.values = values; + } + + @JsonProperty("order") + public Integer getOrder() { + return order; + } + + @JsonProperty("order") + public void setOrder(Integer order) { + this.order = order; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return "Field [refApi=" + refApi + ", logicalGroupCode=" + logicalGroupCode + ", name=" + name + ", fieldType=" + + fieldType + ", values=" + values + ", isRequired=" + isRequired + ", order=" + order + + ", additionalProperties=" + additionalProperties + "]"; + } + + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/models/Form.java b/src/main/java/com/tarento/formservice/models/Form.java new file mode 100644 index 0000000000000000000000000000000000000000..0532f50f5b5826aa3f43ff669f3785fcda5ad62e --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/Form.java @@ -0,0 +1,74 @@ +package com.tarento.formservice.models; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "id", "title", "version", "numberOfRecords"}) +public class Form { + + @JsonProperty("id") + private Long id; + @JsonProperty("title") + private String title; + @JsonProperty("version") + private int version; + @JsonProperty("numberOfRecords") + private Long numberOfRecords; + @JsonProperty("secondaryId") + private String secondaryId; + + @JsonProperty("secondaryId") + public String getSecondaryId() { + return secondaryId; + } + + @JsonProperty("secondaryId") + public void setSecondaryId(String secondaryId) { + this.secondaryId = secondaryId; + } + + @JsonProperty("numberOfRecords") + public Long getNumberOfRecords() { + return numberOfRecords; + } + + @JsonProperty("numberOfRecords") + public void setNumberOfRecords(Long numberOfRecords) { + this.numberOfRecords = numberOfRecords; + } + + @JsonProperty("version") + public int getVersion() { + return version; + } + + @JsonProperty("version") + public void setVersion(int version) { + this.version = version; + } + + @JsonProperty("id") + public Long getId() { + return id; + } + + @JsonProperty("id") + public void setId(Long id) { + this.id = id; + } + + @JsonProperty("title") + public String getTitle() { + return title; + } + + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/models/FormDataUploadDto.java b/src/main/java/com/tarento/formservice/models/FormDataUploadDto.java new file mode 100644 index 0000000000000000000000000000000000000000..d4f07c44bb8c432a7d1740d2bb69c43f079b2986 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/FormDataUploadDto.java @@ -0,0 +1,31 @@ +package com.tarento.formservice.models; + +import org.springframework.web.multipart.MultipartFile; + +public class FormDataUploadDto { + + private Long id; + private int version; + private MultipartFile file; + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public int getVersion() { + return version; + } + public void setVersion(int version) { + this.version = version; + } + public MultipartFile getFile() { + return file; + } + public void setFile(MultipartFile file) { + this.file = file; + } + + + +} diff --git a/src/main/java/com/tarento/formservice/models/FormDetail.java b/src/main/java/com/tarento/formservice/models/FormDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..0267f159c69d9a6f8c459a76bab1a25d248aae9f --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/FormDetail.java @@ -0,0 +1,58 @@ +package com.tarento.formservice.models; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "updatedDate", "fields"}) +public class FormDetail extends Form{ + + @JsonProperty("updatedDate") + private Long updatedDate; + @JsonProperty("fields") + private List<Field> fields = null; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("updatedDate") + public Long getUpdatedDate() { + return updatedDate; + } + + @JsonProperty("updatedDate") + public void setUpdatedDate(Long updatedDate) { + this.updatedDate = updatedDate; + } + + @JsonProperty("fields") + public List<Field> getFields() { + return fields; + } + + @JsonProperty("fields") + public void setFields(List<Field> fields) { + this.fields = fields; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/models/InformationDetail.java b/src/main/java/com/tarento/formservice/models/InformationDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..39e5753f67294db88bfd90b865ba6a82a692a0ba --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/InformationDetail.java @@ -0,0 +1,102 @@ +package com.tarento.formservice.models; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "key", "value", "dataType", "content" }) +public class InformationDetail { + + @JsonProperty("key") + private String key; + @JsonProperty("value") + private String value; + @JsonProperty("dataType") + private String dataType; + @JsonProperty("content") + private List<Content> content = null; + @JsonProperty("orientation") + private String orientation = null; + @JsonProperty("backgroundColor") + private String backgroundColor = null; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + public String getBackgroundColor() { + return backgroundColor; + } + + public void setBackgroundColor(String backgroundColor) { + this.backgroundColor = backgroundColor; + } + + public String getOrientation() { + return orientation; + } + + public void setOrientation(String orientation) { + this.orientation = orientation; + } + + @JsonProperty("key") + public String getKey() { + return key; + } + + @JsonProperty("key") + public void setKey(String key) { + this.key = key; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + @JsonProperty("dataType") + public String getDataType() { + return dataType; + } + + @JsonProperty("dataType") + public void setDataType(String dataType) { + this.dataType = dataType; + } + + @JsonProperty("content") + public List<Content> getContent() { + return content; + } + + @JsonProperty("content") + public void setContent(List<Content> content) { + this.content = content; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/src/main/java/com/tarento/formservice/models/InformationMedia.java b/src/main/java/com/tarento/formservice/models/InformationMedia.java new file mode 100644 index 0000000000000000000000000000000000000000..1c1873de287cb3cede664608cc027e6654ef21e7 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/InformationMedia.java @@ -0,0 +1,86 @@ +package com.tarento.formservice.models; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"key", +"value", +"primary", +"order" +}) +public class InformationMedia { + +@JsonProperty("key") +private String key; +@JsonProperty("value") +private String value; +@JsonProperty("primary") +private Boolean primary; +@JsonProperty("order") +private Integer order; +@JsonIgnore +private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + +@JsonProperty("key") +public String getKey() { +return key; +} + +@JsonProperty("key") +public void setKey(String key) { +this.key = key; +} + +@JsonProperty("value") +public String getValue() { +return value; +} + +@JsonProperty("value") +public void setValue(String value) { +this.value = value; +} + +@JsonProperty("primary") +public Boolean getPrimary() { +return primary; +} + +@JsonProperty("primary") +public void setPrimary(Boolean primary) { +this.primary = primary; +} + +@JsonProperty("order") +public Integer getOrder() { +return order; +} + +@JsonProperty("order") +public void setOrder(Integer order) { +this.order = order; +} + +@JsonAnyGetter +public Map<String, Object> getAdditionalProperties() { +return this.additionalProperties; +} + +@JsonAnySetter +public void setAdditionalProperty(String name, Object value) { +this.additionalProperties.put(name, value); +} + +} diff --git a/src/main/java/com/tarento/formservice/models/MetaInformation.java b/src/main/java/com/tarento/formservice/models/MetaInformation.java new file mode 100644 index 0000000000000000000000000000000000000000..0999a526773e8ef6be8b93b5cb9404770523ca59 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/MetaInformation.java @@ -0,0 +1,131 @@ +package com.tarento.formservice.models; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class MetaInformation { + + @JsonProperty("id") + private Long id = null; + @JsonProperty("version") + private Long version= null; + @JsonProperty("name") + private String name= null; + @JsonProperty("tagline") + private String tagline= null; + @JsonProperty("domain") + private String domain= null; + @JsonProperty("colorCode") + private String colorCode=null; + @JsonProperty("isFeatured") + private Boolean isFeatured=null; + @JsonProperty("isSaved") + private Boolean isSaved=null; + @JsonProperty("isPublished") + private Boolean isPublished=null; + @JsonProperty("clientName") + private String clientName=null; + @JsonProperty("clientCountry") + private String clientCountry=null; + @JsonProperty("clientLogo") + private String clientLogo=null; + @JsonProperty("tags") + private String tags=null; + + + + public String getTags() { + return tags; + } + public void setTags(String tags) { + this.tags = tags; + } + public MetaInformation() {} + public MetaInformation(Long id, String name, String domain, String tagline, String colorCode) { + this.id = id ; + this.name = name; + this.domain = domain; + this.tagline = tagline; + this.colorCode = colorCode; + } + + public String getClientName() { + return clientName; + } + public void setClientName(String clientName) { + this.clientName = clientName; + } + public String getClientCountry() { + return clientCountry; + } + public void setClientCountry(String clientCountry) { + this.clientCountry = clientCountry; + } + public String getClientLogo() { + return clientLogo; + } + public void setClientLogo(String clientLogo) { + this.clientLogo = clientLogo; + } + public Boolean getIsSaved() { + return isSaved; + } + public void setIsSaved(Boolean isSaved) { + this.isSaved = isSaved; + } + public Boolean getIsPublished() { + return isPublished; + } + public void setIsPublished(Boolean isPublished) { + this.isPublished = isPublished; + } + public Boolean getIsFeatured() { + return isFeatured; + } + public void setIsFeatured(Boolean isFeatured) { + this.isFeatured = isFeatured; + } + public String getColorCode() { + return colorCode; + } + public void setColorCode(String colorCode) { + this.colorCode = colorCode; + } + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public Long getVersion() { + return version; + } + public void setVersion(Long version) { + this.version = version; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getTagline() { + return tagline; + } + public void setTagline(String tagline) { + this.tagline = tagline; + } + public String getDomain() { + return domain; + } + public void setDomain(String domain) { + this.domain = domain; + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/models/Pack.java b/src/main/java/com/tarento/formservice/models/Pack.java new file mode 100644 index 0000000000000000000000000000000000000000..a33411e3a037e36f6977c3eb473d8f76d3b8a2e9 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/Pack.java @@ -0,0 +1,95 @@ +package com.tarento.formservice.models; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Pack { + + @JsonProperty("id") + private Long id; + @JsonProperty("name") + private String name; + @JsonProperty("description") + private String description; + @JsonProperty("coverImage") + private String coverImage; + @JsonProperty("backgroundColor") + private String backgroundColor; + @JsonProperty("isActive") + private Boolean isActive; + @JsonProperty("isDeleted") + private Boolean isDeleted; + @JsonProperty("collectionList") + private List<Long> collectionList; + @JsonProperty("collectionInfoList") + private List<Object> collectionInfoList; + @JsonProperty("distributionList") + private List<PackDistribution> distributionList; + + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getCoverImage() { + return coverImage; + } + public void setCoverImage(String coverImage) { + this.coverImage = coverImage; + } + public String getBackgroundColor() { + return backgroundColor; + } + public void setBackgroundColor(String backgroundColor) { + this.backgroundColor = backgroundColor; + } + public List<PackDistribution> getDistributionList() { + return distributionList; + } + public void setDistributionList(List<PackDistribution> distributionList) { + this.distributionList = distributionList; + } + public Boolean getIsActive() { + return isActive; + } + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + public Boolean getIsDeleted() { + return isDeleted; + } + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + public List<Long> getCollectionList() { + return collectionList; + } + public void setCollectionList(List<Long> collectionList) { + this.collectionList = collectionList; + } + public List<Object> getCollectionInfoList() { + return collectionInfoList; + } + public void setCollectionInfoList(List<Object> collectionInfoList) { + this.collectionInfoList = collectionInfoList; + } +} diff --git a/src/main/java/com/tarento/formservice/models/PackDistribution.java b/src/main/java/com/tarento/formservice/models/PackDistribution.java new file mode 100644 index 0000000000000000000000000000000000000000..fba03c7c1ce01247e451106c479157199cc5df69 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/PackDistribution.java @@ -0,0 +1,53 @@ +package com.tarento.formservice.models; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class PackDistribution { + + @JsonProperty("id") + private Long id; + @JsonProperty("purpose") + private String purpose; + @JsonProperty("url") + private String url; + @JsonProperty("isActive") + private Boolean isActive; + @JsonProperty("stats") + private List<Object> stats; + + public List<Object> getStats() { + return stats; + } + public void setStats(List<Object> stats) { + this.stats = stats; + } + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getPurpose() { + return purpose; + } + public void setPurpose(String purpose) { + this.purpose = purpose; + } + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + public Boolean getIsActive() { + return isActive; + } + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + + +} diff --git a/src/main/java/com/tarento/formservice/models/ProjectInformation.java b/src/main/java/com/tarento/formservice/models/ProjectInformation.java new file mode 100644 index 0000000000000000000000000000000000000000..eed3675e3f9021e2d59c3a9659e2c95c116527f3 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/ProjectInformation.java @@ -0,0 +1,63 @@ +package com.tarento.formservice.models; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"projectMedia", +"projectDetails" +}) +public class ProjectInformation extends MetaInformation { + + +@JsonProperty("projectMedia") +private List<InformationMedia> projectMedia = null; +@JsonProperty("projectDetails") +private List<InformationDetail> projectDetails = null; +@JsonIgnore +private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + +@JsonProperty("projectMedia") +public List<InformationMedia> getProjectMedia() { +return projectMedia; +} + +@JsonProperty("projectMedia") +public void setProjectMedia(List<InformationMedia> projectMedia) { +this.projectMedia = projectMedia; +} + +@JsonProperty("projectDetails") +public List<InformationDetail> getProjectDetails() { +return projectDetails; +} + +@JsonProperty("projectDetails") +public void setProjectDetails(List<InformationDetail> projectDetails) { +this.projectDetails = projectDetails; +} + +@JsonAnyGetter +public Map<String, Object> getAdditionalProperties() { +return this.additionalProperties; +} + +@JsonAnySetter +public void setAdditionalProperty(String name, Object value) { +this.additionalProperties.put(name, value); +} + +} diff --git a/src/main/java/com/tarento/formservice/models/ServiceInformation.java b/src/main/java/com/tarento/formservice/models/ServiceInformation.java new file mode 100644 index 0000000000000000000000000000000000000000..03e2edb298a1349ede867600703c08dd71454814 --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/ServiceInformation.java @@ -0,0 +1,61 @@ +package com.tarento.formservice.models; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"projectMedia", +"projectDetails" +}) +public class ServiceInformation extends MetaInformation { + @JsonProperty("serviceMedia") + private List<InformationMedia> serviceMedia = null; + @JsonProperty("serviceDetails") + private List<InformationDetail> serviceDetails = null; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + + @JsonProperty("serviceMedia") + public List<InformationMedia> getServiceMedia() { + return serviceMedia; + } + + @JsonProperty("serviceMedia") + public void setServiceMedia(List<InformationMedia> serviceMedia) { + this.serviceMedia = serviceMedia; + } + + @JsonProperty("serviceDetails") + public List<InformationDetail> getServiceDetails() { + return serviceDetails; + } + + @JsonProperty("serviceDetails") + public void setServiceDetails(List<InformationDetail> serviceDetails) { + this.serviceDetails = serviceDetails; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + } diff --git a/src/main/java/com/tarento/formservice/models/Value.java b/src/main/java/com/tarento/formservice/models/Value.java new file mode 100644 index 0000000000000000000000000000000000000000..3bd4cd6f6ccde07cfd4d69482585760931e4812d --- /dev/null +++ b/src/main/java/com/tarento/formservice/models/Value.java @@ -0,0 +1,57 @@ +package com.tarento.formservice.models; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import lombok.ToString; + +@ToString(includeFieldNames = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "heading", "subHeading" }) +public class Value { + + @JsonProperty("heading") + private String heading; + @JsonProperty("subHeading") + private String subHeading; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("heading") + public String getHeading() { + return heading; + } + + @JsonProperty("heading") + public void setHeading(String heading) { + this.heading = heading; + } + + @JsonProperty("subHeading") + public String getSubHeading() { + return subHeading; + } + + @JsonProperty("subHeading") + public void setSubHeading(String subHeading) { + this.subHeading = subHeading; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/producer/FormServiceProducer.java b/src/main/java/com/tarento/formservice/producer/FormServiceProducer.java new file mode 100644 index 0000000000000000000000000000000000000000..3c11da49f648217cd8031838d820d6c596cd7652 --- /dev/null +++ b/src/main/java/com/tarento/formservice/producer/FormServiceProducer.java @@ -0,0 +1,24 @@ +package com.tarento.formservice.producer; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Service; + +@Service +public class FormServiceProducer { + + public static final Logger LOGGER = LoggerFactory.getLogger(FormServiceProducer.class); + + @Autowired + private KafkaTemplate<String, Object> kafkaTemplate; + + public void pushToPipeline(Object object, String topic, String key) { + LOGGER.info("Kafka Object : {}", object); + LOGGER.info("Kafka Topic : {}", topic); + LOGGER.info("Kafka Key : {}", key); + kafkaTemplate.send(topic, key, object); + } + +} diff --git a/src/main/java/com/tarento/formservice/producer/FormServiceProducerConfig.java b/src/main/java/com/tarento/formservice/producer/FormServiceProducerConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..920afcf57134e27169ad8edd8964028f784f6526 --- /dev/null +++ b/src/main/java/com/tarento/formservice/producer/FormServiceProducerConfig.java @@ -0,0 +1,50 @@ +package com.tarento.formservice.producer; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.kafka.clients.producer.ProducerConfig; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.kafka.annotation.EnableKafka; +import org.springframework.kafka.core.DefaultKafkaProducerFactory; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.core.ProducerFactory; +import org.springframework.kafka.support.serializer.JsonSerializer; + +import com.fasterxml.jackson.databind.ser.std.StringSerializer; + +@Configuration +@EnableKafka +public class FormServiceProducerConfig { + + @Value("${spring.kafka.bootstrap.servers}") + private String serverConfig; + + @Value("${kafka.producer.config.retries_config}") + private Integer retriesConfig; + + @Value("${kafka.producer.config.batch_size_config}") + private Integer batchSizeConfig; + + @Value("${kafka.producer.config.linger_ms_config}") + private Integer lingerMsConfig; + + @Value("${kafka.producer.config.buffer_memory_config}") + private Integer bufferMemoryConfig; + + @Bean + public ProducerFactory<String, Object> producerFactory() { + Map<String, Object> configProps = new HashMap<>(); + configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, serverConfig); + configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + return new DefaultKafkaProducerFactory<>(configProps); + } + + @Bean + public KafkaTemplate<String, Object> kafkaTemplate() { + return new KafkaTemplate<>(producerFactory()); + } +} diff --git a/src/main/java/com/tarento/formservice/producer/HashMapSerializer.java b/src/main/java/com/tarento/formservice/producer/HashMapSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..9580edaf08a0f667ec390eef4a18c5835d3b1991 --- /dev/null +++ b/src/main/java/com/tarento/formservice/producer/HashMapSerializer.java @@ -0,0 +1,33 @@ +package com.tarento.formservice.producer; + +import java.util.Map; + +import org.apache.kafka.common.serialization.Serializer; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@SuppressWarnings("rawtypes") +public class HashMapSerializer implements Serializer<Map> { + @Override + public void close() { + // + } + + @Override + public void configure(Map<String, ?> arg0, boolean arg1) { + // + } + + @Override + public byte[] serialize(String topic, Map data) { + byte[] value = null; + ObjectMapper objectMapper = new ObjectMapper(); + try { + value = objectMapper.writeValueAsString(data).getBytes(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return value; + } +} diff --git a/src/main/java/com/tarento/formservice/producer/JavaSerializer.java b/src/main/java/com/tarento/formservice/producer/JavaSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..0a924fb87014f3ae8aa4530465c32fc389962c80 --- /dev/null +++ b/src/main/java/com/tarento/formservice/producer/JavaSerializer.java @@ -0,0 +1,36 @@ +package com.tarento.formservice.producer; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.Map; + +import org.apache.kafka.common.serialization.Serializer; + +public class JavaSerializer implements Serializer<Object> { + + @Override + public byte[] serialize(String topic, Object data) { + try { + ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); + ObjectOutputStream objectStream = new ObjectOutputStream(byteStream); + objectStream.writeObject(data); + objectStream.flush(); + objectStream.close(); + return byteStream.toByteArray(); + } catch (IOException e) { + throw new IllegalStateException("Can't serialize object: " + data, e); + } + } + + @Override + public void configure(Map<String, ?> configs, boolean isKey) { + + } + + @Override + public void close() { + + } + +} diff --git a/src/main/java/com/tarento/formservice/repository/ElasticSearchRepository.java b/src/main/java/com/tarento/formservice/repository/ElasticSearchRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..e49d24156e4cf3b6e01c2b5f14506dc8139c65e8 --- /dev/null +++ b/src/main/java/com/tarento/formservice/repository/ElasticSearchRepository.java @@ -0,0 +1,186 @@ +package com.tarento.formservice.repository; + +import java.io.IOException; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpHost; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.action.bulk.BulkResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.update.UpdateResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback; +import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.common.xcontent.XContentType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; +import org.springframework.web.client.RestTemplate; + +import com.google.gson.Gson; +import com.tarento.formservice.models.DataObject; + +/** + * This Repository Class is used to perform the transactions of storing the data + * into the Elastic Search Repository + * + * @author Darshan Nagesh + * + */ +@Service +public class ElasticSearchRepository { + + public static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchRepository.class); + + private final RestTemplate restTemplate; + private RestHighLevelClient client; + private String elasticHost; + private int elasticPort; + private String elasticUsername; + private String elasticPassword; + + public ElasticSearchRepository(RestTemplate restTemplate, @Value("${services.esindexer.host}") String elasticHost, + @Value("${services.esindexer.host.port}") int elasticPort, + @Value("${services.esindexer.username}") String elasticUsername, + @Value("${services.esindexer.password}") String elasticPassword) { + this.restTemplate = restTemplate; + this.elasticHost = elasticHost; + this.elasticPort = elasticPort; + this.elasticUsername = elasticUsername; + this.elasticPassword = elasticPassword; + this.client = connectToElasticSearch(); + } + + private RestHighLevelClient connectToElasticSearch() { + final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + credentialsProvider.setCredentials(AuthScope.ANY, + new UsernamePasswordCredentials(elasticUsername, elasticPassword)); + + HttpClientConfigCallback httpClientConfigCallback = new HttpClientConfigCallback() { + @Override + public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { + return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); + } + }; + return new RestHighLevelClient(RestClient.builder(new HttpHost(elasticHost, elasticPort)) + .setHttpClientConfigCallback(httpClientConfigCallback)); + } + + /** + * Based on the Transaction Index Data Obtained and the URL with Headers, this + * method will put the Data obtained on the Elastic Search Database and returns + * the response in the form of Positive or Negative outcome (True Or False) + * + * @param transactionIndex + * @param url + * @param headers + * @return + */ + @SuppressWarnings("rawtypes") + public Boolean saveMyDataObject(Object object, String url, HttpHeaders headers) { + ResponseEntity<Map> map = null; + try { + map = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(object, headers), Map.class); + } catch (final HttpClientErrorException httpClientErrorException) { + LOGGER.error("Error :", httpClientErrorException); + } catch (HttpServerErrorException httpServerErrorException) { + LOGGER.error("Error :", httpServerErrorException); + } catch (Exception e) { + LOGGER.error("Error: ", e); + } + if (map != null && map.getStatusCode() != null && (map.getStatusCode() == HttpStatus.OK) + || (map.getStatusCode() == HttpStatus.CREATED)) { + return true; + } + return false; + } + + public Boolean writeDatatoElastic(Object object, String id, String indexName, String documentType) + throws IOException { + try { + IndexRequest indexRequest = new IndexRequest(indexName, documentType, id).source(new Gson().toJson(object), + XContentType.JSON); + IndexResponse response = client.index(indexRequest, RequestOptions.DEFAULT); + if (!StringUtils.isBlank(response.toString())) + LOGGER.info("Response : {}", response); + } catch (Exception e) { + LOGGER.error(e.getMessage()); + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + // Update ES Data + public Boolean updateElasticData(Object object, String id, String indexName, String documentType) + throws IOException { + try { + UpdateRequest updateRequest = new UpdateRequest(indexName, documentType, id).doc(new Gson().toJson(object), + XContentType.JSON); + UpdateResponse response = client.update(updateRequest, RequestOptions.DEFAULT); + if (!StringUtils.isBlank(response.toString())) + LOGGER.info("Updated Response : {}", response.getResult()); + } catch (Exception e) { + LOGGER.error(e.getMessage()); + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + public Boolean writeBulkDatatoElastic(BulkRequest request) throws IOException { + try { + BulkResponse response = client.bulk(request, RequestOptions.DEFAULT); + if (!StringUtils.isBlank(response.toString())) + LOGGER.info("Response : {}", response); + } catch (Exception e) { + LOGGER.error(e.getMessage()); + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + /** + * Based on the Transaction Index Data Obtained and the URL with Headers, this + * method will put the Data obtained on the Elastic Search Database and returns + * the response in the form of Positive or Negative outcome (True Or False) + * + * @param transactionIndex + * @param url + * @param headers + * @return + */ + public Boolean saveData(DataObject dataObject, String url, HttpHeaders headers) { + @SuppressWarnings("rawtypes") + ResponseEntity<Map> map = null; + try { + map = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(dataObject, headers), Map.class); + } catch (final HttpClientErrorException httpClientErrorException) { + LOGGER.error("Error:", httpClientErrorException); + } catch (HttpServerErrorException httpServerErrorException) { + LOGGER.error("Error : ", httpServerErrorException); + } catch (Exception e) { + LOGGER.error("Error : ", e); + } + if (map != null && map.getStatusCode() != null + && ((map.getStatusCode() == HttpStatus.OK) || (map.getStatusCode() == HttpStatus.CREATED))) { + return true; + } + return false; + } +} diff --git a/src/main/java/com/tarento/formservice/service/FormsService.java b/src/main/java/com/tarento/formservice/service/FormsService.java new file mode 100644 index 0000000000000000000000000000000000000000..5948ca7a415df0136f79bcfc722cb245927a937d --- /dev/null +++ b/src/main/java/com/tarento/formservice/service/FormsService.java @@ -0,0 +1,66 @@ +package com.tarento.formservice.service; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import com.tarento.formservice.model.AgentOverview; +import com.tarento.formservice.model.FormData; +import com.tarento.formservice.model.IncomingData; +import com.tarento.formservice.model.OverviewCount; +import com.tarento.formservice.model.ReplyFeedbackDto; +import com.tarento.formservice.model.ResponseData; +import com.tarento.formservice.model.UserInfo; +import com.tarento.formservice.model.VerifyFeedbackDto; +import com.tarento.formservice.model.VoteFeedbackDto; +import com.tarento.formservice.models.Form; +import com.tarento.formservice.models.FormDetail; + +/** + * Interface for all the Form Service APIs + * + * @author Darshan Nagesh + * + */ +public interface FormsService { + + public Form createForm(FormDetail newForm) throws IOException; + + public FormData addInteraction(FormData fData) throws IOException; + + public List<Form> getAllForms(); + + public FormDetail getFormById(Long id); + + public List<FormData> getAllInteractions(); + + public AgentOverview getAgentAggregations(Long agentId); + + public Boolean saveFormSubmit(IncomingData incomingData) throws IOException; + + public List<IncomingData> getFeedbacksByFormId(Long id, String approved, String challenged, Long agentId, + Long customerId, UserInfo userInfo, Boolean challengeStatus); + + public List<IncomingData> getFeedbacksByFormId(Long id); + + public Boolean verifyFeedback(UserInfo userInfo, VerifyFeedbackDto verifyFeedbackDto) throws IOException; + + public Boolean voteFeedback(UserInfo userInfo, VoteFeedbackDto voteFeedbackDto) throws IOException; + + public Boolean replyFeedback(UserInfo userInfo, ReplyFeedbackDto voteFeedbackDto) throws IOException; + + public Boolean challengeFeedback(String id, String reason) throws IOException; + + boolean updateInteraction(Map<String, Object> jsonMap, String id) throws IOException; + + public List<IncomingData> getFeedbacks(String approved, String challenged, Boolean challengeStatus); + + public OverviewCount getOverviewCount(UserInfo userInfo); + + public Boolean requestFeedback(FormData formData) throws IOException; + + ResponseData fetchUserInfo(Long userId); + + List<FormData> getAllInteractionsForAutomatedRequestFeedback() throws Exception; + +} diff --git a/src/main/java/com/tarento/formservice/service/JsonFormsService.java b/src/main/java/com/tarento/formservice/service/JsonFormsService.java new file mode 100644 index 0000000000000000000000000000000000000000..17f83780a79a2254d256ca2573acfeeeb09c49fc --- /dev/null +++ b/src/main/java/com/tarento/formservice/service/JsonFormsService.java @@ -0,0 +1,12 @@ +package com.tarento.formservice.service; + +import java.io.IOException; + +import com.tarento.formservice.model.FormDetail; +import com.tarento.formservice.models.Form; + +public interface JsonFormsService { + + public Boolean processJsonForms(Object obj, Form form, FormDetail formModel) throws IOException; + +} diff --git a/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java b/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..13fa42c11507e1425aedde233a18bb417aa10038 --- /dev/null +++ b/src/main/java/com/tarento/formservice/service/impl/FormsServiceImpl.java @@ -0,0 +1,1147 @@ +package com.tarento.formservice.service.impl; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.TimeZone; + +import org.apache.commons.lang3.StringUtils; +import org.apache.tomcat.util.codec.binary.Base64; +import org.apache.velocity.VelocityContext; +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.action.search.MultiSearchResponse; +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.MatchQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.query.RangeQueryBuilder; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.sort.SortBuilders; +import org.elasticsearch.search.sort.SortOrder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.tarento.formservice.dao.FormsDao; +import com.tarento.formservice.executor.MasterDataManager; +import com.tarento.formservice.model.AgentOverview; +import com.tarento.formservice.model.FormData; +import com.tarento.formservice.model.IncomingData; +import com.tarento.formservice.model.OverviewCount; +import com.tarento.formservice.model.ReplyFeedbackDto; +import com.tarento.formservice.model.ResponseData; +import com.tarento.formservice.model.Result; +import com.tarento.formservice.model.Role; +import com.tarento.formservice.model.UserInfo; +import com.tarento.formservice.model.VerifyFeedbackDto; +import com.tarento.formservice.model.Vote; +import com.tarento.formservice.model.VoteFeedbackDto; +import com.tarento.formservice.models.Form; +import com.tarento.formservice.models.FormDetail; +import com.tarento.formservice.repository.ElasticSearchRepository; +import com.tarento.formservice.service.FormsService; +import com.tarento.formservice.utils.Constants; +import com.tarento.formservice.utils.DateUtils; +import com.tarento.formservice.utils.JsonKey; +import com.tarento.formservice.utils.SendMail; + +@Service(Constants.ServiceRepositories.FORM_SERVICE) +public class FormsServiceImpl implements FormsService { + + public static final Logger LOGGER = LoggerFactory.getLogger(FormsServiceImpl.class); + private static final String AUTHORIZATION = "Authorization"; + private static final String US_ASCII = "US-ASCII"; + private static final String BASIC_AUTH = "Basic %s"; + private final String indexServiceHost; + private final String interactionIndexName; + private final String userName; + private final String password; + @SuppressWarnings("unused") + private final String easIndexName; + @SuppressWarnings("unused") + private final String easDocType; + Gson gson = new Gson(); + + public FormsServiceImpl(@Value("${services.esindexer.host}") String indexServiceHost, + @Value("${services.esindexer.username}") String userName, + @Value("${services.esindexer.password}") String password, + @Value("${es.fs.forms.index.name}") String easIndexName, + @Value("${es.fs.interactions.index.name}") String interactionIndexName, + @Value("${es.fs.forms.document.type}") String easDocumentType) { + this.indexServiceHost = indexServiceHost; + this.userName = userName; + this.password = password; + this.easIndexName = easIndexName; + this.interactionIndexName = interactionIndexName; + this.easDocType = easDocumentType; + } + + @Autowired + private ElasticSearchRepository elasticRepository; + + @Autowired + private FormsDao formsDao; + + @SuppressWarnings("unused") + private MultiSearchResponse executeElasticSearchQuery(String dataContext, String dataContextVersion, + String searchParameter, String indexName, String docType) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(1000); + BoolQueryBuilder boolBuilder = QueryBuilders.boolQuery(); + if (StringUtils.isNotBlank(dataContext)) { + boolBuilder.must().add(QueryBuilders.matchQuery(Constants.Parameters.CONTEXT, dataContext)); + } + if (StringUtils.isNotBlank(dataContextVersion)) { + boolBuilder.must().add(QueryBuilders.matchQuery(Constants.Parameters.CONTEXT_VERSION, dataContextVersion)); + } + if (StringUtils.isNotBlank(searchParameter)) { + BoolQueryBuilder subBoolBuilder = QueryBuilders.boolQuery(); + subBoolBuilder.should().add(QueryBuilders.wildcardQuery(Constants.PortfolioConstants.VALUE_KEYWORD, + "*" + searchParameter + "*")); + boolBuilder.must().add(subBoolBuilder); + } + + searchSourceBuilder.query(boolBuilder); + return formsDao + .executeMultiSearchRequest(new SearchRequest(indexName).types(docType).source(searchSourceBuilder)); + } + + /** + * A helper method to create the headers for Rest Connection with UserName and + * Password + * + * @return HttpHeaders + */ + private HttpHeaders getHttpHeaders() { + HttpHeaders headers = new HttpHeaders(); + headers.add(AUTHORIZATION, getBase64Value(userName, password)); + headers.setContentType(MediaType.APPLICATION_JSON); + return headers; + } + + /** + * Helper Method to create the Base64Value for headers + * + * @param userName + * @param password + * @return + */ + + private String getBase64Value(String userName, String password) { + String authString = String.format("%s:%s", userName, password); + byte[] encodedAuthString = Base64.encodeBase64(authString.getBytes(Charset.forName(US_ASCII))); + return String.format(BASIC_AUTH, new String(encodedAuthString)); + } + + @Override + public Form createForm(FormDetail newForm) throws IOException { + if (newForm.getId() != null) + performVersionCheck(newForm); + return (formsDao.addNewForm(newForm, getHttpHeaders())) ? newForm : null; + } + + private void performVersionCheck(Form newForm) { + MultiSearchResponse response = formsDao.executeMultiSearchRequest(createRequestForVersionCheck(newForm)); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + if (searchResponse != null) { + for (SearchHit hit : searchResponse.getHits()) { + Form existingForm = gson.fromJson(hit.getSourceAsString(), Form.class); + if (existingForm.getId().equals(newForm.getId()) && existingForm.getVersion() == newForm.getVersion()) { + int nextVersion = newForm.getVersion() + 1; + newForm.setVersion(nextVersion); + } + } + } + + } + + private SearchRequest createRequestForVersionCheck(Form newForm) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(1000); + BoolQueryBuilder boolBuilder = QueryBuilders.boolQuery(); + boolBuilder.must().add(QueryBuilders.matchQuery(Constants.Parameters.ID, newForm.getId())); + searchSourceBuilder.query(boolBuilder); + SearchRequest sRequest; + sRequest = new SearchRequest("fs-forms").types("forms").source(searchSourceBuilder); + return sRequest; + } + + @Override + public List<Form> getAllForms() { + List<Form> formList = new ArrayList<>(); + SearchRequest searchRequest = buildQueryForGetAllForms(); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + if (searchResponse != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getAggregations(), JsonNode.class); + JsonNode aggregationNode = responseNode.findValue("UniqueFormId"); + if (aggregationNode.has("buckets")) { + JsonNode buckets = aggregationNode.findValue("buckets"); + for (JsonNode bucket : buckets) { + @SuppressWarnings("unused") + JsonNode latestVersionNode = bucket.findValue("LatestVersion"); + JsonNode hitsNode = latestVersionNode.get("hits"); + if (hitsNode.has("hits")) { + JsonNode innerHits = hitsNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + Form 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); + } + } + } + } + LOGGER.info("Form List: {}", gson.toJson(formList)); + } + return formList; + } + + public static int randInt(int min, int max) { + Random rand = new Random(); + return rand.nextInt((max - min) + 1) + min; + } + + @Override + public FormDetail getFormById(Long id) { + FormDetail form = new FormDetail(); + SearchRequest searchRequest = buildQueryForGetQueryById(id); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + if (searchResponse != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getAggregations(), JsonNode.class); + JsonNode aggregationNode = responseNode.findValue("UniqueFormId"); + if (aggregationNode.has("buckets")) { + JsonNode buckets = aggregationNode.findValue("buckets"); + for (JsonNode bucket : buckets) { + JsonNode latestVersionNode = bucket.findValue("LatestVersion"); + JsonNode hitsNode = latestVersionNode.get("hits"); + if (hitsNode.has("hits")) { + JsonNode innerHits = hitsNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + form = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), FormDetail.class); + LOGGER.info("Each Form : {}", gson.toJson(form)); + } + } + + } + } + } + return form; + } + + private SearchRequest buildQueryForGetAllForms() { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0) + .aggregation(AggregationBuilders.terms("UniqueFormId").field("id").size(100) + .subAggregation(AggregationBuilders.topHits("LatestVersion").from(0).size(1) + .version(Boolean.FALSE).explain(Boolean.FALSE) + .sort(SortBuilders.fieldSort("version").order(SortOrder.DESC)))); + return new SearchRequest("fs-forms").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetCount() { + BoolQueryBuilder approvalPendingBoolBuilder = QueryBuilders.boolQuery(); + approvalPendingBoolBuilder.must().add(QueryBuilders.termQuery("approval.keyword", "")); + BoolQueryBuilder approvalAddressedboolBuilder = QueryBuilders.boolQuery(); + approvalAddressedboolBuilder.must().add( + QueryBuilders.termsQuery("approval.keyword", new ArrayList<>(Arrays.asList("APPROVED", "REJECTED")))); + BoolQueryBuilder challengePendingboolBuilder = QueryBuilders.boolQuery(); + BoolQueryBuilder newBoolQuery = QueryBuilders.boolQuery(); + newBoolQuery.filter(QueryBuilders.termsQuery("approval.keyword", new ArrayList<>(Arrays.asList("APPROVED")))); + newBoolQuery.filter(QueryBuilders.termQuery("challenge.keyword", "")); + newBoolQuery.should(QueryBuilders.matchQuery("challengeStatus", true)); + challengePendingboolBuilder.must().add(newBoolQuery); + BoolQueryBuilder challengeAddressedBoolBuilder = QueryBuilders.boolQuery(); + BoolQueryBuilder challengeBoolQuery = QueryBuilders.boolQuery(); + challengeBoolQuery.filter(QueryBuilders.termsQuery("challenge.keyword", + new ArrayList<>(Arrays.asList("OVERRULED", "SUSTAINED")))); + challengeBoolQuery.should(QueryBuilders.matchQuery("challengeStatus", true)); + challengeAddressedBoolBuilder.must().add(challengeBoolQuery); + + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0); + searchSourceBuilder.aggregation(AggregationBuilders.filter("Approval Pending", approvalPendingBoolBuilder) + .subAggregation(AggregationBuilders.count("Approval Pending Count").field("id"))); + searchSourceBuilder.aggregation(AggregationBuilders.filter("Approval Addressed", approvalAddressedboolBuilder) + .subAggregation(AggregationBuilders.count("Approval Addressed Count").field("id"))); + searchSourceBuilder.aggregation(AggregationBuilders.filter("Challenge Pending", challengePendingboolBuilder) + .subAggregation(AggregationBuilders.count("Challenge Pending Count").field("id"))); + searchSourceBuilder.aggregation(AggregationBuilders.filter("Challenge Addressed", challengeAddressedBoolBuilder) + .subAggregation(AggregationBuilders.count("Challenge Addressed Count").field("id"))); + searchSourceBuilder.query(QueryBuilders.matchAllQuery()); + return new SearchRequest("fs-forms-data").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForAgentOverview(Long agentId) { + + BoolQueryBuilder reviewsReceivedQuery = QueryBuilders.boolQuery(); + reviewsReceivedQuery.must().add(QueryBuilders.termQuery("agentId", agentId)); + + BoolQueryBuilder reviewsChallenged = QueryBuilders.boolQuery(); + BoolQueryBuilder newBoolQuery = QueryBuilders.boolQuery(); + newBoolQuery.filter(QueryBuilders.termQuery("agentId", 397)); + newBoolQuery.should(QueryBuilders.matchQuery("challengeStatus", true)); + reviewsChallenged.must().add(newBoolQuery); + + BoolQueryBuilder averageRating = QueryBuilders.boolQuery(); + averageRating.must().add(QueryBuilders.termQuery("agentId", agentId)); + averageRating.must().add(QueryBuilders.termQuery("approval.keyword", "APPROVED")); + + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0); + searchSourceBuilder.aggregation(AggregationBuilders.filter("Reviews Received", reviewsReceivedQuery) + .subAggregation(AggregationBuilders.count("Reviews Received Count").field("id"))); + + searchSourceBuilder.aggregation(AggregationBuilders.filter("Reviews Challenged", reviewsChallenged) + .subAggregation(AggregationBuilders.count("Reviews Challenged Count").field("id"))); + + searchSourceBuilder.aggregation(AggregationBuilders.filter("Average Rating", averageRating) + .subAggregation(AggregationBuilders.avg("Average Rating Value") + .field("dataObject.How would you rate your overall experience with our agent? (Mandatory)"))); + + return new SearchRequest("fs-forms-data").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForAgentOverviewForInteractions(Long agentId) { + + BoolQueryBuilder agentBool = QueryBuilders.boolQuery(); + agentBool.must().add(QueryBuilders.termQuery("agent", agentId)); + + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0); + searchSourceBuilder.aggregation(AggregationBuilders.filter("Interactions", agentBool) + .subAggregation(AggregationBuilders.count("Interactions Count").field("id"))); + + return new SearchRequest("fs-interactions").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetAllCharts() { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(100); + return new SearchRequest("vt-chart").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetAllDashboards() { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(100); + return new SearchRequest("vt-dashboard").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetQueryById(Long id) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0) + .query(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("id", id))) + .aggregation(AggregationBuilders.terms("UniqueFormId").field("id").size(100) + .subAggregation(AggregationBuilders.topHits("LatestVersion").from(0).size(1) + .version(Boolean.FALSE).explain(Boolean.FALSE) + .sort(SortBuilders.fieldSort("version").order(SortOrder.DESC)))); + return new SearchRequest("fs-forms").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetFeedbacks(Long id, String approved, String challenged, Long agentId, + Long customerId, UserInfo userInfo, Boolean challengeStatus) { + if (StringUtils.isNotBlank(challenged)) { + challengeStatus = Boolean.TRUE; + } + for (Role role : userInfo.getRoles()) { + if (role.getName().equals("Customer")) { + customerId = userInfo.getId(); + return buildQueryForCustomerFeedbacks(id, approved, challenged, challengeStatus); + } else if (role.getName().equals("Agent")) { + agentId = userInfo.getId(); + } + } + return buildQueryForGetFeedbacksGeneral(id, approved, challenged, agentId, customerId, challengeStatus); + } + + private SearchRequest buildQueryForCustomerFeedbacks(Long id, String approved, String challenged, + Boolean challengeStatus) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(1000); + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + if (id == null && approved == null && challenged == null) { + boolQuery.must(QueryBuilders.matchAllQuery()); + } + if (id != null && id > 0) { + boolQuery.must(QueryBuilders.matchQuery("id", id)); + } + if (approved != null) { + if (approved.equalsIgnoreCase("APPROVED")) + boolQuery.filter(QueryBuilders.termQuery("approval.keyword", "APPROVED")); + else if (approved.equalsIgnoreCase("REJECTED")) + boolQuery.filter(QueryBuilders.termQuery("approval.keyword", "REJECTED")); + else if (approved.equalsIgnoreCase("PENDING")) + boolQuery.filter(QueryBuilders.termQuery("approval.keyword", "")); + } + if (challengeStatus != null && challengeStatus) { + boolQuery.filter(QueryBuilders.termQuery("approval.keyword", "APPROVED")); + if (challenged != null) { + if (challenged.equalsIgnoreCase("OVERRULED")) + boolQuery.filter(QueryBuilders.termQuery("challenge.keyword", "OVERRULED")); + else if (challenged.equalsIgnoreCase("SUSTAINED")) + boolQuery.filter(QueryBuilders.termQuery("challenge.keyword", "SUSTAINED")); + else if (challenged.equalsIgnoreCase("PENDING")) + boolQuery.filter(QueryBuilders.matchQuery("challengeStatus", Boolean.TRUE)); + } + } + if (approved == null && challengeStatus == null) { + boolQuery.must(QueryBuilders.termQuery("approval.keyword", "APPROVED")); + BoolQueryBuilder bool2Query = new BoolQueryBuilder(); + bool2Query.must(QueryBuilders.matchQuery("challengeStatus", Boolean.TRUE)); + bool2Query.filter(QueryBuilders.termQuery("challenge.keyword", "OVERRULED")); + BoolQueryBuilder bool3Query = new BoolQueryBuilder(); + bool3Query.should(QueryBuilders.termQuery("challengeStatus", Boolean.FALSE)); + bool3Query.should(bool2Query); + boolQuery.must(bool3Query); + } + searchSourceBuilder.query(boolQuery).sort(SortBuilders.fieldSort("timestamp").order(SortOrder.DESC)).size(1000); + return new SearchRequest("fs-forms-data").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetFeedbacksGeneral(Long id, String approved, String challenged, Long agentId, + Long customerId, Boolean challengeStatus) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(1000); + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + if (id == null && approved == null && challenged == null && agentId == null && customerId == null) { + boolQuery.must(QueryBuilders.matchAllQuery()); + } + if (id != null && id > 0) { + boolQuery.must(QueryBuilders.matchQuery("id", id)); + } + if (customerId != null && customerId > 0) { + MatchQueryBuilder approvalMatch = QueryBuilders.matchQuery("approval.keyword", "APPROVED"); + boolQuery.must(approvalMatch); + MatchQueryBuilder blankChallengeStatusMatch = QueryBuilders.matchQuery("challenge.keyword", ""); + MatchQueryBuilder overruledChallengeStatusMatch = QueryBuilders.matchQuery("challenge.keyword", + "SUSTAINED"); + boolQuery.should(blankChallengeStatusMatch); + boolQuery.should(overruledChallengeStatusMatch); + } + if (agentId != null && agentId > 0) { + boolQuery.must(QueryBuilders.matchQuery("agentId", agentId)); + } + if (approved != null) { + if (approved.equalsIgnoreCase("APPROVED")) + boolQuery.must(QueryBuilders.matchQuery("approval.keyword", "APPROVED")); + else if (approved.equalsIgnoreCase("REJECTED")) + boolQuery.must(QueryBuilders.matchQuery("approval.keyword", "REJECTED")); + else if (approved.equalsIgnoreCase("PENDING")) + boolQuery.must(QueryBuilders.matchQuery("approval.keyword", "")); + } + if (challengeStatus != null && challengeStatus) { + boolQuery.must(QueryBuilders.matchQuery("approval.keyword", "APPROVED")); + if (challenged != null) { + if (challenged.equalsIgnoreCase("OVERRULED")) + boolQuery.must(QueryBuilders.matchQuery("challenge.keyword", "OVERRULED")); + else if (challenged.equalsIgnoreCase("SUSTAINED")) + boolQuery.filter(QueryBuilders.termQuery("challenge.keyword", "SUSTAINED")); + else if (challenged.equalsIgnoreCase("PENDING")) + boolQuery.filter(QueryBuilders.matchQuery("challengeStatus", Boolean.TRUE)); + } + + } + searchSourceBuilder.query(boolQuery).sort(SortBuilders.fieldSort("timestamp").order(SortOrder.DESC)).size(1000); + return new SearchRequest("fs-forms-data").types("forms").source(searchSourceBuilder); + + } + + private SearchRequest buildQueryForGetFeedbackById(Long id) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(1000); + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + if (id != null && id > 0) { + boolQuery.must(QueryBuilders.matchQuery("id", id)); + } + searchSourceBuilder.query(boolQuery).sort(SortBuilders.fieldSort("timestamp").order(SortOrder.DESC)).size(1000); + return new SearchRequest("fs-forms-data").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetAllFeedbacks(String approved, String challenged, Boolean challengeStatus) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0); + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().must(QueryBuilders.matchAllQuery()); + if (approved != null) { + if (approved.equalsIgnoreCase("APPROVED")) + boolQuery.filter(QueryBuilders.termQuery("approval.keyword", "APPROVED")); + else if (approved.equalsIgnoreCase("REJECTED")) + boolQuery.filter(QueryBuilders.termQuery("approval.keyword", "REJECTED")); + else if (approved.equalsIgnoreCase("PENDING")) + boolQuery.filter(QueryBuilders.termQuery("approval.keyword", "")); + } + if (challengeStatus != null && challengeStatus) { + boolQuery.filter(QueryBuilders.termQuery("approval.keyword", "APPROVED")); + boolQuery.filter(QueryBuilders.termQuery("challengeStatus", true)); + if (challenged != null) { + if (challenged.equalsIgnoreCase("OVERRULED")) + boolQuery.filter(QueryBuilders.termQuery("challenge.keyword", "OVERRULED")); + else if (challenged.equalsIgnoreCase("SUSTAINED")) + boolQuery.filter(QueryBuilders.termQuery("challenge.keyword", "SUSTAINED")); + } else { + boolQuery.filter(QueryBuilders.termQuery("challenge.keyword", "")); + } + } else if (challengeStatus != null && !challengeStatus) { + boolQuery.filter(QueryBuilders.termQuery("challengeStatus", false)); + } + searchSourceBuilder.query(boolQuery).sort(SortBuilders.fieldSort("timestamp").order(SortOrder.DESC)).size(1000); + return new SearchRequest("fs-forms-data").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetChartById(Long id) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(100) + .query(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("id", id))); + return new SearchRequest("vt-chart").types("forms").source(searchSourceBuilder); + } + + private SearchRequest buildQueryForGetDashboarById(Long id) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(100) + .query(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("id", id))); + return new SearchRequest("vt-dashboard").types("forms").source(searchSourceBuilder); + } + + public static JsonObject convertToJsonObject(Object payload) { + GsonBuilder builder = new GsonBuilder(); + return (JsonObject) builder.setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create().toJsonTree(payload); + } + + @Override + public Boolean saveFormSubmit(IncomingData incomingData) throws IOException { + return formsDao.saveFormSubmit(incomingData, getHttpHeaders()); + } + + @Override + public List<IncomingData> getFeedbacksByFormId(Long id, String approved, String challenged, Long agentId, + Long customerId, UserInfo userInfo, Boolean challengeStatus) { + + List<IncomingData> incomingData = new ArrayList<>(); + SearchRequest searchRequest = buildQueryForGetFeedbacks(id, approved, challenged, agentId, customerId, userInfo, + challengeStatus); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + if (searchResponse != null && searchResponse.getHits() != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getHits(), JsonNode.class); + if (responseNode.has("hits")) { + JsonNode innerHits = responseNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + String documentId = eachInnerHit.findValue("id").asText(); + IncomingData form = new IncomingData(); + form = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), IncomingData.class); + form.setRecordId(documentId); + if (MasterDataManager.getUserData().get(form.getCustomerId()) != null) { + form.setCustomerName(MasterDataManager.getUserData().get(form.getCustomerId()).getUsername()); + } else { + ResponseData data = fetchUserInfo(form.getCustomerId()); + if (data != null) { + MasterDataManager.getUserData().put(form.getCustomerId(), data); + form.setCustomerName(data.getUsername().toString()); + } + } + if (MasterDataManager.getUserData().get(form.getAgentId()) != null) { + form.setAgentName( + MasterDataManager.getUserData().get(form.getAgentId()).getUsername().toString()); + } else { + ResponseData data = fetchUserInfo(form.getAgentId()); + if (data != null) { + MasterDataManager.getUserData().put(form.getAgentId(), data); + form.setAgentName(data.getUsername().toString()); + } + } + incomingData.add(form); + LOGGER.info("Each Form : {}", gson.toJson(form)); + } + } + } + return incomingData; + } + + @Override + public List<IncomingData> getFeedbacksByFormId(Long id) { + List<IncomingData> incomingData = new ArrayList<>(); + SearchRequest searchRequest = buildQueryForGetFeedbackById(id); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + if (searchResponse != null && searchResponse.getHits() != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getHits(), JsonNode.class); + if (responseNode.has("hits")) { + JsonNode innerHits = responseNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + String documentId = eachInnerHit.findValue("id").asText(); + IncomingData form = new IncomingData(); + form = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), IncomingData.class); + form.setRecordId(documentId); + if (form.getCustomerId() != null) { + if (MasterDataManager.getUserData() != null + && MasterDataManager.getUserData().containsKey(form.getCustomerId())) { + form.setCustomerName( + MasterDataManager.getUserData().get(form.getCustomerId()).getUsername()); + } else { + ResponseData data = fetchUserInfo(form.getCustomerId()); + if (data != null) { + MasterDataManager.getUserData().put(form.getCustomerId(), data); + form.setCustomerName(data.getUsername()); + } + } + } + if (form.getAgentId() != null) { + if (MasterDataManager.getUserData().get(form.getAgentId()) != null) { + form.setAgentName(MasterDataManager.getUserData().get(form.getAgentId()).getUsername()); + } else { + ResponseData data = fetchUserInfo(form.getAgentId()); + if (data != null) { + MasterDataManager.getUserData().put(form.getAgentId(), data); + form.setAgentName(data.getUsername()); + } + } + } + incomingData.add(form); + LOGGER.info("Each Form : {}", gson.toJson(form)); + } + } + } + return incomingData; + } + + @Override + public Boolean verifyFeedback(UserInfo userInfo, VerifyFeedbackDto verifyFeedbackDto) throws IOException { + Map<String, Object> jsonMap = new HashMap<>(); + if (verifyFeedbackDto.getCondition().equalsIgnoreCase("APPROVAL") + && !StringUtils.isBlank(verifyFeedbackDto.getStatus()) + && (verifyFeedbackDto.getStatus().equalsIgnoreCase("APPROVED") + || verifyFeedbackDto.getStatus().equalsIgnoreCase("REJECTED"))) { + jsonMap.put("approval", verifyFeedbackDto.getStatus()); + jsonMap.put("approvedTime", new Date().getTime()); + jsonMap.put("approvedBy", userInfo.getId()); + if (verifyFeedbackDto.getStatus().equalsIgnoreCase("REJECTED")) { + jsonMap.put("reasonForApprovalRejection", verifyFeedbackDto.getReasonForApprovalRejection()); + } + } else if (verifyFeedbackDto.getCondition().equalsIgnoreCase("CHALLENGE") + && !StringUtils.isBlank(verifyFeedbackDto.getStatus()) + && (verifyFeedbackDto.getStatus().equalsIgnoreCase("OVERRULED") + || verifyFeedbackDto.getStatus().equalsIgnoreCase("SUSTAINED"))) { + jsonMap.put("challenge", verifyFeedbackDto.getStatus()); + jsonMap.put("challengeStatus", true); + jsonMap.put("challengeVerifiedTime", new Date().getTime()); + jsonMap.put("challengeVerifiedBy", userInfo.getId()); + if (verifyFeedbackDto.getCondition().equalsIgnoreCase("CHALLENGE")) { + jsonMap.put("reasonForChallenge", verifyFeedbackDto.getReasonForChallenge()); + } + } + return formsDao.verifyFeedback(jsonMap, verifyFeedbackDto.getId()); + } + + @Override + public FormData addInteraction(FormData fData) throws IOException { + String encodedString = encodeFormsData(fData); + fData.setUrlCode(encodedString); + boolean status = formsDao.addInteraction(fData, getHttpHeaders()); + return (status) ? fData : null; + } + + @Override + public boolean updateInteraction(Map<String, Object> jsonMap, String id) throws IOException { + return formsDao.updateInteraction(jsonMap, id, getHttpHeaders()); + } + + private String encodeFormsData(FormData fData) { + return new String(Base64.encodeBase64(new Gson().toJson(fData).getBytes(Charset.forName(US_ASCII)))); + } + + @Override + public List<FormData> getAllInteractions() { + List<FormData> interactions = new ArrayList<>(); + SearchRequest searchRequest = buildQueryForInteractions(null, null); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + if (searchResponse != null && searchResponse.getHits() != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getHits(), JsonNode.class); + if (responseNode.has("hits")) { + JsonNode innerHits = responseNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + FormData fData = new FormData(); + fData = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), FormData.class); + if (MasterDataManager.getUserData().get(fData.getCustomer()) != null) { + fData.setCustomerName( + MasterDataManager.getUserData().get(fData.getCustomer()).getUsername().toString()); + } else { + ResponseData data = fetchUserInfo(fData.getCustomer()); + if (data != null) { + MasterDataManager.getUserData().put(fData.getCustomer(), data); + fData.setCustomerName(data.getUsername().toString()); + } + } + if (MasterDataManager.getUserData().get(fData.getAgent()) != null) { + fData.setAgentName( + MasterDataManager.getUserData().get(fData.getAgent()).getUsername().toString()); + } else { + ResponseData data = fetchUserInfo(fData.getAgent()); + if (data != null) { + MasterDataManager.getUserData().put(fData.getAgent(), data); + fData.setAgentName(data.getUsername().toString()); + } + } + interactions.add(fData); + } + } + } + return interactions; + } + + @Override + public List<FormData> getAllInteractionsForAutomatedRequestFeedback() throws Exception { + List<FormData> interactions = new ArrayList<>(); + List<String> ids = new ArrayList<>(); + LocalDateTime today = LocalDateTime.now(); + LocalDateTime aweekago = today.minusDays(8); + long newTimestamp = DateUtils.now(today).getTime(); + long startDate = DateUtils.startOfDay(aweekago).getTime(); + long endDate = DateUtils.endOfDay(aweekago).getTime(); + SearchRequest searchRequest = buildQueryForInteractions(startDate, endDate); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + BulkRequest request = new BulkRequest(); + Map<String, Object> jsonMap = new HashMap<>(); + jsonMap.put("linkSentDate", newTimestamp); + JsonNode responseNode = null; + if (searchResponse != null && searchResponse.getHits() != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getHits(), JsonNode.class); + if (responseNode.has("hits")) { + JsonNode innerHits = responseNode.findValue("hits"); + if (!innerHits.isEmpty()) { + for (JsonNode eachInnerHit : innerHits) { + String id = eachInnerHit.findValue("id").toPrettyString(); + if (id != null) { + ids.add(id); + request.add(formsDao.addBulkUpdateRequest(id, jsonMap)); + } + } + Boolean updateBulkRequest = formsDao.updateBulkRequest(request); + } + } + } + return interactions; + } + + @Override + public ResponseData fetchUserInfo(Long userId) { + try { + RestTemplate restTemplate = new RestTemplate(); + final String uri = "http://localhost:8081/user/getUserById?id=" + userId + "&orgId=5001"; + HttpHeaders headers = new HttpHeaders(); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(uri).queryParam("id", userId); + HttpEntity<?> entity = new HttpEntity<>(headers); + ResponseEntity<String> result = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, + String.class); + if (result.getStatusCode() == HttpStatus.OK && !StringUtils.isEmpty(result.getBody())) { + Gson gson = new Gson(); + Result rs = gson.fromJson(result.getBody(), Result.class); + if (rs.getResponseData() != null) { + return rs.getResponseData(); + } + } + } catch (Exception e) { + LOGGER.error(String.format("Encountered an error while fetching user info object in userservice : %s", + e.getMessage())); + } + return null; + } + + private SearchRequest buildQueryForInteractions(Long startDate, Long endDate) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(1000); + if (startDate != null & endDate != null) { + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must(QueryBuilders.matchQuery("linkSentDate", 0)); + boolQuery.must(QueryBuilders.rangeQuery("interactionDate").gte(startDate).lte(endDate)); + searchSourceBuilder.query(boolQuery); + } + return new SearchRequest(interactionIndexName).types("forms").source(searchSourceBuilder); + } + + @Override + public List<IncomingData> getFeedbacks(String approved, String challenged, Boolean challengeStatus) { + List<IncomingData> incomingData = new ArrayList<>(); + + SearchRequest searchRequest = buildQueryForGetAllFeedbacks(approved, challenged, challengeStatus); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + if (searchResponse != null && searchResponse.getHits() != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getHits(), JsonNode.class); + if (responseNode.has("hits")) { + JsonNode innerHits = responseNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + IncomingData form = new IncomingData(); + form = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), IncomingData.class); + if (MasterDataManager.getUserData().get(form.getCustomerId()) != null) { + form.setCustomerName( + MasterDataManager.getUserData().get(form.getCustomerId()).getUsername().toString()); + } else { + ResponseData data = fetchUserInfo(form.getCustomerId()); + if (data != null) { + MasterDataManager.getUserData().put(form.getCustomerId(), data); + form.setCustomerName(data.getUsername().toString()); + } + } + if (MasterDataManager.getUserData().get(form.getAgentId()) != null) { + form.setAgentName( + MasterDataManager.getUserData().get(form.getAgentId()).getUsername().toString()); + } else { + ResponseData data = fetchUserInfo(form.getAgentId()); + if (data != null) { + MasterDataManager.getUserData().put(form.getAgentId(), data); + form.setAgentName(data.getUsername().toString()); + } + } + incomingData.add(form); + LOGGER.info("Each Form : {}", gson.toJson(form)); + } + } + } + return incomingData; + } + + public Boolean challengeFeedback(String id, String reason) throws IOException { + Map<String, Object> jsonMap = new HashMap<>(); + jsonMap.put("challengeStatus", true); + jsonMap.put("reasonForChallenge", reason); + return formsDao.challengeFeedback(jsonMap, id); + } + + @Override + public Boolean voteFeedback(UserInfo userInfo, VoteFeedbackDto voteFeedbackDto) throws IOException { + Map<String, Object> jsonMap = new HashMap<>(); + SearchRequest searchRequest = buildQueryForGetFeedbackById(voteFeedbackDto.getRecordId()); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + IncomingData form = new IncomingData(); + if (searchResponse != null && searchResponse.getHits() != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getHits(), JsonNode.class); + if (responseNode.has("hits")) { + JsonNode innerHits = responseNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + form = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), IncomingData.class); + LOGGER.info("Each Form : {}", gson.toJson(form)); + } + } + } + if (voteFeedbackDto.getAction().equals("DO")) { + if (voteFeedbackDto.getVote().equals("UP")) { + Vote vote = new Vote(); + vote.setVoteDate(new Date().getTime()); + vote.setCustomerId(voteFeedbackDto.getCustomerId()); + vote.setVote(voteFeedbackDto.getVote()); + List<Vote> updatedVotes = new ArrayList<>(); + Long upvotesCount = 0l; + if (form.getUpvotes() != null && form.getUpvotes().size() > 0) { + updatedVotes = form.getUpvotes(); + upvotesCount = form.getUpvoteCount(); + } + updatedVotes.add(vote); + upvotesCount = upvotesCount + 1l; + jsonMap.put("upvotes", updatedVotes); + jsonMap.put("upvoteCount", upvotesCount); + } else if (voteFeedbackDto.getVote().equals("DOWN")) { + Vote vote = new Vote(); + vote.setVoteDate(new Date().getTime()); + vote.setCustomerId(voteFeedbackDto.getCustomerId()); + vote.setVote(voteFeedbackDto.getVote()); + List<Vote> updatedVotes = new ArrayList<>(); + Long downvotesCount = 0l; + if (form.getDownvotes() != null && form.getDownvotes().size() > 0) { + updatedVotes = form.getDownvotes(); + downvotesCount = form.getDownvoteCount(); + } + updatedVotes.add(vote); + downvotesCount = downvotesCount + 1l; + jsonMap.put("downvotes", updatedVotes); + jsonMap.put("downvoteCount", downvotesCount); + } + } else if (voteFeedbackDto.getAction().equals("UNDO")) { + Map<Long, Vote> votesMap = new HashMap<Long, Vote>(); + Long upvotesCount = 0l; + Long downvotesCount = 0l; + if (voteFeedbackDto.getVote().equals("UP")) { + if (form.getUpvotes() != null && form.getUpvotes().size() > 0) { + upvotesCount = form.getUpvoteCount(); + for (Vote vote : form.getUpvotes()) { + if (!vote.getCustomerId().equals(voteFeedbackDto.getCustomerId())) { + votesMap.put(vote.getCustomerId(), vote); + } else { + upvotesCount = upvotesCount - 1l; + } + } + } + List<Vote> finalUpvotesList = new ArrayList(votesMap.values()); + jsonMap.put("upvotes", finalUpvotesList); + jsonMap.put("upvoteCount", upvotesCount); + } else if (voteFeedbackDto.getVote().equals("DOWN")) { + if (form.getDownvotes() != null && form.getDownvotes().size() > 0) { + downvotesCount = form.getDownvoteCount(); + for (Vote vote : form.getDownvotes()) { + if (!vote.getCustomerId().equals(voteFeedbackDto.getCustomerId())) { + votesMap.put(vote.getCustomerId(), vote); + } else { + downvotesCount = downvotesCount - 1l; + } + } + } + + List<Vote> finalDownvotesList = new ArrayList(votesMap.values()); + jsonMap.put("downvotes", finalDownvotesList); + jsonMap.put("downvoteCount", downvotesCount); + } + } + return formsDao.voteFeedback(jsonMap, voteFeedbackDto.getRecordId()); + } + + private SearchRequest buildQueryForGetFeedbackById(String recordId) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(10) + .query(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("_id", recordId))); + return new SearchRequest("fs-forms-data").types("forms").source(searchSourceBuilder); + } + + @Override + public OverviewCount getOverviewCount(UserInfo userInfo) { + OverviewCount overviewCount = new OverviewCount(); + SearchRequest searchRequest = null; + SearchRequest secondSearchRequest = null; + MultiSearchResponse secondResponse = null; + String userRole = ""; + for (Role role : userInfo.getRoles()) { + userRole = role.getName(); + } + if (userRole.equals("Agent")) { + searchRequest = buildQueryForAgentOverview(userInfo.getId()); + secondSearchRequest = buildQueryForAgentOverviewForInteractions(userInfo.getId()); + } else { + searchRequest = buildQueryForGetCount(); + } + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + if (secondSearchRequest != null && userRole.equals("Agent")) { + secondResponse = formsDao.executeMultiSearchRequest(secondSearchRequest); + } + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + SearchResponse secondSearchResponse = secondResponse != null ? secondResponse.getResponses()[0].getResponse() + : null; + JsonNode responseNode = null; + if (searchResponse != null && userRole.equals("Agent")) { + responseNode = new ObjectMapper().convertValue(searchResponse.getAggregations(), JsonNode.class); + int reviewsReceived = responseNode.findValue("Reviews Received").findValue("value").asInt(); + overviewCount.setReviewsReceived(reviewsReceived); + int reviewsChallenged = responseNode.findValue("Reviews Challenged").findValue("value").asInt(); + overviewCount.setReviewsChallenged(reviewsChallenged); + double averageRating = responseNode.findValue("Average Rating").findValue("value").asDouble(); + overviewCount.setAverageRating(averageRating); + if (secondSearchResponse != null) { + responseNode = new ObjectMapper().convertValue(secondSearchResponse.getAggregations(), JsonNode.class); + int interactions = responseNode.findValue("Interactions").findValue("value").asInt(); + overviewCount.setCustomersInteracted(interactions); + } + } else { + responseNode = new ObjectMapper().convertValue(searchResponse.getAggregations(), JsonNode.class); + JsonNode aggregationNode = responseNode.findValue("Approval Pending").get("aggregations"); + JsonNode buckets = aggregationNode.findValue("Approval Pending Count"); + overviewCount + .setPendingApproval(gson.fromJson(buckets.findValue("value").toString(), Long.class).intValue()); + JsonNode aaaggregationNode = responseNode.findValue("Approval Addressed").get("aggregations"); + JsonNode aabuckets = aaaggregationNode.findValue("Approval Addressed Count"); + overviewCount.setApprovalSum(gson.fromJson(aabuckets.findValue("value").toString(), Long.class).intValue()); + JsonNode caaggregationNode = responseNode.findValue("Challenge Addressed").get("aggregations"); + JsonNode cabuckets = caaggregationNode.findValue("Challenge Addressed Count"); + overviewCount + .setChallengeSum(gson.fromJson(cabuckets.findValue("value").toString(), Long.class).intValue()); + JsonNode cpaggregationNode = responseNode.findValue("Challenge Pending").get("aggregations"); + JsonNode cpbuckets = cpaggregationNode.findValue("Challenge Pending Count"); + overviewCount + .setPendingChallenge(gson.fromJson(cpbuckets.findValue("value").toString(), Long.class).intValue()); + } + return overviewCount; + } + + public AgentOverview getAgentAggregations(Long agentId) { + AgentOverview agentOverview = new AgentOverview(); + SearchRequest searchRequest = buildQueryForAgentAggregations(agentId); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + if (searchResponse != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getAggregations(), JsonNode.class); + Double averageRating = responseNode.findValue("Average Rating").findValue("value").asDouble(); + agentOverview.setAverageRating(averageRating); + + Long totalRating = responseNode.findValue("Total Ratings").findValue("value").asLong(); + agentOverview.setTotalRating(totalRating); + Long totalRatingSum = totalRating * 5; + + Map<Integer, Double> ratingSplit = new HashMap<Integer, Double>() { + { + put(1, 0.0); + put(2, 0.0); + put(3, 0.0); + put(4, 0.0); + put(5, 0.0); + } + }; + Map<String, Double> featureListing = new HashMap<String, Double>(); + JsonNode buckets = (ArrayNode) responseNode.findValue("Rating Split").findValue("buckets"); + buckets.forEach(bucket -> { + int docCount = bucket.findValue("docCount").asInt(); + double percentage = ((double) docCount / totalRating) * 100; + ratingSplit.put(bucket.findValue("key").asInt(), percentage); + }); + agentOverview.setRatingSplit(ratingSplit); + + Long quality = responseNode.findValue("Quality Of Listing").findValue("value").asLong(); + double qualityDouble = ((double) quality / totalRatingSum) * 100; + featureListing.put("Quality Of Listing", qualityDouble); + + Long responsiveness = responseNode.findValue("Responsiveness").findValue("value").asLong(); + double responsivenessDouble = ((double) responsiveness / totalRatingSum) * 100; + featureListing.put("Responsiveness", responsivenessDouble); + + Long serviceOrientation = responseNode.findValue("Service Orientation").findValue("value").asLong(); + double serviceOrientationDouble = ((double) serviceOrientation / totalRatingSum) * 100; + featureListing.put("Service Orientation", serviceOrientationDouble); + + Long kk = responseNode.findValue("Knowledge and Expertise").findValue("value").asLong(); + double kkDouble = ((double) kk / totalRatingSum) * 100; + featureListing.put("Knowledge and Expertise", kkDouble); + + agentOverview.setFeatureListing(featureListing); + } + return agentOverview; + } + + private SearchRequest buildQueryForAgentAggregations(Long agentId) { + BoolQueryBuilder agentIdMatchQuery = QueryBuilders.boolQuery(); + agentIdMatchQuery.must().add(QueryBuilders.termQuery("agentId", agentId)); + + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0); + searchSourceBuilder.aggregation(AggregationBuilders.filter("User Based Filter", agentIdMatchQuery) + .subAggregation(AggregationBuilders.avg("Average Rating") + .field("dataObject.How would you rate your overall experience with our agent? (Mandatory)")) + .subAggregation(AggregationBuilders.count("Total Ratings").field("id")) + .subAggregation(AggregationBuilders.terms("Rating Split") + .field("dataObject.How would you rate your overall experience with our agent? (Mandatory)")) + .subAggregation(AggregationBuilders.sum("Quality Of Listing") + .field("dataObject.How was the quality of listing of the property you were interested in?")) + .subAggregation(AggregationBuilders.sum("Responsiveness") + .field("dataObject.How was the responsiveness of the agent when you tried to reach?")) + .subAggregation(AggregationBuilders.sum("Service Orientation") + .field("dataObject.How satisfied are you with the service orientation of the agent?")) + .subAggregation(AggregationBuilders.sum("Knowledge and Expertise") + .field("dataObject.How knowledgeable and expert was the agent?"))); + return new SearchRequest("fs-forms-data").types("forms").source(searchSourceBuilder); + } + + @Override + public Boolean replyFeedback(UserInfo userInfo, ReplyFeedbackDto replyFeedbackDto) throws IOException { + Map<String, Object> jsonMap = new HashMap<>(); + replyFeedbackDto.setUserId(userInfo.getId()); + if (MasterDataManager.getUserData().get(userInfo.getId()) != null) { + replyFeedbackDto + .setUsername(MasterDataManager.getUserData().get(userInfo.getId()).getUsername().toString()); + } else { + ResponseData data = fetchUserInfo(userInfo.getId()); + if (data != null) { + MasterDataManager.getUserData().put(userInfo.getId(), data); + replyFeedbackDto.setUsername(data.getUsername().toString()); + } + } + replyFeedbackDto.setReplyDate(new Date().getTime()); + SearchRequest searchRequest = buildQueryForGetFeedbackById(replyFeedbackDto.getRecordId()); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + IncomingData form = new IncomingData(); + if (searchResponse != null && searchResponse.getHits() != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getHits(), JsonNode.class); + if (responseNode.has("hits")) { + JsonNode innerHits = responseNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + form = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), IncomingData.class); + LOGGER.info("Each Form : {}", gson.toJson(form)); + } + } + } + List<ReplyFeedbackDto> replies = new ArrayList<>(); + if (replyFeedbackDto.getReply() != null && replyFeedbackDto.getReply() != "") + replies.add(replyFeedbackDto); + jsonMap.put("replies", replies); + return formsDao.replyFeedback(jsonMap, replyFeedbackDto.getRecordId()); + } + + @Override + public Boolean requestFeedback(FormData formData) throws IOException { + ResponseData data = fetchUserInfo(formData.getCustomer()); + String name = data.getFirstName(); + VelocityContext context = new VelocityContext(); + try { + context.put(JsonKey.MAIL_SUBJECT, "Requesting your feedback!"); + context.put(JsonKey.MAIL_BODY, "Based on your interaction with our agent, we seek your feedback"); + context.put(JsonKey.FIRST_NAME, name); + context.put(JsonKey.PSWRD, "https://rain.tarento.com/survey/" + formData.getFormData()); + } catch (Exception e) { + LOGGER.error(String.format("Encountered an Exception while sending an email : %s", e.getMessage())); + } + String receipientEmail = "sakthivel.govindan@tarento.com"; + String secondaryEmail = "darshan.nagesh@tarento.com"; + updateLinkSentDate(formData.getFormData()); + SendMail.sendMail(new String[] { receipientEmail, secondaryEmail, data.getEmailId() }, + "Requesting your feedback", context, "email_template.vm"); + return Boolean.TRUE; + } + + private void updateLinkSentDate(String formData) throws IOException { + SearchRequest searchRequest = buildQueryForInteractionsFromFormData(formData); + MultiSearchResponse response = formsDao.executeMultiSearchRequest(searchRequest); + SearchResponse searchResponse = response.getResponses()[0].getResponse(); + JsonNode responseNode = null; + FormData fData = new FormData(); + if (searchResponse != null && searchResponse.getHits() != null) { + responseNode = new ObjectMapper().convertValue(searchResponse.getHits(), JsonNode.class); + if (responseNode.has("hits")) { + JsonNode innerHits = responseNode.findValue("hits"); + for (JsonNode eachInnerHit : innerHits) { + String id = eachInnerHit.findValue("id").asText(); + fData = gson.fromJson(eachInnerHit.findValue("sourceAsMap").toString(), FormData.class); + Map<String, Object> jsonMap = new HashMap<>(); + jsonMap.put("linkSentDate", new Date().getTime()); + formsDao.updateInteractions(jsonMap, id); + } + } + } + } + + private SearchRequest buildQueryForInteractionsFromFormData(String formData) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(1000); + BoolQueryBuilder boolBuilder = QueryBuilders.boolQuery(); + boolBuilder.must().add(QueryBuilders.matchQuery(Constants.Parameters.FORM_DATA, formData)); + searchSourceBuilder.query(boolBuilder); + return new SearchRequest(interactionIndexName).types("forms").source(searchSourceBuilder); + } +} diff --git a/src/main/java/com/tarento/formservice/service/impl/JsonFormsServiceImpl.java b/src/main/java/com/tarento/formservice/service/impl/JsonFormsServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c068b6881e6eff017e08acb5d768954c93b9de0d --- /dev/null +++ b/src/main/java/com/tarento/formservice/service/impl/JsonFormsServiceImpl.java @@ -0,0 +1,332 @@ +package com.tarento.formservice.service.impl; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.util.Calendar; +import java.util.Map; + +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.tarento.formservice.dao.FormsDao; +import com.tarento.formservice.models.Form; +import com.tarento.formservice.service.FormsService; +import com.tarento.formservice.service.JsonFormsService; +import com.tarento.formservice.utils.Constants; + +@Service(Constants.ServiceRepositories.JSON_FORMS_SERVICE) +public class JsonFormsServiceImpl implements JsonFormsService { + + public static final Logger LOGGER = LoggerFactory.getLogger(JsonFormsService.class); + + private static final String AUTHORIZATION = "Authorization"; + // private static final String US_ASCII = "US-ASCII"; + // private static final String BASIC_AUTH = "Basic %s"; + private final String indexServiceHost; + private final String userName; + private final String password; + @SuppressWarnings("unused") + private final String easIndexName; + @SuppressWarnings("unused") + private final String easDocType; + Gson gson = new Gson(); + + public JsonFormsServiceImpl(@Value("${services.esindexer.host}") String indexServiceHost, + @Value("${services.esindexer.username}") String userName, + @Value("${services.esindexer.password}") String password, + @Value("${es.fs.forms.index.name}") String easIndexName, + @Value("${es.fs.forms.document.type}") String easDocumentType) { + this.indexServiceHost = indexServiceHost; + this.userName = userName; + this.password = password; + this.easIndexName = easIndexName; + this.easDocType = easDocumentType; + } + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private FormsDao formsDao; + + @Autowired + private FormsService formsService; + + public static JsonObject convertToJsonObject(Object payload) { + GsonBuilder builder = new GsonBuilder(); + return (JsonObject) builder.setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create().toJsonTree(payload); + } + + @Override + public Boolean processJsonForms(Object jsonFormObject, Form form, + com.tarento.formservice.model.FormDetail formDetails) throws IOException { + LOGGER.info("FORM ID: {}", formDetails.getFormId()); + com.tarento.formservice.models.FormDetail detail = formsService + .getFormById(Long.parseLong(formDetails.getFormId())); + detail.setSecondaryId(form.getSecondaryId()); + detail.setTitle("Title"); + + String docId = ""; + SearchRequest searchRequest; + searchRequest = new SearchRequest(formDetails.getEsIndexName()); + HttpHeaders headers = new HttpHeaders(); + String auth = userName + ":" + password; + byte[] bytes = auth.getBytes(StandardCharsets.UTF_8); + String base64Encoded = java.util.Base64.getEncoder().encodeToString(bytes); + String authHeader = "Basic " + base64Encoded; + headers.add(AUTHORIZATION, authHeader); + headers.add("Content-Type", "application/json"); + ObjectMapper mapper = new ObjectMapper(); + + JsonNode node = mapper.convertValue(jsonFormObject, JsonNode.class); + // Date to Epoch conversion + Long epoch = null; + try { + epoch = new java.text.SimpleDateFormat("MM-dd-yyyy HH:mm:ss") + .parse(node.findValue("Date").asText() + " 23:59:59").getTime(); + } catch (ParseException e) { + LOGGER.info("Encounter an exception while parsing the Date" + e.getMessage()); + } + node = ((ObjectNode) node).put("Date", epoch); + if (formDetails.getEsIndexName().equals("kronos-tarento-summary")) { + if (node.get(Constants.KronosDashboards.DATE) != null + && !node.get(Constants.KronosDashboards.DATE).asText().isEmpty()) { + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.matchQuery( + Constants.KronosDashboards.DATE, node.get(Constants.KronosDashboards.DATE).asText())); + SearchSourceBuilder ssBuilder = new SearchSourceBuilder().query(queryBuilder); + searchRequest.source(ssBuilder); + Object searchResponse = formsDao.executeMultiSearchRequest(searchRequest); + JsonNode responseJsonNode = mapper.convertValue(searchResponse, JsonNode.class); + int hitSize = responseJsonNode.get("responses").get(0).get("response").get("hits").get("hits").size(); + // // check time stamp ? stored - > Override + + if (hitSize > 0) { + // override the document + docId = responseJsonNode.get("responses").get(0).get("response").get("hits").get("hits").get(0) + .get("id").asText(); + Object res; + HttpEntity<Object> entity = new HttpEntity<>(node, headers); + res = restTemplate.exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getEsIndexName() + "/" + + formDetails.getEsIndexDocType() + "/" + docId, + HttpMethod.PUT, entity, Object.class).getBody(); + + } else { + // check time stamp ? stored - > Override IN LOGS index + QueryBuilder qBuilder = QueryBuilders.boolQuery() + .must(QueryBuilders.matchQuery("sourceAsMap.Date", + node.get(Constants.KronosDashboards.DATE).asText())) + .must(QueryBuilders.matchQuery(Constants.KronosDashboards._INDEX, + formDetails.getEsIndexName())); + SearchSourceBuilder sBuilder = new SearchSourceBuilder().query(qBuilder); + searchRequest.source(sBuilder); + Object sRes = formsDao.executeMultiSearchRequest(searchRequest); + JsonNode resJsonNode = mapper.convertValue(searchResponse, JsonNode.class); + int hSize = responseJsonNode.get("responses").get(0).get("response").get("hits").get("hits").size(); + + if (hSize <= 0) { + // check if timestamp is stored for the same month and year with the same IBU + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(Long.parseLong(node.get(Constants.KronosDashboards.DATE).asText())); + calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); + long startDayEpoch = calendar.getTimeInMillis(); + calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); + long endDayEpoch = calendar.getTimeInMillis(); + + QueryBuilder qqBuilder = QueryBuilders.boolQuery().must(QueryBuilders + .rangeQuery(Constants.KronosDashboards.DATE).gte(startDayEpoch).lte(endDayEpoch)); + SearchSourceBuilder ssb = new SearchSourceBuilder().query(qqBuilder); + SearchRequest sRequest = new SearchRequest(formDetails.getEsIndexName()); + sRequest.source(ssb); + Object sResponse = formsDao.executeMultiSearchRequest(sRequest); + JsonNode rJNode = mapper.convertValue(sResponse, JsonNode.class); + int hitSizeOfRes = rJNode.get("responses").get(0).get("response").get("hits").get("hits") + .size(); + + // Maintain logs - DELETE RECORD - INSERT RECORD To LOGS - INSERT NEW RECORD TO + // THE DATA INDEX + if (hitSizeOfRes > 0) { + // push all the docs to "{name}-logs" index + for (int i = 0; i < hitSizeOfRes; i++) { + // Check Date is greater than the stored records + // Then push the record to the LOGS index & delete it from Data Index + if (rJNode.get("responses").get(0).get("response").get("hits").get("hits").get(i) + .get("sourceAsMap").get(Constants.KronosDashboards.DATE) + .asLong() < node.get(Constants.KronosDashboards.DATE).asLong()) { + // Store the index + HttpEntity<Object> entity = new HttpEntity<>( + mapper.convertValue(rJNode.get("responses").get(0).get("response") + .get("hits").get("hits").get(i), Map.class), + headers); + restTemplate.exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getAction() + "/" + + formDetails.getEsIndexDocType(), + HttpMethod.POST, entity, Object.class).getBody(); + // delete the docs from the index + // find the id + String documentId; + documentId = rJNode.get("responses").get(0).get("response").get("hits").get("hits") + .get(i).get("id").asText(); + HttpEntity<?> request = new HttpEntity<>(headers); + Object res = restTemplate.exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getEsIndexName() + + "/" + formDetails.getEsIndexDocType() + "/" + documentId, + HttpMethod.DELETE, request, String.class); + HttpEntity<Object> entity1 = new HttpEntity<>(node, headers); + Object o = restTemplate.exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getEsIndexName() + + "/" + formDetails.getEsIndexDocType(), + HttpMethod.POST, entity1, Object.class).getBody(); + } + } + } else { + HttpEntity<Object> entity = new HttpEntity<>(node, headers); + Object o = restTemplate + .exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getEsIndexName() + + "/" + formDetails.getEsIndexDocType(), + HttpMethod.POST, entity, Object.class) + .getBody(); + } + } + } + } + } else if (formDetails.getEsIndexName().equals("kronos-mis-ibu")) { + if (node.get(Constants.KronosDashboards.DATE) != null + && !node.get(Constants.KronosDashboards.DATE).asText().isEmpty()) { + QueryBuilder queryBuilder = QueryBuilders.boolQuery() + .must(QueryBuilders.matchQuery(Constants.KronosDashboards.DATE, + node.get(Constants.KronosDashboards.DATE).asText())) + .must(QueryBuilders.matchQuery(Constants.KronosDashboards.IBU, + node.get(Constants.KronosDashboards.IBU).asText())) + .must(QueryBuilders.matchQuery(Constants.KronosDashboards.COUNTRY, + node.get(Constants.KronosDashboards.COUNTRY).asText())); + SearchSourceBuilder ssBuilder = new SearchSourceBuilder().query(queryBuilder); + searchRequest.source(ssBuilder); + Object searchResponse = formsDao.executeMultiSearchRequest(searchRequest); + JsonNode responseJsonNode = mapper.convertValue(searchResponse, JsonNode.class); + int hitSize = responseJsonNode.get("responses").get(0).get("response").get("hits").get("hits").size(); + // // check time stamp ? stored - > Override + + if (hitSize > 0) { + // override the document + docId = responseJsonNode.get("responses").get(0).get("response").get("hits").get("hits").get(0) + .get("id").asText(); + Object res; + HttpEntity<Object> entity = new HttpEntity<>(node, headers); + res = restTemplate.exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getEsIndexName() + "/" + + formDetails.getEsIndexDocType() + "/" + docId, + HttpMethod.PUT, entity, Object.class).getBody(); + } else { + // check time stamp ? stored - > Override IN LOGS index + QueryBuilder qBuilder = QueryBuilders.boolQuery() + .must(QueryBuilders.matchQuery("sourceAsMap.Date", + node.get(Constants.KronosDashboards.DATE).asText())) + .must(QueryBuilders.matchQuery(Constants.KronosDashboards.IBU, + node.get(Constants.KronosDashboards.IBU).asText())) + .must(QueryBuilders.matchQuery(Constants.KronosDashboards.COUNTRY, + node.get(Constants.KronosDashboards.COUNTRY).asText())) + .must(QueryBuilders.matchQuery(Constants.KronosDashboards._INDEX, + formDetails.getEsIndexName())); + SearchSourceBuilder sBuilder = new SearchSourceBuilder().query(qBuilder); + searchRequest.source(sBuilder); + Object sRes = formsDao.executeMultiSearchRequest(searchRequest); + JsonNode resJsonNode = mapper.convertValue(searchResponse, JsonNode.class); + int hSize = responseJsonNode.get("responses").get(0).get("response").get("hits").get("hits").size(); + + if (hSize <= 0) { + // check if timestamp is stored for the same month and year with the same IBU + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(Long.parseLong(node.get(Constants.KronosDashboards.DATE).asText())); + calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); + long startDayEpoch = calendar.getTimeInMillis(); + calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); + long endDayEpoch = calendar.getTimeInMillis(); + + QueryBuilder qqBuilder = QueryBuilders.boolQuery() + .must(QueryBuilders.matchQuery(Constants.KronosDashboards.IBU, + node.get(Constants.KronosDashboards.IBU).asText())) + .must(QueryBuilders.matchQuery(Constants.KronosDashboards.COUNTRY, + node.get(Constants.KronosDashboards.COUNTRY).asText())) + .must(QueryBuilders.rangeQuery(Constants.KronosDashboards.DATE).gte(startDayEpoch) + .lte(endDayEpoch)); + SearchSourceBuilder ssb = new SearchSourceBuilder().query(qqBuilder); + SearchRequest sRequest = new SearchRequest(formDetails.getEsIndexName()); + sRequest.source(ssb); + Object sResponse = formsDao.executeMultiSearchRequest(sRequest); + JsonNode rJNode = mapper.convertValue(sResponse, JsonNode.class); + int hitSizeOfRes = rJNode.get("responses").get(0).get("response").get("hits").get("hits") + .size(); + + // Maintain logs - DELETE RECORD - INSERT RECORD To LOGS - INSERT NEW RECORD TO + // THE DATA INDEX + if (hitSizeOfRes > 0) { + // push all the docs to "{name}-logs" index + for (int i = 0; i < hitSizeOfRes; i++) { + // Check Date is greater than the stored records + // Then push the record to the LOGS index & delete it from Data Index + if (rJNode.get("responses").get(0).get("response").get("hits").get("hits").get(i) + .get("sourceAsMap").get(Constants.KronosDashboards.DATE) + .asLong() < node.get(Constants.KronosDashboards.DATE).asLong()) { + // Store the index + HttpEntity<Object> entity = new HttpEntity<>( + mapper.convertValue(rJNode.get("responses").get(0).get("response") + .get("hits").get("hits").get(i), Map.class), + headers); + restTemplate.exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getAction() + "/" + + formDetails.getEsIndexDocType(), + HttpMethod.POST, entity, Object.class).getBody(); + // delete the docs from the index + // find the id + String documentId; + documentId = rJNode.get("responses").get(0).get("response").get("hits").get("hits") + .get(i).get("id").asText(); + HttpEntity<?> request = new HttpEntity<>(headers); + Object res = restTemplate.exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getEsIndexName() + + "/" + formDetails.getEsIndexDocType() + "/" + documentId, + HttpMethod.DELETE, request, String.class); + HttpEntity<Object> entity1 = new HttpEntity<>(node, headers); + Object o = restTemplate.exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getEsIndexName() + + "/" + formDetails.getEsIndexDocType(), + HttpMethod.POST, entity1, Object.class).getBody(); + } + } + } else { + HttpEntity<Object> entity = new HttpEntity<>(node, headers); + Object o = restTemplate + .exchange( + Constants.HTTP + this.indexServiceHost + "/" + formDetails.getEsIndexName() + + "/" + formDetails.getEsIndexDocType(), + HttpMethod.POST, entity, Object.class) + .getBody(); + } + } + } + } + } + return Boolean.TRUE; + } +} diff --git a/src/main/java/com/tarento/formservice/utils/AnalyticsSchedulerManager.java b/src/main/java/com/tarento/formservice/utils/AnalyticsSchedulerManager.java new file mode 100644 index 0000000000000000000000000000000000000000..6654fb9c2a2864e8f5570843a01ca17d02b148ea --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/AnalyticsSchedulerManager.java @@ -0,0 +1,44 @@ +package com.tarento.formservice.utils; + +import org.quartz.CronScheduleBuilder; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.Scheduler; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.impl.StdSchedulerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.tarento.formservice.service.impl.FormsServiceImpl; + +public class AnalyticsSchedulerManager { + public static final Logger LOGGER = LoggerFactory.getLogger(FormsServiceImpl.class); + + /** + * SCHEDULER job is configured here + */ + public static void schedule() { + JobDetail dailyJob = JobBuilder.newJob(InteractionRequestFeedbackJob.class) + .withIdentity("DailyInteractionTime", "DailyInteractionData").build(); + Trigger dailyTrigger = TriggerBuilder.newTrigger().withIdentity("InteractionTimeDaily", "InteractionDataDaily") + // this SCHEDULER will run every day at 5:30 PM in UTC . + .withSchedule(CronScheduleBuilder.cronSchedule("0 0 3 ? * MON-SUN")).build(); + // 0 30 17 1/1 * ? * ->> 5:30 everyday + // 0 0/2 * 1/1 * ? * ->> Every 2 mins + // 0 30 17 ? * FRI,SUN * ->> Weekly Mail + // 0 30 17 ? * MON-FRI ->> Monday to Friday at 5:30 + try { + Scheduler scheduler = new StdSchedulerFactory().getScheduler(); + scheduler.start(); + scheduler.scheduleJob(dailyJob, dailyTrigger); + } catch (Exception e) { + LOGGER.error(String.format("Encountered an error while running the scheduler: %s", e.getMessage())); + } + } + + private AnalyticsSchedulerManager() { + super(); + + } +} diff --git a/src/main/java/com/tarento/formservice/utils/Constants.java b/src/main/java/com/tarento/formservice/utils/Constants.java new file mode 100644 index 0000000000000000000000000000000000000000..010552ab4698d057557b837e216f6f7e9729d911 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/Constants.java @@ -0,0 +1,117 @@ +package com.tarento.formservice.utils; + +public interface Constants { + + public class SMTP { + private SMTP() { + super(); + } + + public static final String HOST = "smtpout.idc.tarento.com"; + public static final int PORT = 587; + public static final boolean SSL = true; + public static final String USER = "AKIAJJLLS652M5B32APA"; + public static final String PSWRD = "AhYkENBNOY9M6Cl29IqETcKIWsP5Z+dUNuigVKglCuU5"; + public static final String EMAIL = "timetrack@tarento.com"; + public static final String ALIAS = "aurora-desk.support"; + } + + public static final String HOST = "smtpout.idc.tarento.com"; + public static final String FROM = "timetrack@tarento.com"; + public static final String USER = "AKIAJJLLS652M5B32APA"; + public static final String PSWRD = "AhYkENBNOY9M6Cl29IqETcKIWsP5Z+dUNuigVKglCuU5"; + public static final String ALIAS = "pulz.support"; + public static final String LOGO_URL = "https://cabhound-static.s3.amazonaws.com/insuranceDoc/claim/tarento_logo.png"; + public static final int MAX_EXECUTOR_THREAD = 10; + + interface ServiceRepositories { + static final String FORM_SERVICE = "formsService"; + static final String FORM_REPO = "formDao"; + static final String FORM_SQL_REPO = "formSqlDao"; + static final String JSON_FORMS_SERVICE = "jsonFormsService"; + } + + interface RequestMethods { + static final String GET = "GET"; + static final String POST = "POST"; + static final String OPTIONS = "OPTIONS"; + static final String DELETE = "DELETE"; + static final String PUT = "PUT"; + } + + interface ResponseCodes { + static final int UNAUTHORIZED_ID = 401; + static final int SUCCESS_ID = 200; + static final int FAILURE_ID = 320; + static final String UNAUTHORIZED = "Invalid credentials. Please try again."; + static final String PROCESS_FAIL = "Process failed, Please try again."; + static final String SUCCESS = "success"; + } + + interface Parameters { + static final String PARAMETER = "parameter"; + static final String HASHCODE = "hashcode"; + static final String PUBLISHED = "isPublished"; + static final String SAVED = "isSaved"; + static final String ACTIVE = "isActive"; + static final String DETAIL = "isDetail"; + static final String DELETED = "isDeleted"; + static final String ID = "id"; + static final String GETALL = "getAll"; + static final String CONTEXT = "dataContext"; + static final String CONTEXT_VERSION = "dataContextVersion"; + static final String VERSION = "version"; + static final String FORM_DATA = "urlCode"; + } + + interface PortfolioConstants { + static final String FEATURED = "Featured"; + static final String PROJECT = "PROJECT"; + static final String SERVICE = "SERVICE"; + static final String COLLECTION = "COLLECTION"; + static final String PROJECT_AND_SERVICE = "PROJECT&SERVICE"; + static final String ALL_PORTFOLIO = "All"; + static final Long METADATA_PROJECT_ID = 9999l; + static final Long ALL_COLLECTION_ID = 9999l; + static final String BGIMAGE_KEY = "BackgroundImages"; + static final String BGCOLOR_KEY = "BackgroundColors"; + static final String LATEST_PORTFOLIO = "latestPortfolio"; + static final String ID_KEY = "_id"; + static final String VALUE_KEYWORD = "contents.dataNodes.value.keyword"; + static final String CONTENT_VALUE_KEYWORD = "projectDetails.content.value.keyword"; + static final String DISTRIBUTIONLIST_URL_KEYWORD = "distributionList.url.keyword"; + static final String DISTRIBUTIONLIST_PURPOSE_KEYWORD = "distributionList.purpose.keyword"; + static final String TAGS_KEYWORD = "tags.keyword"; + } + + interface KronosDashboards { + static final String AS_ON_MONTH = "AsOnMonth"; + static final String IBU_NAME = "IBU Name"; + static final String RESPONSES = "responses"; + static final String RESPONSE = "response"; + static final String SOURCE_AS_MAP = "sourceAsMap"; + static final String _INDEX = "_index"; + static final String SALES_PERSRON = "Sales Person"; + static final String JOINING_DATE = "JoiningDate"; + static final String USER_ID = "User ID"; + static final String MOBILE_NO = "MobileNo"; + static final String EMAIL = "Email"; + static final String DATE = "Date"; + static final String IBU = "IBU"; + static final String COUNTRY = "Country"; + + } + + interface ResponseMessages { + static final String ERROR_MESSAGE = "Unable to fetch the details. Please try again later!"; + static final String PACK_HASHCODE_EMPTY = "Hashcode cannot be empty! Please try again with valid hashcode"; + static final String PACK_DISTRIBUTION_INVALID = "This pack is no longer valid. Please contact admin!"; + } + + interface Markers { + static final String DAO_IMPL = "DAOIMPL"; + } + + static final String HTTP = "https://"; + public static final String TIME_ZONE = "UTC"; +} diff --git a/src/main/java/com/tarento/formservice/utils/DateUtil.java b/src/main/java/com/tarento/formservice/utils/DateUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..91ce529f14e8264516da1480f472e5e5f5c5364e --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/DateUtil.java @@ -0,0 +1,391 @@ +package com.tarento.formservice.utils; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import lombok.NoArgsConstructor; + +@NoArgsConstructor +public class DateUtil { + + private static final String ENCOUNTERED_AN_EXCEPTION = "Encountered an Exception : %s"; + public static final Logger LOGGER = LoggerFactory.getLogger(DateUtil.class); + + public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; + public static final String INVOICE_DATE_FORMATTER = "EEEE, MMMM d, yyyy"; + public static final String YYYYMMDD_FORMATTER = "yyyy-MM-dd"; + public static final String DATE_MONTH_YEAR_FORMAT = "dd-MMMM-yyyy"; + + /** + * this method take date object and format the date with time zone UTC. + * + * @param date + * date object + * @return formatted date as String in "yyyy-MM-dd HH:mm:ss" + */ + public static String getFormattedDateInUTC(Date date) { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(Constants.TIME_ZONE)); + return format.format(date); + } + + /** + * this method take date object and time zone ,and format date object with + * incoming time zone. + * + * @param date + * date object + * @param timeZone + * @return formatted date as String in "yyyy-MM-dd HH:mm:ss" + */ + public static String getFormattedDateWithTimeZone(Date date, String timeZone) { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + return format.format(date); + } + + /** + * this method will format current date object with incoming formatter + * + * @param format + * date formatter + * @return String formatted date object. + */ + public static String getCurrentDate(String format) { + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + return dateFormat.format(new Date()); + } + + /** + * this method will format long time value to given time zone with MM-dd-yyyy + * HH:mm:ss + * + * @param timeZone + * @param time + * @return String + */ + public static String convertLongToStringAsDateTime(String timeZone, long time) { + SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss"); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + Date date = new Date(time); + return format.format(date); + } + + /** + * this method will format long time value to given time zone with MM-dd-yyyy + * HH:mm:ss + * + * @param timeZone + * @param date + * @param incomingDateFormat + * @return String + */ + public static String dateFormatter(String timeZone, String date, String incomingDateFormat) { + SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss"); + SimpleDateFormat incomingFormatter = new SimpleDateFormat(incomingDateFormat); + incomingFormatter.setTimeZone(TimeZone.getDefault()); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + String response = ""; + try { + Date defaultFormattedDate = incomingFormatter.parse(date); + response = format.format(defaultFormattedDate); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return response; + } // + + /** + * this method will format long time value to given time zone with MMMMM d + * EEEEEEEEE,hh:mm a + * + * @param timeZone + * @param date + * @param incomingDateFormat + * @return String + */ + public static String ormatterInMMMMdEEE(String timeZone, String date, String incomingDateFormat) { + SimpleDateFormat format = new SimpleDateFormat("EEEEEEEEE, MMMMM d @hh:mm a"); + SimpleDateFormat incomingFormatter = new SimpleDateFormat(incomingDateFormat); + incomingFormatter.setTimeZone(TimeZone.getDefault()); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + String response = ""; + try { + Date defaultFormattedDate = incomingFormatter.parse(date); + response = format.format(defaultFormattedDate); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return response; + } + + /** + * this method will format long time value to given time zone with MMMMM d + * EEEEEEEEE,hh:mm a + * + * @param timeZone + * @param time + * @return String + */ + public static String convertLongToStringAsMMMMEEEE(String timeZone, long time) { + SimpleDateFormat format = new SimpleDateFormat("EEEEEEEEE, MMMMM d @hh:mm a"); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + Date date = new Date(time); + return format.format(date); + } + + /** + * this method will format date object with time zone + * + * @param date + * date object + * @param timeZone + * String + * @return String + */ + public static String getSqlTimeStamp(Date date, String... timeZone) { + + DateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + if (timeZone != null && timeZone.length > 0) { + format.setTimeZone(TimeZone.getTimeZone(timeZone[0])); + } + return format.format(date); + } + + /** + * this method will convert long value to date object and provide formatted date + * object in "yyyy-MM-dd HH:mm:ss" this form + * + * @param time + * @return String + */ + public static String getSqlTimeStamp(Long time) { + return getSqlTimeStamp(new Date(time)); + } + + /** + * + * @param date + * @param timeZone + * @return Date + * @throws Exception + */ + public static Date getDateInDefaultTimeZone(String date, String timeZone) throws Exception { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + SimpleDateFormat formatterWithDefaultTimeZone = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + Date reservationTimeWithTimeZone = format.parse(date + ":00"); + String reservationTimeWithDefaultTimeZone = formatterWithDefaultTimeZone.format(reservationTimeWithTimeZone); + return formatterWithDefaultTimeZone.parse(reservationTimeWithDefaultTimeZone); + } + + /** + * + * @return Date + * @throws Exception + */ + public static Date getCurrentDate() throws Exception { + SimpleDateFormat formatterWithDefaultTimeZone = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + Date currDate = new Date(); + String currTimeWithTimeZone = formatterWithDefaultTimeZone.format(currDate); + return formatterWithDefaultTimeZone.parse(currTimeWithTimeZone); + } + + /** + * This method will convert String date time with UTC time Zone in "yyyy-MM-dd + * HH:mm:ss" format + * + * @param date + * String + * @return Date jave.util Date object + */ + public static Date convertStringToDateWithTime(String date) { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(Constants.TIME_ZONE)); + Date afterFormat = null; + try { + afterFormat = format.parse(date); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return afterFormat; + } + + /** + * this method will provide current data in GMT. + * + * @return Date Object + */ + public static Date getCurrentDateInGmt() { + Calendar c = Calendar.getInstance(); + TimeZone z = c.getTimeZone(); + int offset = z.getRawOffset(); + if (z.inDaylightTime(new Date())) { + offset = offset + z.getDSTSavings(); + } + int offsetHrs = offset / 1000 / 60 / 60; + int offsetMints = offset / 1000 / 60 % 60; + c.add(Calendar.HOUR_OF_DAY, (-offsetHrs)); + c.add(Calendar.MINUTE, (-offsetMints)); + return c.getTime(); + } + + /** + * this method is used to take system current time and return time with time + * zone. + * + * @param date + * current date + * @param timezone + * time + * @return String + */ + public static String convertDateWithTimeZone(Date date, String timezone) { + SimpleDateFormat dateFormatGmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + dateFormatGmt.setTimeZone(TimeZone.getTimeZone(timezone)); + return dateFormatGmt.format(date); + + } + + /** + * this method will convert String to date object with system time zone. + * + * @param date + * String + * @return Date + */ + public static Date convertStringToDate(String date) { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + Date afterFormat = null; + try { + afterFormat = format.parse(date); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return afterFormat; + } + + /** + * this will format incoming date with MM/dd/yyyy + * + * @param date + * String + * @return String + */ + public static String formateWithMMddyyyy(String date) { + SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); + String formattedDate = ""; + try { + formattedDate = format.format(dateFormat.parse(date)); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + + return formattedDate; + } + + /** + * This method will return reservation time and current time difference in + * minutes. + * + * @param date + * String reservation time + * @return int + */ + public static int getDateDifferenceInMinutes(String date) { + int diffDate = 0; + SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + dateFormat.setTimeZone(TimeZone.getTimeZone(Constants.TIME_ZONE)); + try { + Date requestedDate = dateFormat.parse(date); + Date currentDate = new Date(); + currentDate = dateFormat.parse(dateFormat.format(currentDate)); + diffDate = (int) ((requestedDate.getTime() - currentDate.getTime()) / 60000); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return diffDate; + } + + /** + * This method will formate incoming String to time zone and format. + * + * @param date + * @param timZone + * @param format + * @return + */ + public static String formatStringToTimeZone(String date, String timZone, String format) { + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + dateFormat.setTimeZone(TimeZone.getTimeZone(timZone)); + SimpleDateFormat dateFormat1 = new SimpleDateFormat(format); + dateFormat1.setTimeZone(TimeZone.getTimeZone(Constants.TIME_ZONE)); + String formattedDate = date; + try { + Date parseDate = dateFormat.parse(date); + formattedDate = dateFormat1.format(parseDate); + formattedDate = dateFormat1.format(dateFormat1.parse(formattedDate)); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return formattedDate; + } + + /** + * This method will provide current date in UTC format in YYYY_MM_DD format. + * + * @return String + */ + public static String getYyyyMmDdInUTC() { + SimpleDateFormat format = new SimpleDateFormat(YYYYMMDD_FORMATTER); + format.setTimeZone(TimeZone.getTimeZone(Constants.TIME_ZONE)); + return format.format(new Date()); + } + + /** + * this method will convert String to date object in UTC + * + * @param date + * String + * @return Date + */ + public static Date convertStringToDateUTC(String date) { + SimpleDateFormat format = new SimpleDateFormat(YYYYMMDD_FORMATTER); + format.setTimeZone(TimeZone.getTimeZone(Constants.TIME_ZONE)); + Date afterFormat = null; + try { + afterFormat = format.parse(date); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return afterFormat; + } + + public static String getTimeWithHHMMSSFormat() { + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); + return sdf.format(cal.getTime()); + + } + + public static Date convertPorjectUploadDate(String date) { + SimpleDateFormat format = new SimpleDateFormat(DATE_MONTH_YEAR_FORMAT); + Date formatDate = null; + try { + formatDate = format.parse(date); + } catch (ParseException e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return formatDate; + } + +} diff --git a/src/main/java/com/tarento/formservice/utils/DateUtils.java b/src/main/java/com/tarento/formservice/utils/DateUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..5f712c0a71129b0f48b77a6c699534c87bb8ec0f --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/DateUtils.java @@ -0,0 +1,416 @@ +package com.tarento.formservice.utils; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DateUtils { + private static final String ENCOUNTERED_AN_EXCEPTION = "Encountered an Exception : %s"; + public static final Logger LOGGER = LoggerFactory.getLogger(DateUtil.class); + + public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; + public static final String INVOICE_DATE_FORMATTER = "EEEE, MMMM d, yyyy"; + public static final String YYYYMMDD_FORMATTER = "yyyy-MM-dd"; + public static final String DATE_MONTH_YEAR_FORMAT = "dd-MMMM-yyyy"; + + public static Date startOfDay(LocalDateTime localDate) { + return Date.from(localDate.with(LocalTime.MIDNIGHT).atZone(ZoneId.systemDefault()).toInstant()); + } + + public static Date now(LocalDateTime localDate) { + return Date.from(localDate.atZone(ZoneId.systemDefault()).toInstant()); + } + + public static Date asDate(LocalDateTime localDateTime) { + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + + public static Date endOfDay(LocalDateTime localDate) { + return Date.from(localDate.with(LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant()); + } + + public static LocalDate asLocalDate(Date date) { + return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate(); + } + + public static LocalDateTime asLocalDateTime(Date date) { + return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime(); + } + + /** + * this method take date object and format the date with time zone UTC. + * + * @param date + * date object + * @return formatted date as String in "yyyy-MM-dd HH:mm:ss" + */ + public static String getFormattedDateInUTC(Date date) { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())); + return format.format(date); + } + + /** + * this method take date object and time zone ,and format date object with + * incoming time zone. + * + * @param date + * date object + * @param timeZone + * @return formatted date as String in "yyyy-MM-dd HH:mm:ss" + */ + public static String getFormattedDateWithTimeZone(Date date, String timeZone) { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + return format.format(date); + } + + /** + * this method will format current date object with incoming formatter + * + * @param format + * date formatter + * @return String formatted date object. + */ + public static String getCurrentDate(String format) { + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + return dateFormat.format(new Date()); + } + + /** + * this method will format long time value to given time zone with MM-dd-yyyy + * HH:mm:ss + * + * @param timeZone + * @param time + * @return String + */ + public static String convertLongToStringAsDateTime(String timeZone, long time) { + SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss"); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + Date date = new Date(time); + return format.format(date); + } + + /** + * this method will format long time value to given time zone with MM-dd-yyyy + * HH:mm:ss + * + * @param timeZone + * @param date + * @param incomingDateFormat + * @return String + */ + public static String dateFormatter(String timeZone, String date, String incomingDateFormat) { + SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss"); + SimpleDateFormat incomingFormatter = new SimpleDateFormat(incomingDateFormat); + incomingFormatter.setTimeZone(TimeZone.getDefault()); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + String response = ""; + try { + Date defaultFormattedDate = incomingFormatter.parse(date); + response = format.format(defaultFormattedDate); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return response; + } // + + /** + * this method will format long time value to given time zone with MMMMM d + * EEEEEEEEE,hh:mm a + * + * @param timeZone + * @param date + * @param incomingDateFormat + * @return String + */ + public static String ormatterInMMMMdEEE(String timeZone, String date, String incomingDateFormat) { + SimpleDateFormat format = new SimpleDateFormat("EEEEEEEEE, MMMMM d @hh:mm a"); + SimpleDateFormat incomingFormatter = new SimpleDateFormat(incomingDateFormat); + incomingFormatter.setTimeZone(TimeZone.getDefault()); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + String response = ""; + try { + Date defaultFormattedDate = incomingFormatter.parse(date); + response = format.format(defaultFormattedDate); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return response; + } + + /** + * this method will format long time value to given time zone with MMMMM d + * EEEEEEEEE,hh:mm a + * + * @param timeZone + * @param time + * @return String + */ + public static String convertLongToStringAsMMMMEEEE(String timeZone, long time) { + SimpleDateFormat format = new SimpleDateFormat("EEEEEEEEE, MMMMM d @hh:mm a"); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + Date date = new Date(time); + return format.format(date); + } + + /** + * this method will format date object with time zone + * + * @param date + * date object + * @param timeZone + * String + * @return String + */ + public static String getSqlTimeStamp(Date date, String... timeZone) { + + DateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + if (timeZone != null && timeZone.length > 0) { + format.setTimeZone(TimeZone.getTimeZone(timeZone[0])); + } + return format.format(date); + } + + /** + * this method will convert long value to date object and provide formatted date + * object in "yyyy-MM-dd HH:mm:ss" this form + * + * @param time + * @return String + */ + public static String getSqlTimeStamp(Long time) { + return getSqlTimeStamp(new Date(time)); + } + + /** + * + * @param date + * @param timeZone + * @return Date + * @throws Exception + */ + public static Date getDateInDefaultTimeZone(String date, String timeZone) throws Exception { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + SimpleDateFormat formatterWithDefaultTimeZone = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(timeZone)); + Date reservationTimeWithTimeZone = format.parse(date + ":00"); + String reservationTimeWithDefaultTimeZone = formatterWithDefaultTimeZone.format(reservationTimeWithTimeZone); + return formatterWithDefaultTimeZone.parse(reservationTimeWithDefaultTimeZone); + } + + /** + * + * @return Date + * @throws Exception + */ + public static Date getCurrentDate() throws Exception { + SimpleDateFormat formatterWithDefaultTimeZone = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + Date currDate = new Date(); + String currTimeWithTimeZone = formatterWithDefaultTimeZone.format(currDate); + return formatterWithDefaultTimeZone.parse(currTimeWithTimeZone); + } + + /** + * This method will convert String date time with UTC time Zone in "yyyy-MM-dd + * HH:mm:ss" format + * + * @param date + * String + * @return Date jave.util Date object + */ + public static Date convertStringToDateWithTime(String date) { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())); + Date afterFormat = null; + try { + afterFormat = format.parse(date); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return afterFormat; + } + + /** + * this method will provide current data in GMT. + * + * @return Date Object + */ + public static Date getCurrentDateInGmt() { + Calendar c = Calendar.getInstance(); + TimeZone z = c.getTimeZone(); + int offset = z.getRawOffset(); + if (z.inDaylightTime(new Date())) { + offset = offset + z.getDSTSavings(); + } + int offsetHrs = offset / 1000 / 60 / 60; + int offsetMints = offset / 1000 / 60 % 60; + c.add(Calendar.HOUR_OF_DAY, (-offsetHrs)); + c.add(Calendar.MINUTE, (-offsetMints)); + return c.getTime(); + } + + /** + * this method is used to take system current time and return time with time + * zone. + * + * @param date + * current date + * @param timezone + * time + * @return String + */ + public static String convertDateWithTimeZone(Date date, String timezone) { + SimpleDateFormat dateFormatGmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + dateFormatGmt.setTimeZone(TimeZone.getTimeZone(timezone)); + return dateFormatGmt.format(date); + + } + + /** + * this method will convert String to date object with system time zone. + * + * @param date + * String + * @return Date + */ + public static Date convertStringToDate(String date) { + SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + Date afterFormat = null; + try { + afterFormat = format.parse(date); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return afterFormat; + } + + /** + * this will format incoming date with MM/dd/yyyy + * + * @param date + * String + * @return String + */ + public static String formateWithMMddyyyy(String date) { + SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); + String formattedDate = ""; + try { + formattedDate = format.format(dateFormat.parse(date)); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + + return formattedDate; + } + + /** + * This method will return reservation time and current time difference in + * minutes. + * + * @param date + * String reservation time + * @return int + */ + public static int getDateDifferenceInMinutes(String date) { + int diffDate = 0; + SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + dateFormat.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())); + try { + Date requestedDate = dateFormat.parse(date); + Date currentDate = new Date(); + currentDate = dateFormat.parse(dateFormat.format(currentDate)); + diffDate = (int) ((requestedDate.getTime() - currentDate.getTime()) / 60000); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return diffDate; + } + + /** + * This method will formate incoming String to time zone and format. + * + * @param date + * @param timZone + * @param format + * @return + */ + public static String formatStringToTimeZone(String date, String timZone, String format) { + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + dateFormat.setTimeZone(TimeZone.getTimeZone(timZone)); + SimpleDateFormat dateFormat1 = new SimpleDateFormat(format); + dateFormat1.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())); + String formattedDate = date; + try { + Date parseDate = dateFormat.parse(date); + formattedDate = dateFormat1.format(parseDate); + formattedDate = dateFormat1.format(dateFormat1.parse(formattedDate)); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return formattedDate; + } + + /** + * This method will provide current date in UTC format in YYYY_MM_DD format. + * + * @return String + */ + public static String getYyyyMmDdInUTC() { + SimpleDateFormat format = new SimpleDateFormat(YYYYMMDD_FORMATTER); + format.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())); + return format.format(new Date()); + } + + /** + * this method will convert String to date object in UTC + * + * @param date + * String + * @return Date + */ + public static Date convertStringToDateUTC(String date) { + SimpleDateFormat format = new SimpleDateFormat(YYYYMMDD_FORMATTER); + format.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())); + Date afterFormat = null; + try { + afterFormat = format.parse(date); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return afterFormat; + } + + public static String getTimeWithHHMMSSFormat() { + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); + return sdf.format(cal.getTime()); + + } + + public static Date convertPorjectUploadDate(String date) { + SimpleDateFormat format = new SimpleDateFormat(DATE_MONTH_YEAR_FORMAT); + Date formatDate = null; + try { + formatDate = format.parse(date); + } catch (ParseException e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + return formatDate; + } + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/utils/ElasticProperties.java b/src/main/java/com/tarento/formservice/utils/ElasticProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..4bc1754c745ff98589ff4e56777edbb3f12af8cd --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/ElasticProperties.java @@ -0,0 +1,66 @@ +package com.tarento.formservice.utils; + +public interface ElasticProperties { + + public interface Property { + final String TRANSACTION_TRANSDATE = "TransDate"; + final String TRANSACTION_STOREID = "StoreId"; + final String TRANSACTION_NETAMOUNT = "NetAmt"; + final String TARGET_TARGETDATE = "targetDate"; + final String TARGET_STORECODE = "storeCode"; + final String TARGET_VERSION = "version"; + final String TARGET_SALESVALUE = "salesValue"; + final String TARGET_AVGVALUE = "avgValue"; + final String TARGET_RECEIPTVALUE = "receiptsValue"; + final String ITEM_DETAILS_CATEGORY_ID = "itemDetails.categoryId"; + final String ITEM_DETAILS_PRICE = "itemDetails.price" ; + final String AVERAGE_RATING = "AvgRating"; + final String SORT_ORDER_DESCENDING = "desc"; + final String SORT_ORDER_ASCENDING = "asc"; + final String COUNTS = "counts"; + final String COUNTS_RATING = "CountsRating"; + final String FEEDBACK_VALUE_RESPONSE = "feedback_value"; + } + + public interface SuccessMessages { + final String STORE_USER = "User and Store successfully mapped" ; + final String STORE_TIMING = "Store Times entered successfully" ; + } + + public interface Query { + final String MATCH_CONDITION = "MATCH"; + final String RANGE_CONDITION = "RANGE"; + final String AGGREGATION_CONDITION = " AGGREGATION"; + final String TRANSACTION_DATE_FIELD = "TransDate"; + final String FEEDBACK_DATE_TIME = "serverDateTime"; + final String COUNT_STORE_CODE = "storeId"; + final String COUNT_RATING_VALUE = "value"; + final String COUNT_REASON_KEYWORD = "reasons.keyword"; + final String COUNT_GENDER_KEYWORD = "gender.keyword"; + final String COUNT_AGEGROUP_KEYWORD = "ageGroup.keyword"; + final String SUM = "SUM"; + final String VALUE_COUNT="value_count"; + final String AVG = "AVG"; + final String CUMMULATIVE_SUM="cumulative_sum"; + final String FIELD = "FIELD"; + final String COUNT = "COUNT"; + final String BUCKETS_PATH = "BUCKETS_PATH"; + final String DATE_HISTOGRAM = "DATE_HISTOGRAM"; + final String EXTENDED_BOUNDS = "EXTENDED_BOUNDS"; + final String MIN = "MIN"; + final String MAX = "MAX"; + final String INTERVAL = "INTERVAL"; + final String HOUR ="HOUR"; + final String DAY ="DAY"; + final String MINUTE ="MINUTE"; + final String MONTH ="MONTH"; + final String TERM ="TERM"; + final String SIZE="size"; + final String ORDER="order"; + final Integer TOP_CSAT_STORE_COUNT = 5; + + + + } + +} \ No newline at end of file diff --git a/src/main/java/com/tarento/formservice/utils/ExcelConstants.java b/src/main/java/com/tarento/formservice/utils/ExcelConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..4ab5f1f577aff68a4a75f30bacbd1032c74e5742 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/ExcelConstants.java @@ -0,0 +1,10 @@ +package com.tarento.formservice.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public interface ExcelConstants { + public final List<String> RATING_LIST_STRING = new ArrayList<>(Arrays.asList("header", "seperator")); + +} diff --git a/src/main/java/com/tarento/formservice/utils/ExcelFileUtil.java b/src/main/java/com/tarento/formservice/utils/ExcelFileUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..2d1ddc9674e087cac0b4c7d958e3143f059b739e --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/ExcelFileUtil.java @@ -0,0 +1,200 @@ +package com.tarento.formservice.utils; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Random; + +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.tarento.formservice.models.Field; +import com.tarento.formservice.models.FormDetail; +import com.tarento.formservice.producer.FormServiceProducer; + +public class ExcelFileUtil { + public static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ExcelFileUtil.class); + + private static final String CSV_CHARACTER_SEPERATOR = ","; + + @Autowired + FormServiceProducer formServiceProducer; + + private static Long clientDateString(String source) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", Locale.UK); + Date date = null; + try { + date = df.parse(source); + } catch (ParseException e) { + LOGGER.error("Encountered an Exception while parsing the Date : {}", e.getMessage()); + } + if (date != null) { + return date.getTime(); + } else { + return null; + } + } + + private static Long removePercentSymbol(String source) { + String value = source.replace("%", ""); + if (StringUtils.isNotBlank(value)) { + return Long.parseLong(value); + } else { + return null; + } + } + + private static Long applyLogicOnfieldEnrolmentDate(String enrolmentDate) { + if (!enrolmentDate.equals("") && !enrolmentDate.equals("\"\"") && StringUtils.isNotBlank(enrolmentDate)) { + Calendar cal = Calendar.getInstance(); + String[] splitArray = enrolmentDate.split(" "); + List<String> stringArray = Arrays.asList(splitArray); + String firstPart = stringArray.get(0); + String secondPart = stringArray.get(1); + String[] datePart = firstPart.split("-"); + List<String> datePartList = Arrays.asList(datePart); + String[] timePart = secondPart.split(":"); + List<String> timePartList = Arrays.asList(timePart); + + cal.set(Calendar.YEAR, Integer.parseInt(datePartList.get(0))); + cal.set(Calendar.MONTH, Integer.parseInt(datePartList.get(1)) - 1); + cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(datePartList.get(2))); + if (Integer.parseInt(timePartList.get(0)) < 12) { + cal.set(Calendar.HOUR, Integer.parseInt(timePartList.get(0)) - 1); + cal.set(Calendar.AM_PM, Calendar.AM); + } else { + cal.set(Calendar.HOUR, Integer.parseInt(timePartList.get(0)) - 13); + cal.set(Calendar.AM_PM, Calendar.PM); + } + cal.set(Calendar.MINUTE, Integer.parseInt(timePartList.get(1))); + cal.set(Calendar.SECOND, Integer.parseInt(timePartList.get(2))); + return cal.getTimeInMillis(); + } else { + return null; + } + + } + + private static Long applyLogicOnfieldCompletionDate(String completionDate) { + if (!completionDate.equals("") && !completionDate.equals("\"\"") && StringUtils.isNotBlank(completionDate)) { + String[] splitArray = null; + splitArray = completionDate.split("T"); + List<String> stringArray = Arrays.asList(splitArray); + String firstPart = stringArray.get(0); + String secondPart = stringArray.get(1); + String[] datePart = firstPart.split("-"); + List<String> datePartList = Arrays.asList(datePart); + String[] timePart = secondPart.split(":"); + List<String> timePartList = Arrays.asList(timePart); + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, Integer.parseInt(datePartList.get(0))); + cal.set(Calendar.MONTH, Integer.parseInt(datePartList.get(1)) - 1); + cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(datePartList.get(2))); + if (Integer.parseInt(timePartList.get(0)) < 12) { + cal.set(Calendar.HOUR, Integer.parseInt(timePartList.get(0)) - 1); + cal.set(Calendar.AM_PM, Calendar.AM); + } else { + cal.set(Calendar.HOUR, Integer.parseInt(timePartList.get(0)) - 12); + cal.set(Calendar.AM_PM, Calendar.PM); + } + cal.set(Calendar.MINUTE, Integer.parseInt(timePartList.get(1))); + if (StringUtils.isNotBlank(timePartList.get(2))) { + String[] secondsAndMilli = timePartList.get(2).split("."); + if (secondsAndMilli.length > 1) + cal.set(Calendar.SECOND, Integer.parseInt(secondsAndMilli[1])); + return cal.getTimeInMillis(); + } + return cal.getTimeInMillis(); + } else { + return null; + } + } + + private static Map<Integer, Field> getOrderFormFieldMap(FormDetail formDetail) { + Map<Integer, Field> fieldOrderMap = new LinkedHashMap<>(); + for (Field eachField : formDetail.getFields()) { + if (!ExcelConstants.RATING_LIST_STRING.contains(eachField.getFieldType().toLowerCase())) { + fieldOrderMap.put(eachField.getOrder(), eachField); + } + } + return fieldOrderMap; + } + + // Get Form Field Map + // Key And Value both are field name + private static Map<String, Field> getFormFieldMap(FormDetail formDetail) { + Map<String, Field> fieldOrderMap = new LinkedHashMap<>(); + for (Field eachField : formDetail.getFields()) { + if (!ExcelConstants.RATING_LIST_STRING.contains(eachField.getFieldType().toLowerCase())) { + fieldOrderMap.put(eachField.getName(), eachField); + } + } + return fieldOrderMap; + } + + private static List<Row> filterActiveRowsFromWorksheet(XSSFSheet activeWorkSheet) { + List<Row> activeRowList = new ArrayList<>(); + Iterator<Row> itr = activeWorkSheet.rowIterator(); + while (itr.hasNext()) { + Row row = itr.next(); + if (row.getCell(1) != null) { + activeRowList.add(row); + } + } + return activeRowList; + } + + @SuppressWarnings("unused") + private static List<Row> filterActiveRowsFromWorksheet(HSSFSheet activeWorkSheet) { + List<Row> activeRowList = new ArrayList<>(); + Iterator<Row> itr = activeWorkSheet.rowIterator(); + while (itr.hasNext()) { + Row row = itr.next(); + if (row.getCell(1) != null) { + activeRowList.add(row); + } + } + return activeRowList; + } + + @SuppressWarnings("unused") + private static Map<String, Integer> constructHeaderIndexMap(XSSFSheet worksheet) { + Map<String, Integer> headerIndexMap = new HashMap<>(); + XSSFRow currentRow = null; + for (int i = 0; i < currentRow.getPhysicalNumberOfCells(); i++) { + try { + if (currentRow.getCell(i) != null && !currentRow.getCell(i).getStringCellValue().isEmpty()) { + headerIndexMap.put(currentRow.getCell(i).getStringCellValue(), i); + } + } catch (NullPointerException nullEx) { + LOGGER.error("Invalid cell references found : {}", nullEx.getMessage()); + } catch (Exception ex) { + LOGGER.error("Unknown exception found : {} ", ex.getMessage()); + } + } + return headerIndexMap; + } + + public static int randInt(int min, int max) { + Random rand; + rand = new Random(); + int randomNum; + randomNum = rand.nextInt((max - min) + 1) + min; + return randomNum; + } +} diff --git a/src/main/java/com/tarento/formservice/utils/ExecutorManager.java b/src/main/java/com/tarento/formservice/utils/ExecutorManager.java new file mode 100644 index 0000000000000000000000000000000000000000..d0cbc715eaf7cba67d11139e3763cfbdae20e0e9 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/ExecutorManager.java @@ -0,0 +1,32 @@ +package com.tarento.formservice.utils; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; + +import lombok.NoArgsConstructor; + +/** + * This class will manage execute service thread. + * + * @author Manzarul.Haque + * + */ +@NoArgsConstructor +public class ExecutorManager { + /* + * service ScheduledExecutorService object + */ + private static ScheduledExecutorService service = null; + static { + service = Executors.newScheduledThreadPool(Constants.MAX_EXECUTOR_THREAD); + } + + /** + * This method will send executor service object. + * + * @return + */ + public static ScheduledExecutorService getExecutorService() { + return service; + } +} diff --git a/src/main/java/com/tarento/formservice/utils/FileConfigApplicationRunner.java b/src/main/java/com/tarento/formservice/utils/FileConfigApplicationRunner.java new file mode 100644 index 0000000000000000000000000000000000000000..3418d90cbd10d94d2d444d7ed6ae8566891bad88 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/FileConfigApplicationRunner.java @@ -0,0 +1,121 @@ +/** + * + */ +package com.tarento.formservice.utils; + +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.core.io.ResourceLoader; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.jayway.jsonpath.JsonPath; + +@Component +public class FileConfigApplicationRunner implements ApplicationRunner { + + public static final Logger log = LoggerFactory.getLogger(FileConfigApplicationRunner.class); + + @Autowired + public ResourceLoader resourceLoader; + + @Value("${file.config.path}") + public String fileDirectory; + + @Value("${file.config.path}") + public String masterConfigUrl; + + private static Map<String, String> fileServiceMap = new HashMap<>(); + + private static Map<String, Map<String, Object>> masterConfigMap = new HashMap<>(); + + @Override + public void run(ApplicationArguments args) throws Exception { + try { + // log.info("Reading data files from: {} ", fileDirectory); + // readDirectory(fileDirectory); + } catch (Exception e) { + log.error("Exception while loading yaml files: ", e); + } + } + + public void readDirectory(String path) { + File folder = new File(path); + File[] listOfFiles = folder.listFiles(); + for (int i = 0; i < listOfFiles.length; i++) { + if (listOfFiles[i].isFile()) { + // log.info("File {}", listOfFiles[i].getName()); + File file = listOfFiles[i]; + String name = file.getName(); + String[] fileName = name.split("[.]"); + if (fileName[fileName.length - 1].equals("yml") || fileName[fileName.length - 1].equals("yaml")) { + // log.info("Reading yaml file....:- {}", name); + try { + buildFileServiceMap(file.getName()); + } catch (Exception e) { + log.error("Exception while fetching service map for: "); + } + } else if (fileName[fileName.length - 1].equals("json")) { + try { + buildFileServiceMap(file.getName()); + } catch (Exception e) { + log.error("Exception while fetching service map for: "); + } + } else { + // log.info("file is not of a valid type please change and retry"); + // log.info("Note: file can either be .yml/.yaml or .json"); + } + + } else if (listOfFiles[i].isDirectory()) { + // log.info("Directory {}", listOfFiles[i].getName()); + readDirectory(listOfFiles[i].getAbsolutePath()); + } + } + // log.info("fileServiceMap: {}", fileServiceMap); + } + + private void buildFileServiceMap(String fileName) { + String[] serviceNames = fileName.split("-"); + fileServiceMap.put(serviceNames[0], fileName); + } + + public static Map<String, String> getFileServiceMap() { + return fileServiceMap; + } + + public void prepareMasterConfigMap(Map<String, Object> map) { + ObjectMapper objectMapper = new ObjectMapper(); + + Set<String> moduleKeys = map.keySet(); + Iterator<String> moduleKeyIterator = moduleKeys.iterator(); + String masterName = null; + Map<String, Object> masterDataJsonArray = null; + while (moduleKeyIterator.hasNext()) { + masterName = moduleKeyIterator.next(); + + try { + masterDataJsonArray = JsonPath.read(objectMapper.writeValueAsString(map.get(masterName)), "$"); + } catch (JsonProcessingException e) { + // log.info("Encounter an exception while preparing master config map: {}", + // e.getMessage()); + } + masterConfigMap.put(masterName, masterDataJsonArray); + } + // log.info("MasterConfigMap: {}", masterConfigMap); + } + + public static Map<String, Map<String, Object>> getMasterConfigMap() { + return masterConfigMap; + } +} diff --git a/src/main/java/com/tarento/formservice/utils/GMailAuthenticator.java b/src/main/java/com/tarento/formservice/utils/GMailAuthenticator.java new file mode 100644 index 0000000000000000000000000000000000000000..d0dfcbe0f5596d9f17622e9d12c6e3e6ef08e6f4 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/GMailAuthenticator.java @@ -0,0 +1,37 @@ +/** + * + */ +package com.tarento.formservice.utils; + + +import javax.mail.Authenticator; +import javax.mail.PasswordAuthentication; + +/** + * @author Manzarul.Haque + * + */ +public class GMailAuthenticator extends Authenticator { + String user; + String pw; + + /** + * this method is used to authenticate gmail user name and password. + * + * @param username + * @param password + */ + public GMailAuthenticator(String username, String password) { + super(); + this.user = username; + this.pw = password; + } + + /** + * + */ + @Override + public PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(this.user, this.pw); + } +} diff --git a/src/main/java/com/tarento/formservice/utils/InteractionRequestFeedbackJob.java b/src/main/java/com/tarento/formservice/utils/InteractionRequestFeedbackJob.java new file mode 100644 index 0000000000000000000000000000000000000000..4bd241d270633902904cf962dc81decdf570bcd4 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/InteractionRequestFeedbackJob.java @@ -0,0 +1,27 @@ +package com.tarento.formservice.utils; + +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.tarento.formservice.service.FormsService; +import com.tarento.formservice.service.impl.FormsServiceImpl; + +public class InteractionRequestFeedbackJob implements Job { + public static final Logger LOGGER = LoggerFactory.getLogger(FormsServiceImpl.class); + @Autowired + private FormsService formsService; + + @Override + public void execute(JobExecutionContext arg0) throws JobExecutionException { + try { + formsService.getAllInteractionsForAutomatedRequestFeedback(); + } catch (Exception e) { + LOGGER.error(String.format("Encountered an error while running the job: %s", e.getMessage())); + } + } + +} diff --git a/src/main/java/com/tarento/formservice/utils/JSONObjectUtil.java b/src/main/java/com/tarento/formservice/utils/JSONObjectUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..37714cc2d216eccd15cf870f760c854642828b2f --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/JSONObjectUtil.java @@ -0,0 +1,41 @@ +package com.tarento.formservice.utils; +import org.springframework.beans.factory.annotation.Autowired; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; + +public class JSONObjectUtil { + @Autowired + public ObjectMapper mapper; + @Autowired + public Gson gson; + + + /** + * @return + */ + public static String getJsonString(ObjectMapper objectMapper,Object object) throws JsonProcessingException { + if(objectMapper != null){ + return objectMapper.writeValueAsString(object); + } + return null; + } + + public ObjectMapper getMapper() { + return mapper; + } + + public void setObjectMapper(ObjectMapper objectMapper){ + mapper=objectMapper; + } + + public Gson getGson() { + return gson; + } + + public void setGson(Gson gsonn) + { + gson = gsonn; + } +} diff --git a/src/main/java/com/tarento/formservice/utils/JsonKey.java b/src/main/java/com/tarento/formservice/utils/JsonKey.java new file mode 100644 index 0000000000000000000000000000000000000000..03e6f799f9b5a02ea1c1bef95bf4cc3ca3f3c3d9 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/JsonKey.java @@ -0,0 +1,115 @@ +/** + * + */ +package com.tarento.formservice.utils; + +import lombok.NoArgsConstructor; + +/** + * @author Abhishek + * + */ +@NoArgsConstructor +public class JsonKey { + /* + * USER_NAME contains userName as key + */ + public static final String USER_ID = "userId"; + /* + * USER_NAME contains userName as key + */ + public static final String USER_NAME = "username"; + /* + * PASSWORD contains password + */ + public static final String PSWRD = "password"; + /* + * OLD_PASSWORD + */ + public static final String OLD_PSWRD = "oldPass"; + /* + * NEW_PASSWORD + */ + public static final String NEW_PSWRD = "newPass"; + /* + * DEVICE_TYPE user device type + */ + public static final String DEVICE_TYPE = "deviceType"; + /* + * DEVICE_ID user device id. + */ + public static final String DEVICE_ID = "deviceId"; + /* + * TIMEZONE + */ + public static final String TIMEZONE = "timeZone"; + /* + * SESSION + */ + public static final String SESSION = "sessionId"; + /* + * FIRST_NAME + */ + public static final String FIRST_NAME = "firstName"; + /* + * LAST_NAME + */ + public static final String LAST_NAME = "lastName"; + + public static final String URL = "url"; + + public static final String USERNAME = "username"; + + public static final String LINK = "link"; + + public static final String ROLE_IDS = "roleIds"; + + public static final String ROLENAME = "roleName"; + /* + * EMAIL + */ + public static final String EMAIL = "email"; + public static final String STATUS_CODE = "statusCode"; + public static final String STATUS = "statusInfo"; + public static final String STATUS_MESSAGE = "statusMessage"; + public static final String ERROR_MESSAGE = "errorMessage"; + /** + * RESPONSE. + */ + public static final String RESPONSE = "response"; + public static final String RESPONSE_DATA = "responseData"; + + /** + * IS_ACTIVE. + */ + public static final String IS_ACTIVE = "isActive"; + /** + * IS_DELETED. + */ + public static final String IS_DELETED = "isDeleted"; + + public static final String TIME = "time"; + + public static final String SUBSCRIPTION_NAME = "subscriptionName"; + + public static final String ASSET_TYPE = "assetType"; + public static final String ASSET_NAME = "assetName"; + public static final String FROM_USER = "fromUser"; + public static final String MAIL_SUBJECT = "mail_subject"; + public static final String MAIL_BODY = "mail_body"; + public static final String LOGO_URL = "logo_url"; + public static final String TYPE = "type"; + public static final String TICKET_ID = "ticketId"; + public static final String SEVERITY = "severity"; + public static final String CREATED_BY = "createdBy"; + public static final String OWNER = "owner"; + public static final String SUMMARY = "summary"; + public static final String ORGNAME = "CompName"; + public static final String HELPDESKNAME = "HelpdeskName"; + public static final String HELPDESK_NAME = "helpdeskName"; + public static final String OLDSTATUS = "oldStatus"; + public static final String UPDATE = "update"; + public static final String NEWSTATUS = "newStatus"; + public static final String ID = "id"; + public static final String HELPDESKID = "helpdeskId"; +} diff --git a/src/main/java/com/tarento/formservice/utils/PathRoutes.java b/src/main/java/com/tarento/formservice/utils/PathRoutes.java new file mode 100644 index 0000000000000000000000000000000000000000..8cccc4a6d1b437737678de577cbd077cd0c065bd --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/PathRoutes.java @@ -0,0 +1,52 @@ +package com.tarento.formservice.utils; + +public interface PathRoutes { + + public interface FormServiceApi { + final String FORMS_ROOT = "/forms"; + + final String GET_ALL_FORMS = "/getAllForms"; + final String GET_FORM_BY_ID = "/getFormById"; + + final String CREATE_FORM = "/createForm"; + final String UPLOAD_RECORDS = "/uploadRecordData"; + + final String UPLOAD_USER_COURSE_DATA = "/uploadUserCourseData"; + + final String UPLOAD_ASSESSMENT_DATA = "/uploadAssessmentData"; + + final String UPLOAD_DATA = "/uploadData"; + final String SAVE_FORM_SUBMIT = "/saveFormSubmit"; + final String VERIFY_FEEDBACK = "/verifyFeedback"; + final String VOTE_FEEDBACK = "/voteFeedback"; + final String CHALLENGE_FEEDBACK = "/challengeFeedback"; + final String SAVE_FORM_SUBMIT_BULK = "/saveFormSubmitBulk"; + final String REQUEST_FEEDBACK = "/requestFeedback"; + + final String SAVE_USER_CHART = "/saveUserChart"; + final String GET_CHART_BY_ID = "/getChartById"; + final String GET_ALL_CHARTS = "/getAllCharts"; + final String DELETE_CHART_BY_ID = "/deleteChartById"; + + final String SAVE_USER_DASHBOARD = "/saveUserDashboard"; + final String GET_DASHBOARD_BY_ID = "/getDashboardById"; + final String GET_ALL_DASHBOARDS = "/getAllDashboards"; + final String DELETE_DASHBOARD_BY_ID = "/deleteDashboardById"; + + final String GET_FEEDBACKS = "/getFeedbacks"; + final String GET_FEEDBACK_BY_ID = "/getFeedbackById"; + final String GET_ALL_FEEDBACKS = "/getAllFeedbacks"; + final String GET_OVERVIEW_COUNT = "/getOverviewCount"; + final String ADD_INTERACTION = "/addInteraction"; + final String GET_ALL_INTERACTIONS = "/getAllInteractions"; + final String GET_AGENT_AGGREGATIONS = "/getAgentAggregations"; + final String REPLY_FEEDBACK = "/replyFeedback"; + + } + + public interface JsonFormServiceApi { + final String JSON_FORM_ROOT = "/admin"; + final String FORMS = "/forms"; + final String UPLOAD_JSON_DATA = "/uploadFormData"; + } +} diff --git a/src/main/java/com/tarento/formservice/utils/ResponseCode.java b/src/main/java/com/tarento/formservice/utils/ResponseCode.java new file mode 100644 index 0000000000000000000000000000000000000000..1a028cb64725b72f4e6025f81e7504a17905a27c --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/ResponseCode.java @@ -0,0 +1,86 @@ +package com.tarento.formservice.utils; + + +/** + * + * @author Abhishek + * + */ +public enum ResponseCode { + UnAuthorised(Constants.ResponseCodes.UNAUTHORIZED_ID, Constants.ResponseCodes.UNAUTHORIZED), Success( + Constants.ResponseCodes.SUCCESS_ID, Constants.ResponseCodes.SUCCESS),FAILURE( + Constants.ResponseCodes.FAILURE_ID, Constants.ResponseCodes.PROCESS_FAIL); + /** + * error code contains int value + */ + private int errorCode; + /** + * errorMessage contains proper error message. + */ + private String errorMessage; + + + + /** + * @param errorCode + * @param errorMessage + */ + private ResponseCode(int errorCode, String errorMessage) { + this.errorCode = errorCode; + this.errorMessage = errorMessage; + } + + /** + * + * @param errorCode + * @return + */ + public String getMessage(int errorCode) { + return ""; + } + + /** + * @return + */ + public int getErrorCode() { + return errorCode; + } + + /** + * @param errorCode + */ + public void setErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + /** + * @return + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * @param errorMessage + */ + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * This method will provide status message based on code + * + * @param code + * @return String + */ + public static String getResponseMessage(int code) { + String value = ""; + ResponseCode responseCodes[] = ResponseCode.values(); + for (ResponseCode actionState : responseCodes) { + if (actionState.getErrorCode() == code) { + value = actionState.getErrorMessage(); + } + } + return value; + } +} diff --git a/src/main/java/com/tarento/formservice/utils/ResponseGenerator.java b/src/main/java/com/tarento/formservice/utils/ResponseGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..a48a24f7afadb6b1777b1430bceda048410fbfc5 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/ResponseGenerator.java @@ -0,0 +1,78 @@ +package com.tarento.formservice.utils; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +public class ResponseGenerator { + + private static ObjectMapper objectMapper = new ObjectMapper(); + + public static String failureResponse() throws JsonProcessingException { + ObjectNode response = objectMapper.createObjectNode(); + response.put(JsonKey.STATUS_CODE, ResponseCode.FAILURE.getErrorCode()); + response.put(JsonKey.STATUS_MESSAGE, ResponseCode.FAILURE.getErrorMessage()); + response.put(JsonKey.ERROR_MESSAGE, ResponseCode.FAILURE.getErrorMessage()); + return JSONObjectUtil.getJsonString(objectMapper, response); + } + + public static String failureResponse(String message) throws JsonProcessingException { + ObjectNode actualResponse = objectMapper.createObjectNode(); + + ObjectNode response = objectMapper.createObjectNode(); + response.put(JsonKey.STATUS_CODE, ResponseCode.FAILURE.getErrorCode()); + response.put(JsonKey.STATUS_MESSAGE, ResponseCode.FAILURE.getErrorMessage()); + response.put(JsonKey.ERROR_MESSAGE, message); + actualResponse.putPOJO(JsonKey.STATUS, response); + + return JSONObjectUtil.getJsonString(objectMapper, actualResponse); + } + + public static String failureResponse(String errorCode, String message) throws JsonProcessingException { + ObjectNode actualResponse = objectMapper.createObjectNode(); + + ObjectNode response = objectMapper.createObjectNode(); + response.put(errorCode, message); + response.put(JsonKey.STATUS_MESSAGE, message); + response.put(JsonKey.ERROR_MESSAGE, message); + actualResponse.putPOJO(JsonKey.STATUS, response); + + return JSONObjectUtil.getJsonString(objectMapper, actualResponse); + } + + public static String successResponse(Object obj) throws JsonProcessingException { + ObjectNode actualResponse = objectMapper.createObjectNode(); + + ObjectNode response = objectMapper.createObjectNode(); + response.put(JsonKey.STATUS_CODE, ResponseCode.Success.getErrorCode()); + response.put(JsonKey.STATUS_MESSAGE, ResponseCode.Success.getErrorMessage()); + response.put(JsonKey.ERROR_MESSAGE, ""); + actualResponse.putPOJO(JsonKey.STATUS, response); + if (obj != null) { + actualResponse.putPOJO(JsonKey.RESPONSE_DATA, obj); + } + + return JSONObjectUtil.getJsonString(objectMapper, actualResponse); + } + + /** + * this method will crate success response and send to controller. + * + * @return ObjectNode object. + */ + public static String successResponse(String message) throws JsonProcessingException { + ObjectNode actualResponse = objectMapper.createObjectNode(); + ObjectNode response = objectMapper.createObjectNode(); + response.put(JsonKey.STATUS_CODE, ResponseCode.Success.getErrorCode()); + response.put(JsonKey.STATUS_MESSAGE, ResponseCode.Success.getErrorMessage()); + // response.put(JsonKey.SUCCESS_MESSAGE, message); + actualResponse.putPOJO(JsonKey.STATUS, response); + response.put(JsonKey.ERROR_MESSAGE, ""); + actualResponse.putPOJO(JsonKey.STATUS, response); + if (message != null) { + actualResponse.putPOJO(JsonKey.RESPONSE_DATA, message); + } + + return JSONObjectUtil.getJsonString(objectMapper, actualResponse); + } +} diff --git a/src/main/java/com/tarento/formservice/utils/SendMail.java b/src/main/java/com/tarento/formservice/utils/SendMail.java new file mode 100644 index 0000000000000000000000000000000000000000..667478c688f2ecad78c0170e4f770b4881ef37c7 --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/SendMail.java @@ -0,0 +1,212 @@ +package com.tarento.formservice.utils; + +import java.io.StringWriter; +import java.util.Map; +import java.util.Properties; + +import javax.activation.DataHandler; +import javax.activation.DataSource; +import javax.activation.FileDataSource; +import javax.mail.BodyPart; +import javax.mail.Message; +import javax.mail.Multipart; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; + +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.runtime.RuntimeConstants; +import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Async; + +import lombok.NoArgsConstructor; + +/** + * this api is used to sending mail. + * + * @author Manzarul.Haque + * + */ +@NoArgsConstructor +public class SendMail { + private static final String ENCOUNTERED_AN_EXCEPTION = "Encountered an Exception : %s"; + private static final String TEXT_HTML = "text/html"; + private static final String EMAILS = "emails/"; + public static final Logger LOGGER = LoggerFactory.getLogger(SendMail.class); + private static final String CLASSNAME = SendMail.class.getName(); + private static Properties props = null; + static { + props = System.getProperties(); + props.put("mail.smtp.host", Constants.SMTP.HOST); + props.put("mail.smtp.socketFactory.port", Constants.SMTP.PORT); + props.put("mail.smtp.auth", Constants.SMTP.SSL); + props.put("mail.smtp.port", Constants.SMTP.PORT); + } + + /** + * this method is used to send email. + * + * @param receipent + * email to whom we send mail + * @param context + * VelocityContext + * @param templateName + * String + * @param subject + * subject + */ + @Async + public static void sendMail(String[] receipent, String subject, VelocityContext context, String templateName) { + try { + Session session = Session.getInstance(props, new GMailAuthenticator(Constants.USER, Constants.PSWRD)); + MimeMessage message = new MimeMessage(session); + message.setFrom(new InternetAddress(Constants.FROM, Constants.ALIAS)); + int size = receipent.length; + int i = 0; + while (size > 0) { + message.addRecipient(Message.RecipientType.TO, new InternetAddress(receipent[i])); + i++; + size--; + } + message.setSubject(subject); + VelocityEngine engine = new VelocityEngine(); + engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); + engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); + engine.init(); + Template template = engine.getTemplate(templateName); + StringWriter writer = new StringWriter(); + template.merge(context, writer); + message.setContent(writer.toString(), TEXT_HTML); + Transport transport = session.getTransport("smtp"); + transport.connect(Constants.HOST, Constants.USER, Constants.PSWRD); + transport.sendMessage(message, message.getAllRecipients()); + transport.close(); + } catch (Exception e) { + LOGGER.error(e.toString(), CLASSNAME); + } + } + + /** + * this method is used to send email along with CC Recipients list. + * + * @param receipent + * email to whom we send mail + * @param context + * VelocityContext + * @param templateName + * String + * @param subject + * subject + * @param ccList + * String + */ + @Async + public static void sendMail(String[] receipent, String subject, VelocityContext context, String templateName, + String[] ccList) { + try { + Session session = Session.getInstance(props, new GMailAuthenticator(Constants.USER, Constants.PSWRD)); + MimeMessage message = new MimeMessage(session); + message.setFrom(new InternetAddress(Constants.FROM, Constants.ALIAS)); + int size = receipent.length; + int i = 0; + while (size > 0) { + message.addRecipient(Message.RecipientType.TO, new InternetAddress(receipent[i])); + i++; + size--; + } + size = ccList.length; + i = 0; + while (size > 0) { + message.addRecipient(Message.RecipientType.CC, new InternetAddress(ccList[i])); + i++; + size--; + } + message.setSubject(subject); + VelocityEngine engine = new VelocityEngine(); + engine.init(); + String templatePath = EMAILS; + Template template = engine.getTemplate(templateName); + StringWriter writer = new StringWriter(); + template.merge(context, writer); + message.setContent(writer.toString(), TEXT_HTML); + Transport transport = session.getTransport("smtp"); + transport.connect(Constants.HOST, Constants.USER, Constants.PSWRD); + transport.sendMessage(message, message.getAllRecipients()); + transport.close(); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + } + + /** + * this method is used to send email as an attachment. + * + * @param receipent + * email to whom we send mail + * @param mail + * mail body. + * @param subject + * subject + * @param filePath + * String + */ + @Async + public static void sendAttachment(String[] receipent, String mail, String subject, String filePath) { + try { + Session session = Session.getInstance(props, + new GMailAuthenticator(Constants.SMTP.USER, Constants.SMTP.PSWRD)); + MimeMessage message = new MimeMessage(session); + message.setFrom(new InternetAddress(Constants.SMTP.USER, Constants.SMTP.ALIAS)); + int size = receipent.length; + int i = 0; + while (size > 0) { + message.addRecipient(Message.RecipientType.TO, new InternetAddress(receipent[i])); + i++; + size--; + } + message.setSubject(subject); + BodyPart messageBodyPart = new MimeBodyPart(); + messageBodyPart.setContent(mail, TEXT_HTML); + + Multipart multipart = new MimeMultipart(); + multipart.addBodyPart(messageBodyPart); + DataSource source = new FileDataSource(filePath); + messageBodyPart = new MimeBodyPart(); + messageBodyPart.setDataHandler(new DataHandler(source)); + messageBodyPart.setFileName(filePath); + multipart.addBodyPart(messageBodyPart); + message.setSubject(subject); + message.setContent(multipart); + Transport transport = session.getTransport("smtp"); + transport.connect(Constants.SMTP.HOST, Constants.SMTP.USER, Constants.SMTP.PSWRD); + transport.sendMessage(message, message.getAllRecipients()); + transport.close(); + } catch (Exception e) { + LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION, e.getMessage())); + } + } + + public static void sendMail(final Map<String, String> keyValue, final String[] emails, final String subject, + final String vmFileName) { + ExecutorManager.getExecutorService().execute(new Runnable() { + @Override + public void run() { + VelocityContext context = new VelocityContext(); + for (Map.Entry<String, String> entry : keyValue.entrySet()) { + context.put(entry.getKey(), entry.getValue()); + } + + context.put(JsonKey.LOGO_URL, Constants.LOGO_URL); + sendMail(emails, subject, context, vmFileName); + } + + }); + } +} diff --git a/src/main/java/com/tarento/formservice/utils/Sql.java b/src/main/java/com/tarento/formservice/utils/Sql.java new file mode 100644 index 0000000000000000000000000000000000000000..dccefb1e9cb902064044aefdefa7aa606307770b --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/Sql.java @@ -0,0 +1,49 @@ +package com.tarento.formservice.utils; + +/** + * + * @author Darshan Nagesh + * + */ + +public interface Sql { + + public interface MetadataSql { + final static String GET_CATEGORIES = "SELECT id, code, name, description, store_code from category" ; + final static String GET_SUB_CATEGORIES = "SELECT id, code, name, description, category_code from subcategory"; + final static String GET_ITEMS = " SELECT id, code, name, description, price, subcategory_code from item "; + final static String GET_SERVICE_API="SELECT id, api_name, tag, xlabel, ylabel, description FROM service_apis" ; + final static String GET_CHART_FOR_SERVICE_API = " select sapis.api_name, chrt.service_api_id, chrt.id, chrt.name, chrt.code, chrt.type " + + " from service_apis sapis left join chart chrt on sapis.id = chrt.service_api_id " + + " where sapis.api_name IN " ; + + final static String GET_DASHBOARD_CONFIGURATIONS = "select " + + " dash.name as dashboardName, dash.code as dashboardCode, dash.is_active as isActive, dash.description as dashboardDescription, dash.id as id, dash.placement as placement, " + + " viz.id as visualizationId, viz.name as visualizationName, viz.is_active as visualizationIsActive, viz.description as visualizationDescription, " + + " chrt.id as chartId, chrt.name as chartName, chrt.code as chartCode, chrt.description as chartDescription, chrt.type as chartType, chrt.filter as chartFilter, " + + " sapis.api_name as serviceApiName, sapis.tag as tag, sapis.xlabel as xlabel, sapis.ylabel as ylabel, sapis.description as serviceApiDescription," + + " sapis.api_method as serviceApiMethod, header.id as headerId, header.label as headerLabel, header.data as headerData, header.field as headerField " + + " from dashboard dash left join dashboard_visualization dashviz on dash.id = dashviz.dashboard_id " + + " left join visualization viz on dashviz.visualization_id = viz.id " + + " left join visualization_chart vizchart on viz.id = vizchart.visualization_id " + + " left join chart chrt on vizchart.chart_id = chrt.id " + + " left join chart_header chrtheader on chrt.id = chrtheader.chart_id " + + " left join header_information header on chrtheader.header_id = header.id " + + " left join service_apis sapis on chrt.service_api_id = sapis.id where dash.is_active = true"; + final static String PLACEMENT_FILTER_FOR_HOME = " AND dash.placement = 'HOME'"; + final static String PLACEMENT_FILTER_FOR_DASHBOARD = " AND dash.placement = 'DASHBOARD'"; + final static String GET_ALL_VISUALIZATION = "SELECT description, name, id FROM visualization "; + final static String ADD_NEW_DASHBOARD = "INSERT into dashboard (name, code, description) values (?, ?, ?)"; + final static String MAP_DASHBOARD_VISUALIZATION = "INSERT into dashboard_visualization values (?,?) "; + + final static String RATING_CONFIGURATION_GET = " select config.id as id, config.value as value, config.name as name, config.subtitle as subtitle, config.end_message as endMessage, config.color_code as colorCode, reasons.id as reasonId, " + + " reasons.reason as reason from store_rating_config config left join store_rating_config_reasons confreasons ON config.id = confreasons.rating_id " + + " left join store_rating_reasons reasons ON confreasons.reason_id = reasons.id WHERE config.org_id = ? " ; + final static String RATING_CONFIG_VERSION = " SELECT version from store_rating_config_version "; + final static String TENANT_RATING_CONFIG = " SELECT tenant_name, entry_message, time_out, org_text, org_logo_url, org_color_code, theme_color, org_id from tenant_rating_config where org_id = ? "; + final static String VERIFY_ORG_PIN = " select id from organization where org_code = ? and org_pin = ? and is_active IS TRUE " ; + final static String GET_AGE_GROUPS_FOR_ORG = "select id, age_group from tenant_rating_agegroups ag left join tenant_rating_config_agegroups configag " + + " ON ag.id = configag.age_group_id where configag.org_id = ? "; + } + +} diff --git a/src/main/java/com/tarento/formservice/utils/package-info.java b/src/main/java/com/tarento/formservice/utils/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..ef96688bc6da974ff7e02a6fe5b53cb7521499ca --- /dev/null +++ b/src/main/java/com/tarento/formservice/utils/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author Satish Kumar + * + */ +package com.tarento.formservice.utils; \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..bfdb89347c263285e1b7b852a7aa317267ee71a7 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,52 @@ +server.port=8099 + +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://localhost:3306/retail_user +spring.datasource.username=retail_user +spring.datasource.password=ReTail123T + + +#----------------------------- ELASTIC SEARCH CONFIGURATIONS ------------------------------# +services.esindexer.host=elastic.pulz.app +services.esindexer.host.name=elastic.pulz.app +services.esindexer.host.port=443 +services.esindexer.username=elastic +services.esindexer.password=PuAz@itAqwsaR34bYu + +es.fs.forms.index.name=fs-forms +es.fs.forms.document.type=forms +es.fs.formsdata.index.name=fs-forms-data +es.fs.formsdata.document.type=forms-data +es.fs.interactions.index.name=fs-interactions + + +es.forms.fail.records.index.name=form-failure-records +es.forms.fail.records.index.type=formfailurerecords + +file.config.path=/ +file.config.name=FormConfig.yml + +#services.esindexer.host=10.2.1.30 +#services.esindexer.host.name=http://10.2.1.30/ +#services.esindexer.host.port=9200 +#services.esindexer.username=elastic +#services.esindexer.password=Elastic123 +#es.fs.forms.index.name=fs-forms +#es.fs.forms.document.type=forms +#es.fs.formsdata.index.name=fs-forms-data +#es.fs.formsdata.document.type=forms-data + +# KAFKA SERVER CONFIGURATIONS +spring.kafka.bootstrap.servers=localhost:9092 + +spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer +spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer + +# KAFKA PRODUCER CONFIGURATIONS +kafka.producer.config.retries_config=0 +kafka.producer.config.batch_size_config=100000 +kafka.producer.config.linger_ms_config=100 +kafka.producer.config.buffer_memory_config=66554432 + +spring.http.multipart.max-file-size=100MB +spring.http.multipart.max-request-size=100MB diff --git a/src/main/resources/email_template.vm b/src/main/resources/email_template.vm new file mode 100644 index 0000000000000000000000000000000000000000..f45f6dc0f3618966bda49db3157c39fe7b64feff --- /dev/null +++ b/src/main/resources/email_template.vm @@ -0,0 +1,424 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title>Aurora Helpdesk</title> + + <style type="text/css"> + /* Take care of image borders and formatting, client hacks */ + img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic;} + a img { border: none; } + table { border-collapse: collapse !important;} + #outlook a { padding:0; } + .ReadMsgBody { width: 100%; } + .ExternalClass { width: 100%; } + .backgroundTable { margin: 0 auto; padding: 0; width: 100% !important; } + table td { border-collapse: collapse; } + .ExternalClass * { line-height: 115%; } + .container-for-gmail-android { min-width: 600px; } + + + /* General styling */ + * { + font-family: Helvetica, Arial, sans-serif; + } + + body { + -webkit-font-smoothing: antialiased; + -webkit-text-size-adjust: none; + width: 100% !important; + margin: 0 !important; + height: 100%; + color: #676767; + } + + td { + font-family: Helvetica, Arial, sans-serif; + font-size: 14px; + color: #777777; + text-align: center; + line-height: 21px; + } + + a { + color: #ff6f6f; + font-weight: bold; + text-decoration: none !important; + } + + .pull-left { + text-align: left; + } + + .pull-right { + text-align: right; + } + + .header-lg, + .header-md, + .header-sm { + font-size: 32px; + font-weight: 700; + line-height: normal; + padding: 35px 0 0; + color: #4d4d4d; + } + + .header-md { + font-size: 24px; + } + + .header-sm { + padding: 5px 0; + font-size: 18px; + line-height: 1.3; + } + + .content-padding { + padding: 20px 0 30px; + } + + .mobile-header-padding-right { + width: 290px; + text-align: right; + padding-left: 10px; + } + + .mobile-header-padding-left { + width: 290px; + text-align: left; + padding-left: 10px; + } + + .free-text { + width: 100% !important; + padding: 10px 60px 0px; + } + + .block-rounded { + border-radius: 5px; + border: 1px solid #e5e5e5; + vertical-align: top; + } + + .button { + padding: 30px 0 0; + } + + .info-block { + padding: 0 20px; + width: 260px; + } + + .mini-block-container { + padding: 30px 50px; + width: 500px; + } + + .mini-block { + background-color: #ffffff; + width: 498px; + border: 1px solid #cccccc; + border-radius: 5px; + padding: 45px 75px; + } + + .block-rounded { + width: 260px; + } + + .info-img { + width: 258px; + border-radius: 5px 5px 0 0; + } + + .force-width-img { + width: 480px; + height: 1px !important; + } + + .force-width-full { + width: 600px; + height: 1px !important; + } + + .user-img img { + width: 130px; + border-radius: 5px; + border: 1px solid #cccccc; + } + + .user-img { + text-align: center; + border-radius: 100px; + color: #ff6f6f; + font-weight: 700; + } + + .user-msg { + padding-top: 10px; + font-size: 14px; + text-align: center; + font-style: italic; + } + + .mini-img { + padding: 5px; + width: 140px; + } + + .mini-img img { + border-radius: 5px; + width: 140px; + } + + .force-width-gmail { + min-width:600px; + height: 0px !important; + line-height: 1px !important; + font-size: 1px !important; + } + + .mini-imgs { + padding: 10px 0 20px; + } + + div.center { + display: table; + } + ul { + text-align: left; + list-style-type:none; + } + </style> + + <style type="text/css" media="screen"> + @import url(http://fonts.googleapis.com/css?family=Oxygen:400,700); + </style> + + <style type="text/css" media="screen"> + @media screen { + /* Thanks Outlook 2013! */ + * { + font-family: 'Oxygen', 'Helvetica Neue', 'Arial', 'sans-serif' !important; + } + } + </style> + + <style type="text/css" media="only screen and (max-width: 480px)"> + /* Mobile styles */ + @media only screen and (max-width: 480px) { + + div.center { + margin-right: 1rem; + } + + table[class*="container-for-gmail-android"] { + min-width: 290px !important; + width: 100% !important; + } + + table[class="w320"] { + width: 320px !important; + } + + img[class="force-width-gmail"] { + display: none !important; + width: 0 !important; + height: 0 !important; + } + + td[class*="mobile-header-padding-left"] { + width: 160px !important; + padding-left: 0 !important; + } + + td[class*="mobile-header-padding-right"] { + width: 160px !important; + padding-right: 0 !important; + } + + td[class="mobile-block"] { + display: block !important; + } + + td[class="mini-img"], + td[class="mini-img"] img{ + width: 150px !important; + } + + td[class="header-lg"] { + font-size: 24px !important; + padding-bottom: 5px !important; + } + + td[class="header-md"] { + font-size: 18px !important; + padding-bottom: 5px !important; + } + + td[class="content-padding"] { + padding: 5px 0 30px !important; + } + + td[class="button"] { + padding: 5px !important; + } + + td[class*="free-text"] { + padding: 10px 18px 30px !important; + } + + img[class="force-width-img"], + img[class="force-width-full"] { + display: none !important; + } + + td[class="info-block"] { + display: block !important; + width: 280px !important; + padding-bottom: 40px !important; + } + + td[class="info-img"], + img[class="info-img"] { + width: 278px !important; + } + + td[class="mini-block-container"] { + padding: 8px 20px !important; + width: 280px !important; + } + + td[class="mini-block"] { + padding: 20px !important; + } + + td[class="user-img"] { + display: block !important; + text-align: center !important; + width: 100% !important; + padding-bottom: 10px; + } + + td[class="user-msg"] { + display: block !important; + padding-bottom: 20px; + } + } + </style> +</head> + +<body bgcolor="#f7f7f7"> +<table align="center" cellpadding="0" cellspacing="0" class="container-for-gmail-android" width="100%"> + <tr> + <td align="left" valign="top" width="100%" style="background:repeat-x url(http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg) #ffffff;"> + <center> + <img src="http://s3.amazonaws.com/swu-filepicker/SBb2fQPrQ5ezxmqUTgCr_transparent.png" class="force-width-gmail"> + <table cellspacing="0" cellpadding="0" width="100%" bgcolor="#ffffff" background="http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg" style="background-color:transparent"> + <tr> + <td width="100%" height="80" valign="top" style="text-align: center; vertical-align:middle;"> + <!--[if gte mso 9]> + <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="mso-width-percent:1000;height:80px; v-text-anchor:middle;"> + <v:fill type="tile" src="http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg" color="#ffffff" /> + <v:textbox inset="0,0,0,0"> + <![endif]--> + <center> + <!-- #if ($logo_url) --> + <a href="https://www.propertyguru.com.sg/"><img width="50" height="60" src="https://pg-admin.tarento.com/img/PG-Group-Logo-1.svg" alt="logo"></a> + <!-- #end --> + </center> + <!--[if gte mso 9]> + </v:textbox> + </v:rect> + <![endif]--> + </td> + </tr> + </table> + </center> + </td> + </tr> + <tr> + <td align="center" valign="top" width="100%" style="background-color: #f7f7f7;" class="content-padding"> + <center> + <table cellspacing="0" cellpadding="0" width="600" class="w320"> + <tr> + <td class="header-lg"> + Your feedback matters ! + </td> + </tr> + <tr> + </tr> + <tr> + <td class="mini-block-container"> + <table cellspacing="0" cellpadding="0" width="100%" style="border-collapse:separate !important;"> + <tr> + <td class="mini-block"> + <table cellpadding="0" cellspacing="0" width="100%"> + <tr> + <td> + <table cellspacing="0" cellpadding="0" width="100%"> + + <tr> + <td class="header-lg"> + Hi, $firstName <br> + $mail_body + </td> + </tr> + </table> + </td> + </tr> + <tr> + <td class="button"> + <div><!--[if mso]> + <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://" style="height:45px;v-text-anchor:middle;width:155px;" arcsize="15%" strokecolor="#ffffff" fillcolor="#ff6f6f"> + <w:anchorlock/> + <center style="color:#ffffff;font-family:Helvetica, Arial, sans-serif;font-size:14px;font-weight:regular;">Sign Up</center> + </v:roundrect> + <![endif]--><a href="$password" + style="background-color:#ff6f6f;border-radius:5px;color:#ffffff;display:inline-block;font-family:'Cabin', Helvetica, Arial, sans-serif;font-size:14px;font-weight:regular;line-height:45px;text-align:center;text-decoration:none;width:155px;-webkit-text-size-adjust:none;mso-hide:all;">Rate & Review</a></div> + </td> + </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> + </table> + </center> + </td> + </tr> + <tr> + <td align="center" valign="top" width="100%" style="background-color: #ffffff; border-top: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5;"> + <center> + <table cellpadding="0" cellspacing="0" width="600" class="w320"> + <tr> + <td class="header-md" style="text-align:center;"> + Powered By Pulz + </td> + </tr> + <tr> + <td class="mini-imgs"> + + </td> + </tr> + </table> + </center> + </td> + </tr> + <tr> + <td align="center" valign="top" width="100%" style="background-color: #f7f7f7; height: 100px;"> + <center> + <table cellspacing="0" cellpadding="0" width="600" class="w320"> + <tr> + + </tr> + </table> + </center> + </td> + </tr> +</table> +</body> +</html> diff --git a/src/main/resources/schema/FormConfig.yml b/src/main/resources/schema/FormConfig.yml new file mode 100644 index 0000000000000000000000000000000000000000..e32debb36fe1c92df6b1c1b44f358e5cf10d29c1 --- /dev/null +++ b/src/main/resources/schema/FormConfig.yml @@ -0,0 +1,111 @@ +--- +formDetails: +- file_name: opportunity-detail + fileCode: opportunitydetail + form_id: '1594890810035' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-opportunity-detail' + esIndexDocType: 'opportunitydetail' + kafkaTopic: 'opportunity-detail' + kakfkaKey: 'opportunity-detail' + description: 'action fields has logs index name' + action: 'kronos-opportunity-detail-logs' +- file_name: group-banner + fileCode: groupbanner + form_id: '1594890436747' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-group-banner' + esIndexDocType: 'groupbanner' + kafkaTopic: 'group-banner' + kakfkaKey: 'group-banner' + description: 'action fields has logs index name' + action: 'kronos-group-banner-logs' +- file_name: revenue-market + fileCode: revenuemarket + form_id: '1594891472457' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-revenue-market' + esIndexDocType: 'revenuemarket' + kafkaTopic: 'revenue-market' + kakfkaKey: 'revenue-market' + description: 'action fields has logs index name' + action: 'kronos-revenue-market-logs' +- file_name: revenue-target-detail + fileCode: revenuetargetdetail + form_id: '1595919240937' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-revenue-target-detail' + esIndexDocType: 'revenuetargetdetail' + kafkaTopic: 'revenue-target-detail' + kakfkaKey: 'revenue-target-detail' + description: 'action fields has logs index name' + action: 'kronos-revenue-target-detail-logs' +- file_name: revenue-target-master + fileCode: revenuetargetmaster + form_id: '1594970154868' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-revenue-target-master' + esIndexDocType: 'revenuetargetmaster' + kafkaTopic: 'revenue-target-master' + kakfkaKey: 'revenue-target-master' + description: 'action fields has logs index name' + action: 'kronos-revenue-target-master-logs' +- file_name: sales-target-detail + fileCode: salestargetdetail + form_id: '1594891063130' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-sales-target-detail' + esIndexDocType: 'salestargetdetail' + kafkaTopic: 'sales-target-detail' + kakfkaKey: 'sales-target-detail' + description: 'action fields has logs index name' + action: 'kronos-sales-target-detail-logs' +- file_name: document-version-logs + fileCode: documentversionlogs + form_id: '' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'document-version-logs' + esIndexDocType: 'documentversionlogs' + kafkaTopic: 'document-version-logs' + kakfkaKey: 'document-version-logs' + description: 'This index is helpful for maintaing the logs of documents with older versions. It does not support any form.' +- file_name: employees-status + fileCode: employeesstatus + form_id: '1596075890491' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-employees-status' + esIndexDocType: 'employeesstatus' + kafkaTopic: 'kronos-employees-status' + kakfkaKey: 'kronos-employees-status' + description: 'action fields has logs index name' + action: 'kronos-employees-status-logs' +- file_name: Summary + fileCode: summary + form_id: '1621562959855' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-tarento-summary' + esIndexDocType: 'kronostarentosummary' + kafkaTopic: 'kronos-tarento-summary' + kakfkaKey: 'kronos-tarento-summary' + description: 'action fields has logs index name' + action: 'kronos-tarento-summary-logs' +- file_name: MIS-IBU + fileCode: MIS-IBU + form_id: '1621977715045' + file_format: '' + isFormIdPresentFileName: false + esIndexName: 'kronos-mis-ibu' + esIndexDocType: 'kronosmisibu' + kafkaTopic: 'kronos-mis-ibu' + kakfkaKey: 'kronos-mis-ibu' + description: 'action fields has logs index name' + action: 'kronos-mis-ibu-logs'