Commit 750843b0 authored by Josue's avatar Josue

Initial commit

parent 353037f9
Pipeline #354 failed with stages
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigInteger;
@Getter @Setter
public class ActionSummaryByGoalBean implements Serializable {
@Expose
private String goal;
@Expose
private BigInteger count;
}
package com.bytesw.bytebot.bean;
import com.bytesw.bytebot.model.Agent;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter @Setter
@ToString
public class AgentBean {
@Expose
private Long id;
@Expose
private String name;
@Expose
private String description;
@Expose
private String version;
@Expose
private String status;
@Expose
private Long countryId;
@Expose
private String countryName;
@Expose
private String timezone;
@Expose
private String avatar;
@Expose
private String language;
@Expose
private String type;
@Expose
private int period;
@Expose
private List<DeploymentChannelBean> deploymentChannels;
@Expose
private List<FrequentQuestionBean> frequentQuestions;
public static AgentBean miniClone(Agent agent) {
AgentBean bean = new AgentBean();
bean.setId(agent.getId());
bean.setName(agent.getName());
bean.setVersion(agent.getVersion());
bean.setStatus(agent.getStatus().getName());
bean.setTimezone(agent.getTimezone());
bean.setAvatar(agent.getAvatar());
if (agent.getCountry() != null) {
bean.setCountryName(agent.getCountry().getName());
}
return bean;
}
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
@Getter @Setter
public class AverageBean implements Serializable {
@Expose
private BigDecimal firstResponseAverage;
@Expose
private BigDecimal sessionAverage;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter @Setter
public class BdcControlBean implements Serializable {
@Expose private Long id;
@Expose private String uuid;
@Expose private String fileName;
@Expose private String status;
@Expose private String user;
@Expose private String date;
@Expose private Long fileId;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.OffsetDateTime;
@Getter @Setter
public class BusinessParameterBean implements Serializable {
@Expose private BigInteger id;
@Expose private long version;
@Expose private String key;
@Expose private String description;
@Expose private String required;
@Expose private String defaultValue;
@Expose private String currentValue;
@Expose private OffsetDateTime dateFrom;
@Expose private OffsetDateTime dateApplyFrom;
@Expose private String programmedValue;
@Expose private BigInteger currentConfigurationId;
@Expose private BigInteger programmedConfigurationId;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.OffsetDateTime;
@Getter @Setter
public class BusinessParameterConfigurationBean implements Serializable {
@Expose private BigInteger id;
@Expose private long version;
@Expose private OffsetDateTime from;
@Expose private OffsetDateTime to;
@Expose private String value;
@Expose private String programmedValue;
@Expose private BusinessParameterBean businessParameters;
@Expose private BigInteger currentConfigurationId;
@Expose private BigInteger programmedConfigurationId;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.OffsetDateTime;
@Getter @Setter
public class BusinessParameterValueBean implements Serializable {
@Expose private String key;
@Expose private String description;
@Expose private boolean required;
@Expose private String defaultValue;
@Expose private String value;
@Expose private OffsetDateTime from;
@Expose private BigInteger id;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
@Getter
@Setter
public class CalendarExceptionBean {
@Expose
private BigInteger id;
@Expose
private long version;
@Expose
private String description;
@Expose
private CalendarBean calendar;
@Expose
private String calendarExceptionType;
//Frecuencia
@Expose
private String frequencyType;
//annualCalendar y UniqueWeekly
@Expose
private int month;
@Expose
private int dayOfMonth;
@Expose
private int weekOfMonth;
@Expose
private int dayOfWeek;
//UniqueCalendar
@Expose
private LocalDate date;
//rangeCalendar
@Expose
private OffsetDateTime from;
@Expose
private OffsetDateTime to;
@Expose
private boolean delete;
}
package com.bytesw.bytebot.bean;
import com.bytesw.bytebot.model.Channel;
import com.bytesw.bytebot.model.ChannelParam;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @author Sebastian Chicoma Sandmann
* @version 10-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public class ChannelBean {
@Expose
private Long id;
@Expose
private String name;
@Expose
private String image;
@Expose
private List<ChannelParamBean> parameters;
@Expose
private String suggestTitle;
@Expose
private String suggestDetail;
public static ChannelBean clone(Channel channel) {
ChannelBean bean = new ChannelBean();
bean.setId(channel.getId());
bean.setName(channel.getName());
bean.setImage(channel.getImage());
bean.setParameters(new ArrayList<>());
bean.setSuggestTitle(channel.getSuggestTitle());
bean.setSuggestDetail(channel.getSuggestDetail());
if (channel.getParameters() != null) {
Collections.sort(channel.getParameters(), (o1, o2) -> o1.getOrder() - o2.getOrder());
for (ChannelParam param : channel.getParameters()) {
bean.getParameters().add(ChannelParamBean.clone(param));
}
}
return bean;
}
}
package com.bytesw.bytebot.bean;
import com.bytesw.bytebot.model.ChannelParam;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author Sebastian Chicoma Sandmann
* @version 10-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public class ChannelParamBean {
@Expose
private String name;
@Expose
private String label;
@Expose
private Integer maxlength;
@Expose
private String type;
@Expose
private Boolean required;
@Expose
private Integer order;
@Expose
private String traductions;
@Expose
private String regex;
public static ChannelParamBean clone(ChannelParam channelParam) {
ChannelParamBean bean = new ChannelParamBean();
bean.setName(channelParam.getName());
bean.setLabel(channelParam.getLabel());
bean.setMaxlength(channelParam.getMaxlength());
bean.setRequired(channelParam.isRequired());
bean.setType(channelParam.getType());
bean.setOrder(channelParam.getOrder());
bean.setTraductions(channelParam.getTraductions());
bean.setRegex(channelParam.getRegex());
return bean;
}
}
package com.bytesw.bytebot.bean;
import com.bytesw.bytebot.model.Country;
import com.bytesw.bytebot.model.Timezone;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.ArrayList;
import java.util.List;
/**
* @author Sebastian Chicoma Sandmann
* @version 10-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public class CountryBean {
@Expose
private Long id;
@Expose
private String name;
@Expose
private List<String> timezones;
public static CountryBean clone(Country country) {
CountryBean bean = new CountryBean();
bean.setId(country.getId());
bean.setName(country.getName());
bean.setTimezones(new ArrayList<>());
if (country.getTimezones() != null) {
for (Timezone timezone : country.getTimezones()) {
bean.getTimezones().add(timezone.getTimezone());
}
}
return bean;
}
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public class DeploymentChannelBean {
@Expose
private Long id;
@Expose
private String name;
@Expose
private String status;
@Expose
private Long channelId;
@Expose
private String channelName;
@Expose
private List<DeploymentChannelParamValueBean> parameters;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public class DeploymentChannelParamValueBean {
@Expose
private Long id;
@Expose
private String channelParamName;
@Expose
private String value;
@Expose
private Long agen_id;
@Expose
private String channel;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public class FrequentQuestionBean {
@Expose
private Long id;
@Expose
private String uuid;
@Expose
private String filename;
@Expose
private String description;
@Expose
private String status;
@Expose
private String user;
@Expose
private String uploadDate;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigInteger;
@Getter @Setter
public class MessageByIntentBean implements Serializable {
@Expose
private String identifier;
@Expose
private BigInteger count;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class ProcessETLBean implements Serializable {
@Expose
private int id;
@Expose
private String name;
@Expose
private long version;
}
package com.bytesw.bytebot.bean;
import lombok.Getter;
import lombok.Setter;
import java.time.OffsetDateTime;
@Getter @Setter
public class RangeBean {
private OffsetDateTime startDate;
private OffsetDateTime endDate;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigInteger;
@Getter @Setter
public class SessionByClientBean implements Serializable {
@Expose
private BigInteger user_id;
@Expose
private String sender_id;
@Expose
private BigInteger count;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@Getter @Setter
public class SummaryBean implements Serializable {
@Expose
private BigInteger value;
@Expose
private BigDecimal percent;
@Expose
private List<ArrayList<Object>> history;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigInteger;
@Getter @Setter
public class SummaryMessageByIntentBean implements Serializable {
@Expose
private Long id;
@Expose
private String identifier;
@Expose
private BigInteger count;
}
package com.bytesw.bytebot.bean;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.math.BigInteger;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
@Getter
@Setter
public class WeekSchedulerBean {
@Expose
private BigInteger id;
@Expose
private long version;
@Expose
private int dayOfWeek;
@Expose
private OffsetTime from;
@Expose
private OffsetTime to;
@Expose
private String calendarID;
@Expose
private String calendarName;
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.etl.beans.ActionBean;
import com.bytesw.bytebot.service.ActionService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RequestMapping("/service/settings/actions")
@ProgramSecurity("ACTIONS")
@Log4j2
public class ActionController extends XDFController<ActionBean, Long> {
public ActionController(ActionService service) {
super(service);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.AgentBean;
import com.bytesw.bytebot.controller.bean.ResponseController;
import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.service.*;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.swagger.annotations.ApiParam;
import java.security.Principal;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@Log4j2
@RestController
@RequestMapping("/service/agent")
@ProgramSecurity("conversational_agent")
public class AgentController {
@Autowired
private AgentService agentService;
@Autowired
private FileManagementService fileManagementService;
@Autowired
private GsonBuilder gsonBuilder;
@Autowired
private OrquestadorService orquestadorService;
@PostMapping(value = "/page")
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> paginationConversationalAgent(@RequestBody Pagination<AgentBean> pagination) {
HttpStatus hs = HttpStatus.OK;
try {
agentService.searchByPagination(pagination);
return new ResponseEntity<>(gsonBuilder.create().toJson(pagination), hs);
} catch (Exception e) {
log.error("Error detectado: ", e);
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(ExceptionUtils.getFullStackTrace(e)), hs);
}
}
@GetMapping(value = "/{id}")
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> getConversartionalAgentById(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) {
HttpStatus hs = HttpStatus.OK;
try {
return new ResponseEntity<>(gsonBuilder.create().toJson(agentService.getAgent(id)), hs);
} catch (Exception e) {
log.error("Error detectado: ", e);
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(ExceptionUtils.getFullStackTrace(e)), hs);
}
}
@PutMapping(value = "/")
@PreAuthorize("hasPermission(this, 'new')")
public ResponseEntity<String> createConversationalAgent(@RequestBody AgentBean agentBean) {
HttpStatus hs = HttpStatus.OK;
try {
agentService.save(agentBean);
return new ResponseEntity<>(gsonBuilder.create().toJson(new ResponseController("agent.insert.success", hs.value())), hs);
} catch (Exception e) {
log.error("Error detectado: ", e);
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(ExceptionUtils.getFullStackTrace(e)), hs);
}
}
@PutMapping(value = "/{id}")
@PreAuthorize("hasPermission(this, 'edit')")
public ResponseEntity<String> updateConversationalAgent(@PathVariable("id") Long id,
@RequestBody AgentBean agentBean) {
HttpStatus hs = HttpStatus.OK;
try {
if (id != null) {
agentService.save(agentBean);
return new ResponseEntity<>(gsonBuilder.create().toJson(new ResponseController("agent.update.success", hs.value())), hs);
} else {
hs = HttpStatus.UNAUTHORIZED;
return new ResponseEntity<>(gsonBuilder.create().toJson(new ResponseController("agent.update.error", hs.value())), hs);
}
} catch (Exception e) {
log.error("Error detectado: ", e);
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(ExceptionUtils.getFullStackTrace(e)), hs);
}
}
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasPermission(this, 'delete')")
public ResponseEntity<String> deleteConversationalAgent(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) {
HttpStatus hs = HttpStatus.OK;
try {
if (id != null) {
boolean deleteValid = agentService.delete(id);
if (deleteValid) {
return new ResponseEntity<>(gsonBuilder.create().toJson(new ResponseController("agent.delete.success", hs.value())), hs);
} else {
// hs = HttpStatus.FAILED_DEPENDENCY;
return new ResponseEntity<>(gsonBuilder.create().toJson(new ResponseController("agent.delete.error.integrity", hs.FAILED_DEPENDENCY.value())), hs);
}
} else {
hs = HttpStatus.UNAUTHORIZED;
return new ResponseEntity<>(gsonBuilder.create().toJson(new ResponseController("agent.delete.error.unauthtorized", hs.value())), hs);
}
} catch (Exception e) {
log.error("Error detectado: ", e);
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(ExceptionUtils.getFullStackTrace(e)), hs);
}
}
@GetMapping(value = "/countries")
public ResponseEntity<String> getCountries() {
HttpStatus hs = HttpStatus.OK;
try {
return new ResponseEntity<>(gsonBuilder.create().toJson(agentService.getCountries()), hs);
} catch (Exception e) {
log.error("Error detectado: ", e);
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(ExceptionUtils.getFullStackTrace(e)), hs);
}
}
@GetMapping(value = "/channels")
public ResponseEntity<String> getChannels() {
HttpStatus hs = HttpStatus.OK;
try {
return new ResponseEntity<>(gsonBuilder.create().toJson(agentService.getChannels()), hs);
} catch (Exception e) {
log.error("Error detectado: ", e);
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(ExceptionUtils.getFullStackTrace(e)), hs);
}
}
@PostMapping("/file-upload")
public ResponseEntity<String> uploadFile(@RequestParam("file") MultipartFile file, Principal principal) {
Gson gson = gsonBuilder.create();
try {
String uuid = UUID.randomUUID().toString();
FileValidationResponse response = orquestadorService.executeGenerateBCD(uuid, file);
response.setUser(principal != null ? principal.getName() : null);
return new ResponseEntity<>(gson.toJson(response), HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
@PutMapping("/file-upload/{uuid}")
public ResponseEntity<String> uploadFile(@PathVariable("uuid") String uuid, Principal principal) {
Gson gson = gsonBuilder.create();
try {
FileValidationResponse response = orquestadorService.retry(uuid);
response.setUser(principal != null ? principal.getName() : null);
return new ResponseEntity<>(gson.toJson(response), HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@DeleteMapping("/file-upload/{uuid}")
public ResponseEntity<String> deleteBdc(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) {
Gson gson = gsonBuilder.create();
Map<String, String> resp = new HashMap<>();
try {
orquestadorService.deleteBcd(uuid);
resp.put("message", "OK");
return new ResponseEntity<>(gson.toJson(resp), HttpStatus.OK);
} catch (Exception e) {
resp.put("message", "ERROR");
return new ResponseEntity<>(gson.toJson(resp), HttpStatus.OK);
}
}
@GetMapping("/synchronize/{id}")
public ResponseEntity<String> synchronizeFiles(@PathVariable("id") Long id,
@RequestParam("user") String user) {
Gson gson = new GsonBuilder().create();
try {
agentService.synchronizeFiles(id, user);
return new ResponseEntity<>(HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@GetMapping(value = "/")
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> getAgentAll() {
HttpStatus hs = HttpStatus.OK;
try {
return new ResponseEntity<>(gsonBuilder.create().toJson(agentService.getAgentAll()), hs);
} catch (Exception e) {
String info = "Error detectado al obtener informacion";
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(info), hs);
}
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.dto.AirportDto;
import com.bytesw.bytebot.dto.DataPage;
import com.bytesw.bytebot.service.AirportService;
import com.bytesw.xdf.controller.BasicXDFController;
import com.bytesw.xdf.service.XDFService;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/service/airport")
public class AirportController extends BasicXDFController<AirportDto, Long> {
@Autowired
private AirportService airportService;
@Autowired
private GsonBuilder gsonBuilder;
public AirportController(AirportService airportService) {
super(airportService);
}
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<AirportDto> pagination) {
Gson gson = gsonBuilder.create();
DataPage<AirportDto> value = new DataPage<>();
value.setData(airportService.getAll());
return new ResponseEntity(value, HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.BdcControlBean;
import com.bytesw.bytebot.service.BcdControlService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RequestMapping("/service/settings/bcdControl")
@ProgramSecurity("BCDCONTROL")
@Log4j2
public class BdcControlController extends XDFController<BdcControlBean, Long> {
public BdcControlController(BcdControlService service) {
super(service);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.dto.BookingAgentDto;
import com.bytesw.bytebot.dto.DataPage;
import com.bytesw.bytebot.service.BookingAgentService;
import com.bytesw.xdf.controller.BasicXDFController;
import com.bytesw.xdf.service.XDFService;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/service/agent")
public class BookingAgentController extends BasicXDFController<BookingAgentDto, Long> {
@Autowired
private BookingAgentService agentService;
@Autowired
private GsonBuilder gsonBuilder;
public BookingAgentController(BookingAgentService bookingAgentService) {
super(bookingAgentService);
}
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<BookingAgentDto> pagination) {
Gson gson = gsonBuilder.create();
DataPage<BookingAgentDto> value = new DataPage<>();
value.setData(agentService.getAll());
return new ResponseEntity(value, HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.service.BusinessParameterConfigurationService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import com.bytesw.bytebot.bean.BusinessParameterConfigurationBean;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigInteger;
@RestController()
@RequestMapping("/service/settings/business-parameter-configuration")
@ProgramSecurity("BUSINESS_PARAMETERS_CONFIGURATION")
@Log4j2
public class BusinessParameterConfigurationController extends XDFController<BusinessParameterConfigurationBean, BigInteger> {
public BusinessParameterConfigurationController(BusinessParameterConfigurationService service) {
super(service);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.BusinessParameterBean;
import com.bytesw.bytebot.bean.BusinessParameterValueBean;
import com.bytesw.bytebot.bean.BusinessParameterConfigurationBean;
import com.bytesw.bytebot.service.BusinessParameterService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import com.bytesw.xdf.exception.ReferentialIntegrityException;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigInteger;
import java.time.OffsetDateTime;
import java.util.List;
@RestController()
@RequestMapping("/service/settings/business-parameter")
@ProgramSecurity("BUSINESS-PARAMETERS")
@Log4j2
public class BusinessParameterController extends XDFController<BusinessParameterBean, BigInteger> {
@Autowired BusinessParameterService service;
@Autowired
protected GsonBuilder gsonBuilder;
public BusinessParameterController(BusinessParameterService service) {
super(service);
}
@RequestMapping(value = {"/value/{key}"}, method = {RequestMethod.PUT})
@ApiResponses({
@ApiResponse(code = 200, message = "Success", response = ResponseEntity.class),
@ApiResponse(code = 404,message = "Not Found"),
@ApiResponse(code = 409,message = "Already exists"),
@ApiResponse(code = 505, message = "Internal Server Error")
})
@PreAuthorize("hasPermission(this, 'edit')")
public ResponseEntity<Void> addNewAddValue(
@ApiParam(value = "key", required = true) @PathVariable("key") String key,
@ApiParam(value = "value", required = true) @RequestParam("value") String value,
@ApiParam(value = "from", required = false) @RequestParam("from") String fromString) {
OffsetDateTime from = OffsetDateTime.parse(fromString);
this.service.addValue(key, value, from);
return new ResponseEntity(HttpStatus.OK);
}
@RequestMapping(value = {"/create"}, method = {RequestMethod.POST})
@ApiResponses({
@ApiResponse(code = 200, message = "Success", response = ResponseEntity.class),
@ApiResponse(code = 409, message = "Already Exists"),
@ApiResponse(code = 505, message = "Internal Server Error")
})
@PreAuthorize("hasPermission(this, 'new')")
public ResponseEntity<String> createWithValue(@RequestBody BusinessParameterValueBean bean, HttpServletRequest req) {
Gson gson = gsonBuilder.create();
bean = this.service.createWithValue(bean);
return new ResponseEntity(gson.toJson(bean), HttpStatus.OK);
}
@RequestMapping(value = {"/current/{key}"}, method = {RequestMethod.GET})
@ApiResponses({
@ApiResponse(code = 200, message = "Success", response = ResponseEntity.class),
@ApiResponse(code = 404,message = "Not Found"),
@ApiResponse(code = 409, message = "Already Exists"),
@ApiResponse(code = 505, message = "Internal Server Error")
})
@PreAuthorize("hasPermission(this, 'new')")
public ResponseEntity<String> getCurrentValue(@ApiParam(value = "key", required = true) @PathVariable("key") String key) {
Gson gson = gsonBuilder.create();
// String value = this.service.getCurrentValue(key);
String value = this.service.getCurrentValueParameterByKey(key);
return new ResponseEntity(gson.toJson(value), HttpStatus.OK);
}
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@RequestMapping(
method = {RequestMethod.GET},
value = {"/parameter-value/{key}"}
)
@ResponseBody
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> getFeaturesTemplate(@PathVariable("key") String key) {
String featuresTemplate = ((BusinessParameterService)this.service).getCurrentValueParameterByKey(key);
return new ResponseEntity(this.gson.toJson(featuresTemplate), HttpStatus.OK);
}
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@RequestMapping(
method = {RequestMethod.POST},
value = {"/page"}
)
@ResponseBody
@Override
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<BusinessParameterBean> pagination) {
if (pagination.getFilterExpression()!=null) {
if (pagination.getFilterExpression().contains("(required==Y)")) {
pagination.setFilterExpression(pagination.getFilterExpression().replace("(required==Y)", "(required==true)"));
}
}
this.service.searchByPagination(pagination);
return new ResponseEntity(this.gson.toJson(pagination), HttpStatus.OK);
}
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 404,
message = "Not Found"
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@RequestMapping(
value = {"/{id}"},
method = {RequestMethod.DELETE}
)
@PreAuthorize("hasPermission(this, 'delete')")
public ResponseEntity<String> delete(@PathVariable("id") BigInteger id, HttpServletRequest req) {
this.service.delete(id);
return new ResponseEntity(HttpStatus.OK);
}
@RequestMapping(
value = {"/{id}"},
method = {RequestMethod.PUT}
)
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 404,
message = "Not Found"
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@PreAuthorize("hasPermission(this, 'edit')")
public ResponseEntity<String> update(@PathVariable("id") BigInteger id, @RequestBody BusinessParameterBean bean, HttpServletRequest req) {
try {
if (this.service.validateKey(bean)) {
throw new ReferentialIntegrityException("Ya existe un identificador con el mismo nombre");
} else {
this.service.update(bean, id);
}
} catch (ObjectOptimisticLockingFailureException var6) {
BusinessParameterBean actualBean = this.service.getById(id);
return new ResponseEntity(this.gson.toJson(actualBean), HttpStatus.CONFLICT);
}
return new ResponseEntity(HttpStatus.OK);
}
@RequestMapping(
value = {"/"},
method = {RequestMethod.POST}
)
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 409,
message = "Already Exists"
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@PreAuthorize("hasPermission(this, 'new')")
public ResponseEntity<String> create(@RequestBody BusinessParameterBean bean, HttpServletRequest req) {
if (this.service.validateKey(bean)) {
throw new ReferentialIntegrityException("Ya existe un identificador con el mismo nombre");
} else {
bean = this.service.createBP(bean);
return new ResponseEntity(this.gson.toJson(bean), HttpStatus.OK);
}
}
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 404,
message = "Not Found"
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@RequestMapping(
value = {"/searchKey/{busnessKey}"},
method = {RequestMethod.GET}
)
@PreAuthorize("hasPermission(this, 'showHistory')")
public ResponseEntity<String> findByKey(@PathVariable("busnessKey") BigInteger busnessKey, HttpServletRequest req) {
List<BusinessParameterConfigurationBean> bean = this.service.getConfigurationParametersList(busnessKey);
return new ResponseEntity(this.gson.toJson(bean), HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.CalendarBean;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import com.bytesw.bytebot.service.CalendarService;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RequestMapping("/service/settings/calendar")
@ProgramSecurity("CALENDAR")
@Log4j2
public class CalendarController extends XDFController<CalendarBean, String> {
public CalendarController(CalendarService service) {
super(service);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.CalendarExceptionBean;
import com.bytesw.bytebot.service.CalendarExceptionService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
@RestController()
@RequestMapping("/service/settings/calendar-exception")
@ProgramSecurity("CALENDAR-EXCEPTION")
@Log4j2
public class CalendarExceptionController extends XDFController<CalendarExceptionBean, BigInteger> {
@Autowired
CalendarExceptionService service;
public CalendarExceptionController(CalendarExceptionService service) {
super(service);
}
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 404,
message = "Not Found"
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@RequestMapping(
value = {"/find-by-calendar-id"},
method = {RequestMethod.POST}
)
@ResponseBody
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> getCalendarExceptionbyID(@RequestBody Map<String, String> parametersCalendar, HttpServletRequest req) {
List<CalendarExceptionBean> calendarExceptionBeanList = this.service.getCalendarExceptionbyID(parametersCalendar);
return new ResponseEntity(this.gson.toJson(calendarExceptionBeanList), HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.SummaryMessageBySentenceBean;
import com.bytesw.bytebot.service.dashboard.CustomerInteractionDashboardService;
import com.bytesw.bytebot.service.dashboard.OperativeDashboardService;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/dashboard")
public class DashboardController {
@Autowired
private OperativeDashboardService operativeDashboardService;
@Autowired
private CustomerInteractionDashboardService customerInteractionDashboardService;
@Autowired
private Gson gson;
@PostMapping("/operative")
public ResponseEntity<String> getOperativeInfo(@RequestBody Map<String, Object> body) {
Map<String, Object> info = operativeDashboardService.generateInfo(body);
return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK);
}
@PostMapping("/operative/sentence-by-intent/page")
public ResponseEntity<String> getSentenceByIntentPage(@RequestBody Pagination<SummaryMessageBySentenceBean> pagination) {
customerInteractionDashboardService.getSummaryBySentencePagination(pagination);
return new ResponseEntity<>(gson.toJson(pagination), HttpStatus.OK);
}
@PostMapping("/customer-interaction")
public ResponseEntity<String> getCustomerInteractionInfo(@RequestBody Map<String, Object> body) {
Map<String, Object> info = customerInteractionDashboardService.generateInfo(body);
return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK);
}
@PostMapping("/customer-interaction/message-by-intent/page")
public ResponseEntity<String> getMessageByIntentPage(@RequestBody Pagination<SummaryMessageBySentenceBean> pagination) {
customerInteractionDashboardService.getSummaryByIntentAndSentencePagination(pagination);
return new ResponseEntity<>(gson.toJson(pagination), HttpStatus.OK);
}
@GetMapping("/test")
public ResponseEntity<String> getTest() {
Map<String, Object> data = customerInteractionDashboardService.generateInfo(new HashMap<>());
return new ResponseEntity<>(gson.toJson(data), HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.dto.DataPage;
import com.bytesw.bytebot.dto.FlightDto;
import com.bytesw.bytebot.service.AirportService;
import com.bytesw.bytebot.service.FlightService;
import com.bytesw.xdf.controller.XDFController;
import com.bytesw.xdf.service.XDFService;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/service/flight")
public class FlightController extends XDFController<FlightDto, Long> {
@Autowired
private FlightService flightService;
@Autowired
private AirportService airportService;
@Autowired
private GsonBuilder gsonBuilder;
public FlightController(FlightService flightService) {
super(flightService);
}
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<FlightDto> pagination) {
Gson gson = gsonBuilder.create();
DataPage<FlightDto> value = new DataPage<>();
value.setData(flightService.getAll());
return new ResponseEntity(value, HttpStatus.OK);
}
public ResponseEntity<String> findAll(HttpServletRequest req) {
return new ResponseEntity(this.flightService.getAll(), HttpStatus.OK);
}
public ResponseEntity<String> findOne(@PathVariable("id") Long id, HttpServletRequest req) {
return new ResponseEntity(this.flightService.getById(id), HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.service.GoalService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import com.google.gson.GsonBuilder;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController()
@RequestMapping("/service/settings/goal")
@ProgramSecurity("GOAL")
@Log4j2
public class GoalController extends XDFController<Map, Long> {
@Autowired
private GoalService goalService;
@Autowired
private GsonBuilder gsonBuilder;
public GoalController(GoalService service) {
super(service);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.etl.beans.GoalForActionsBean;
import com.bytesw.bytebot.service.GoalForActionService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RequestMapping("/service/settings/goal-for-actions")
@ProgramSecurity("GOALFORACTIONS")
@Log4j2
public class GoalForActionController extends XDFController<GoalForActionsBean, Long> {
public GoalForActionController(GoalForActionService service) {
super(service);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.dto.DataPage;
import com.bytesw.bytebot.dto.ItineraryReservationDto;
import com.bytesw.bytebot.service.ItineraryReservationService;
import com.bytesw.xdf.controller.BasicXDFController;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/service/itinerarys")
public class ItineraryReservationController extends BasicXDFController<ItineraryReservationDto, Long> {
@Autowired
private ItineraryReservationService itineraryReservationService;
@Autowired
private GsonBuilder gsonBuilder;
public ItineraryReservationController(ItineraryReservationService itineraryReservationService) {
super(itineraryReservationService);
}
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<ItineraryReservationDto> pagination) {
Gson gson = gsonBuilder.create();
DataPage<ItineraryReservationDto> value = new DataPage<>();
value.setData(itineraryReservationService.getAll());
return new ResponseEntity(value, HttpStatus.OK);
}
public ResponseEntity<String> finAll(HttpServletRequest req) {
return new ResponseEntity(this.itineraryReservationService.getAll(), HttpStatus.OK);
}
public ResponseEntity<String> findOne(@PathVariable("id") Long id, HttpServletRequest req) {
return new ResponseEntity(this.itineraryReservationService.getById(id), HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.dto.DataPage;
import com.bytesw.bytebot.dto.LegDto;
import com.bytesw.bytebot.model.Leg;
import com.bytesw.bytebot.repository.IItineraryReservationRepository;
import com.bytesw.bytebot.repository.ILegRepository;
import com.bytesw.bytebot.service.FlightService;
import com.bytesw.bytebot.service.LegService;
import com.bytesw.xdf.controller.BasicXDFController;
import com.bytesw.xdf.service.XDFService;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/service/leg")
public class LegController extends BasicXDFController<LegDto, Long> {
@Autowired
private LegService legService;
@Autowired
private FlightService flightService;
@Autowired
private IItineraryReservationRepository iItineraryReservationRepository;
@Autowired
private ILegRepository legRepository;
@Autowired
private GsonBuilder gsonBuilder;
public LegController(LegService legService) {
super(legService);
}
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<LegDto> pagination) {
Gson gson = gsonBuilder.create();
DataPage<LegDto> value = new DataPage<>();
value.setData(legService.getAll());
return new ResponseEntity(value, HttpStatus.OK);
}
@GetMapping("list/{id}/flights")
public ResponseEntity<String> listFlightsByLegs(@PathVariable(value = "id") Long id) {
return new ResponseEntity(flightService.getById(id).getLegs(), HttpStatus.OK);
}
@PostMapping("/reservation/{id}")
public ResponseEntity<String> addLeg(@PathVariable(value = "id") Long id, @RequestBody Leg legReq) {
Leg leg = iItineraryReservationRepository.findById(id).map( itineraryReservation -> {
Long legId = legReq.getId();
Leg nLeg = legRepository.getOne(legId);
itineraryReservation.addLeg(nLeg);
iItineraryReservationRepository.save(itineraryReservation);
return nLeg;
}).orElseThrow(null);
return new ResponseEntity(HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.dto.DataPage;
import com.bytesw.bytebot.dto.PassengerDto;
import com.bytesw.bytebot.service.PassengerService;
import com.bytesw.xdf.controller.BasicXDFController;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/service/passenger")
public class PassengerController extends BasicXDFController<PassengerDto, Long> {
@Autowired
private PassengerService passengerService;
@Autowired
private GsonBuilder gsonBuilder;
public PassengerController(PassengerService passengerService) {
super(passengerService);
}
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<PassengerDto> pagination) {
Gson gson = gsonBuilder.create();
DataPage<PassengerDto> value = new DataPage<>();
value.setData(passengerService.getAll());
return new ResponseEntity(value, HttpStatus.OK);
}
public ResponseEntity<String> findAll(HttpServletRequest req) {
return new ResponseEntity(this.passengerService.getAll(), HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.dto.DataPage;
import com.bytesw.bytebot.dto.PaymentDto;
import com.bytesw.bytebot.model.Payment;
import com.bytesw.bytebot.repository.IItineraryReservationRepository;
import com.bytesw.bytebot.repository.IPaymentRepository;
import com.bytesw.bytebot.service.PaymentService;
import com.bytesw.xdf.controller.BasicXDFController;
import com.bytesw.xdf.service.XDFService;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/service/payment")
public class PaymentController extends BasicXDFController<PaymentDto, Long> {
@Autowired
private PaymentService paymentService;
@Autowired
private IItineraryReservationRepository itineraryReservationRepository;
@Autowired
private IPaymentRepository paymentRepository;
@Autowired
private GsonBuilder gsonBuilder;
public PaymentController(PaymentService paymentService) {
super(paymentService);
}
@Override
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<PaymentDto> pagination) {
Gson gson = gsonBuilder.create();
DataPage<PaymentDto> value = new DataPage<>();
value.setData(paymentService.getAll());
return new ResponseEntity(value, HttpStatus.OK);
}
@PostMapping("/reservations/{id}/payments")
public ResponseEntity<String> addTag(@PathVariable(value = "id") Long id, @RequestBody Payment paymentReq) {
Payment payment = itineraryReservationRepository.findById(id).map(itineraryReservation -> {
Long paymentId = paymentReq.getId();
Payment pay = paymentRepository.findById(paymentId).orElseThrow(null);
itineraryReservation.addPayment(pay);
itineraryReservationRepository.save(itineraryReservation);
return pay;
}).orElseThrow(null);
return new ResponseEntity(HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.CalendarBean;
import com.bytesw.bytebot.bean.ProcessETLBean;
import com.bytesw.bytebot.service.CalendarService;
import com.bytesw.bytebot.service.ProcessETLService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RequestMapping("/service/settings/ProcessETL")
@ProgramSecurity("PROCESSETL")
@Log4j2
public class ProcessETLController extends XDFController<ProcessETLBean, Integer> {
public ProcessETLController(ProcessETLService service) {
super(service);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.service.provider.TwilioService;
import com.bytesw.xdf.exception.NotFoundException;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
import com.twilio.exception.AuthenticationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.google.gson.Gson;
import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;
@Log4j2
@RestController
@RequestMapping("/providers")
public class ProviderController {
@Autowired
private TwilioService twilioService;
@Autowired
private Gson gson;
@ApiResponses(value={
@ApiResponse(code=200, message = "OK"),
@ApiResponse(code=400, message = "Bad Request. Datos de entrada inválido"),
@ApiResponse(code=401, message = "Unauthorized. Credenciales erróneas"),
@ApiResponse(code=404, message = "Not Found. Recursos no encontrados")
})
@RequestMapping(value="/twilio/messages/{sid_message}",method = {RequestMethod.DELETE})
public ResponseEntity<String> deleteSensibleInfo(@ApiParam(value="sid_message",required = true) @PathVariable("sid_message") String sid_message,
@ApiParam(value = "agent_id: Agente a cual eliminar su data sensible\n{\"agent_id\":1}",
example = "{agent_id:1}",required = true) @NotNull @RequestBody(required = false) Map<String,Object> body){
Map<String,Object> info = new HashMap<>();
try {
if (body == null) {
log.info("Body Input Inválido");
throw new ClassCastException("Input inválido");
}
info = twilioService.generateInfo(sid_message, body);
}catch (ClassCastException e){
return new ResponseEntity<>(e.getMessage(),HttpStatus.BAD_REQUEST);
}catch(NotFoundException e){
return new ResponseEntity<>(e.getMessage(),HttpStatus.NOT_FOUND);
}catch (AuthenticationException e){
return new ResponseEntity<>(e.getMessage(),HttpStatus.UNAUTHORIZED);
}catch (InternalError e){
return new ResponseEntity<>(e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
}
return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK);
}
}
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.SchedulerTaskBean;
import com.bytesw.bytebot.service.SchedulerTaskService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import com.bytesw.xdf.sql.beans.Pagination;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@RestController()
@RequestMapping("/service/settings/scheduler-task")
@ProgramSecurity("SCHEDULER-TASK")
@Log4j2
public class SchedulerTaskController extends XDFController<SchedulerTaskBean, BigInteger> {
public SchedulerTaskController(SchedulerTaskService service) {
super(service);
}
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@RequestMapping(
method = {RequestMethod.POST},
value = {"/page"}
)
@ResponseBody
@Override
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> findAllByPagination(@RequestBody Pagination<SchedulerTaskBean> pagination) {
if (!Objects.isNull(pagination.getFilterExpression()) && !pagination.getFilterExpression().isEmpty()) {
String filterExpression = pagination.getFilterExpression();
if (filterExpression.contains("(internals==Y)")) {
filterExpression = filterExpression.replace("(internals==Y)", "(internals==true)");
}
if (filterExpression.contains("calendarName")) {
filterExpression = filterExpression.replace("calendarName", "calendar.name");
}
pagination.setFilterExpression(filterExpression);
}
this.service.searchByPagination(pagination);
return new ResponseEntity(this.gson.toJson(pagination), HttpStatus.OK);
}
@ApiResponses({@ApiResponse(
code = 200,
message = "Success",
response = ResponseEntity.class
), @ApiResponse(
code = 505,
message = "Internal Server Error"
)})
@RequestMapping(
method = {RequestMethod.GET},
value = {"/initial-data"}
)
@ResponseBody
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> getInitialData() {
Map<String, List> initialData = ((SchedulerTaskService) this.service).getInitialData();
return new ResponseEntity(this.gson.toJson(initialData), HttpStatus.OK);
}
}
package com.bytesw.bytebot.etl.beans;
package com.bytesw.bytebot.dto;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
@Getter
@Setter
@ToString
public class GoalBean {
public class AirportDto implements Serializable {
@Expose
private Long id;
@Expose
private String identifier;
private String airportCode;
@Expose
private Long agenId;
}
\ No newline at end of file
private String airportName;
@Expose
private String airportLocation;
@Expose
private String details;
}
package com.bytesw.bytebot.bean;
package com.bytesw.bytebot.dto;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.math.BigInteger;
@Getter @Setter
public class SummaryMessageBySentenceBean implements Serializable {
@Getter
@Setter
@ToString
public class BookingAgentDto implements Serializable {
@Expose
private Long id;
@Expose
private String identifier;
private String agentName;
@Expose
private String sentence;
private String agentLastname;
@Expose
private BigInteger count;
private String dni;
@Expose
private BigInteger customerCount;
private String agentPhone;
@Expose
private String agentDetails;
}
package com.bytesw.bytebot.etl.beans;
package com.bytesw.bytebot.dto;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
@Getter
@Setter
@ToString
public class ActionBean {
@Expose
private Long id;
public class DataPage<T> implements Serializable {
@Expose
private String identifier;
private List<T> data;
}
package com.bytesw.bytebot.dto;
import com.bytesw.bytebot.model.Leg;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Getter
@Setter
@ToString
public class FlightDto implements Serializable {
@Expose
private Long id;
@Expose
private String airlineCode;
@Expose
private String codeTypeAircraft;
@Expose
private Date departureDate;
@Expose
private Date arrivalDate;
@Expose
private Long codeAirportOrigin;
@Expose
private Long codeAirportDestination;
@Expose
private List<Leg> legs;
@Expose
private double flightCost;
@Expose
private String airportOrigin;
@Expose
private String airportDestination;
}
package com.bytesw.bytebot.bean;
package com.bytesw.bytebot.dto;
import com.bytesw.bytebot.model.Leg;
import com.bytesw.bytebot.model.Payment;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Getter
@Setter
public class CalendarBean implements Serializable {
@ToString
public class ItineraryReservationDto implements Serializable {
@Expose
private String id;
private Long id;
@Expose
private long version;
private Date dateReservation;
@Expose
private String name;
//@TODO: Revisar List<WeekScheduler> weekSchedulerList de la clase Calendar
private String status;
@Expose
private Long codePassenger;
@Expose
private Long codeAgent;
@Expose
private List<WeekSchedulerBean> weekSchedulerBeanList;
private List<Payment> payments;
@Expose
private List<CalendarExceptionBean> calendarExceptionBeanList;
}
\ No newline at end of file
private List<Leg> legs;
}
package com.bytesw.bytebot.bean;
package com.bytesw.bytebot.dto;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
@Getter
@Setter
public class SchedulerTaskBean implements Serializable {
@ToString
public class LegDto implements Serializable {
@Expose
private BigInteger id;
private Long id;
@Expose
private long version;
private Date departureDate;
@Expose
private String description;
private Date arrivalDate;
@Expose
private String internals;
private Long codeAirportOrigin;
@Expose
private String cronExpression;
private Long codeAirportDestination;
@Expose
private String stringParameters;
private Long codeFlight;
@Expose
private Integer etlId;
private String airportOrigin;
@Expose
private String calendarID;
@Expose
private String calendarName;
// @Expose
// private int idEtl;
private String airportDestination;
}
package com.bytesw.bytebot.dto;
import com.bytesw.bytebot.model.ItineraryReservation;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@ToString
public class PassengerDto implements Serializable {
@Expose
private Long id;
@Expose
private String firstName;
@Expose
private String secondName;
@Expose
private String lastName;
@Expose
private String phoneNumber;
@Expose
private String email;
@Expose
private String address;
@Expose
private String city;
@Expose
private String province;
@Expose
private String country;
@Expose
private String details;
@Expose
private List<ItineraryReservation> itineraryReservations = new ArrayList<>();
}
package com.bytesw.bytebot.etl.beans;
package com.bytesw.bytebot.dto;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
@Getter
@Setter
@ToString
public class GoalForActionsBean {
public class PaymentDto implements Serializable {
@Expose
private Long id;
@Expose
private Long goalId;
private Date paymentDate;
@Expose
private Long actionId;
private double paymentAmount;
@Expose
private String status;
}
package com.bytesw.bytebot.etl.batch.beans;
import lombok.*;
import java.io.Serializable;
@Getter @Setter
@EqualsAndHashCode
@AllArgsConstructor
@ToString
public class AttributeValueBean implements Serializable {
private final String identifier;
private String value;
private final Long dataTypeId;
}
package com.bytesw.bytebot.etl.batch.beans;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import javax.sql.DataSource;
@Configuration
public class DBConfig{
@Value("${spring.datasource.driverClassName}")
private String classDriver;
@Value("${spring.datasource.url}")
private String url;
@Value("${spring.datasource.username}")
private String user;
@Value("${spring.datasource.password}")
private String password;
@Bean
public DataSource dataSource(){
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(classDriver);
dataSource.setUrl(url);
dataSource.setUsername(user);
dataSource.setPassword(password);
return dataSource;
}
}
\ No newline at end of file
package com.bytesw.bytebot.etl.batch.beans;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DeleteDataSensBean {
private Long id;
private String channelValue;
private String value;
private Long agenId;
private Long deletePeriod;
}
package com.bytesw.bytebot.etl.batch.beans;
import lombok.Getter;
import lombok.Setter;
import java.sql.Timestamp;
@Getter
@Setter
public class DeleteDataSensControlBean {
private Long id;
private Long agenId;
private Timestamp dateDelete;
private Long eventId;
}
\ No newline at end of file
package com.bytesw.bytebot.etl.batch.beans;
import lombok.Getter;
import lombok.Setter;
import java.time.OffsetDateTime;
@Getter @Setter
public class DeleteDataSensRegistryBean {
private Long id;
private Long inten_id;
private String sender_id;
private String message_sid;
private String multimedia_sid;
private OffsetDateTime update_time;
}
package com.bytesw.bytebot.etl.batch.beans;
import java.util.HashMap;
public class DynaBean extends HashMap<String, Object> {
}
package com.bytesw.bytebot.etl.batch.beans;
import lombok.Getter;
import lombok.Setter;
import java.util.Map;
@Getter @Setter
public class TenantBatchBean {
private String id;
private Map<String, String> datasource;
}
package com.bytesw.bytebot.etl.batch.factory.mapper;
import java.util.Map;
public interface MapperFactory<T> {
T createMapper(Map<String, Object> params);
}
package com.bytesw.bytebot.etl.batch.factory.mapper;
import com.bytesw.bytebot.etl.batch.beans.DynaBean;
import com.bytesw.bytebot.etl.batch.mapper.DynaBeanRowMapper;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class RowMapperFactory implements MapperFactory<DynaBeanRowMapper<DynaBean>>{
@Override
public DynaBeanRowMapper<DynaBean> createMapper(Map<String, Object> params) {
DynaBeanRowMapper<DynaBean> rowMapper = new DynaBeanRowMapper<>();
return rowMapper;
}
}
package com.bytesw.bytebot.etl.batch.factory.reader;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.item.database.JdbcCursorItemReader;
@Log4j2
public class ByteDataBaseItemReaderFactory<T> extends JdbcCursorItemReader<T> implements StepExecutionListener {
@Override
public void beforeStep(StepExecution stepExecution) {
}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
closeDatabase();
return stepExecution.getExitStatus();
}
private void closeDatabase() {
if (this.getDataSource() instanceof BasicDataSource) {
BasicDataSource dataSource = (BasicDataSource) this.getDataSource();
if (!dataSource.isClosed()) {
try {
dataSource.close();
} catch (Exception e) {
log.debug(e.getMessage());
}
}
}
}
}
package com.bytesw.bytebot.etl.batch.factory.reader;
import com.bytesw.bytebot.etl.batch.beans.DynaBean;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.database.JdbcCursorItemReader;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import javax.sql.DataSource;
import java.util.Map;
/**
* Params:
* -jdbc-driver
* -username
* -password
* -jdbc-url
* -query
*/
@Component
@Log4j2
public class DataBaseItemReaderFactory implements ItemReaderFactory<DynaBean, RowMapper<DynaBean>> {
@Override
public ItemReader<DynaBean> createReader(RowMapper<DynaBean> mapper, Map<String, Object> params) {
JdbcCursorItemReader<DynaBean> databaseReader;
databaseReader = new ByteDataBaseItemReaderFactory<>();
String jdbcDriver = params.containsKey("jdbc-driver") ? String.valueOf(params.get("jdbc-driver")): null;;
Assert.isTrue(jdbcDriver != null, "jdbc-driver is required!");
String username = params.containsKey("username") ? String.valueOf(params.get("username")): null;;
Assert.isTrue(username != null, "username is required!");
String password = params.containsKey("password") ? String.valueOf(params.get("password")): null;;
Assert.isTrue(password != null, "password is required!");
String jdbcURL = params.containsKey("jdbc-url") ? String.valueOf(params.get("jdbc-url")): null;;
Assert.isTrue(jdbcURL != null, "jdbc-url is required!");
String query = params.containsKey("query") ? String.valueOf(params.get("query")): null;;
Assert.isTrue(query != null, "query is required!");
DataSource dataSource = getBasicDataSource(jdbcDriver, username, password, jdbcURL);
databaseReader.setDataSource(dataSource);
databaseReader.setRowMapper(mapper);
databaseReader.setSql(query);
return databaseReader;
}
protected DataSource getBasicDataSource(String jdbcDriver, String username, String password, String jdbcURL) {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(jdbcDriver);
dataSource.setUsername(username);
dataSource.setPassword(password);
dataSource.setUrl(jdbcURL);
return dataSource;
}
}
package com.bytesw.bytebot.etl.batch.factory.reader;
import org.springframework.batch.item.ItemReader;
import java.util.Map;
public interface ItemReaderFactory<T, E> {
ItemReader<T> createReader(E mapper, Map<String, Object> params);
}
package com.bytesw.bytebot.etl.batch.listener;
import lombok.extern.log4j.Log4j2;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
@Log4j2
public class JobCompletionListener extends JobExecutionListenerSupport {
@Override
public void afterJob(JobExecution jobExecution) {
if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
log.debug("BATCH JOB COMPLETED SUCCESSFULLY");
}
}
}
\ No newline at end of file
package com.bytesw.bytebot.etl.batch.mapper;
import com.bytesw.bytebot.etl.batch.beans.DynaBean;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.JdbcUtils;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
public class DynaBeanRowMapper<T> implements RowMapper<T> {
@Override
public T mapRow(ResultSet rs, int rowNum) throws SQLException {
ResultSetMetaData rsmd = rs.getMetaData();
DynaBean bean = new DynaBean();
int columnCount = rsmd.getColumnCount();
for (int i = 1; i <= columnCount; i++) {
String column = JdbcUtils.lookupColumnName(rsmd, i);
bean.putIfAbsent(column, JdbcUtils.getResultSetValue(rs, i));
}
return (T) bean;
}
}
package com.bytesw.bytebot.etl.batch.processor;
import com.bytesw.bytebot.etl.batch.beans.DynaBean;
import com.bytesw.bytebot.etl.beans.EventBean;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.batch.item.ItemProcessor;
public class ConvertToBeanProcessor implements ItemProcessor<DynaBean, DynaBean> {
private ObjectMapper mapper = new ObjectMapper();
@Override
public DynaBean process(DynaBean dynaBean) throws Exception {
Long id = new Long(String.valueOf(dynaBean.get("id")));
String data = (String) dynaBean.get("data");
String senderId = (String) dynaBean.get("sender_id");
EventBean eventBean = new EventBean();
eventBean.setId(id);
eventBean.setData(data);
eventBean.setSenderId(senderId);
dynaBean.put("bean", eventBean);
return dynaBean;
}
}
package com.bytesw.bytebot.etl.batch.service;
import com.bytesw.bytebot.etl.batch.beans.DBConfig;
import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
@Configuration
public class SchedulerConfiguration {
@Bean
public LockProvider lockProvider(DataSource dataSource) {
DBConfig dbConfig = new DBConfig();
dataSource = dbConfig.dataSource();
return new JdbcTemplateLockProvider(dataSource);
}
}
\ No newline at end of file
package com.bytesw.bytebot.etl.batch.writer;
import com.bytesw.bytebot.etl.batch.beans.DynaBean;
import com.bytesw.bytebot.etl.beans.EventBean;
import com.bytesw.bytebot.etl.beans.ProcessMessageResult;
import com.bytesw.bytebot.etl.services.ProcessMessageService;
import com.bytesw.xdf.multitenant.core.ThreadLocalStorage;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.item.ItemWriter;
import javax.transaction.Transactional;
import java.util.List;
@Log4j2
public class ByteBotJPAWriter implements ItemWriter<DynaBean>, StepExecutionListener {
@Getter
@Setter
private ProcessMessageService service;
@Override
@Transactional
public void write(List<? extends DynaBean> list) throws Exception {
for (DynaBean dynaBean : list) {
EventBean eventBean = (EventBean) dynaBean.get("bean");
String json = (String) dynaBean.get("data");
ProcessMessageResult result = service.processMessage(json, eventBean.getSenderId());
log.debug(String.format("senderId: %s, processed: %s", eventBean.getSenderId(), result.isProcessed()));
service.saveHistory(eventBean.getId(), eventBean.getSenderId());
}
}
@Override
public void beforeStep(StepExecution stepExecution) {
String tenantId = stepExecution.getJobParameters().getString("tenantId");
ThreadLocalStorage.setTenantName(tenantId);
}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
return stepExecution.getExitStatus();
}
}
package com.bytesw.bytebot.etl.batch.writer;
import com.bytesw.bytebot.etl.batch.beans.DeleteDataSensBean;
import com.bytesw.bytebot.etl.batch.beans.DeleteDataSensRegistryBean;
import com.bytesw.bytebot.etl.batch.beans.DynaBean;
import com.bytesw.bytebot.etl.dao.DeleteDataSensibleControlRepository;
import com.bytesw.bytebot.etl.dao.DeleteDataSensibleLogRepository;
import com.bytesw.bytebot.etl.dao.IntentRepository;
import com.bytesw.bytebot.etl.enums.EventTypeEnum;
import com.bytesw.bytebot.etl.model.DeleteDataSensibleControl;
import com.bytesw.bytebot.etl.model.DeleteDataSensibleLog;
import com.bytesw.bytebot.etl.model.Intent;
import com.bytesw.bytebot.etl.services.DeleteSensMessageService;
import com.bytesw.bytebot.etl.utils.JsonUtils;
import com.bytesw.xdf.exception.NotFoundException;
import com.bytesw.xdf.multitenant.core.ThreadLocalStorage;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.item.ItemWriter;
import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.time.OffsetDateTime;
import java.util.*;
@Log4j2
public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutionListener {
@Getter
@Setter
private DeleteDataSensibleControlRepository deleteDataSensibleControlRepository;
@Getter
@Setter
private DeleteDataSensibleLogRepository deleteDataSensibleLogRepository;
@Getter
@Setter
private IntentRepository intentRepository;
@Getter
@Setter
private DeleteSensMessageService service;
@Getter
@Setter
private List<String> intentByAgent;
@Getter
@Setter
private DeleteDataSensBean agent;
@Override
@Transactional
public void write(List<? extends DynaBean> list) throws Exception {
Object numeros = JsonUtils.getFieldFromJson(agent.getChannelValue(), "$.telefono_despliegue");
List<String> numerosAgentes = numbersAgent((List<Map>) numeros);
for (DynaBean dynaBean : list) {
Long id = Long.parseLong(dynaBean.get("id").toString());
String json = (String) dynaBean.get("data");
String event = (String) JsonUtils.getFieldFromJson(json, "$.event");
String sender_id;
boolean update_control = false;
String presentDate = OffsetDateTime.now().toString().replace('T', ' ');
String timeZone = presentDate.substring(presentDate.length() - 6);
presentDate = presentDate.replace(timeZone, "");
if (EventTypeEnum.USER.getName().equals(event)) {
String toAgent = (String) JsonUtils.getFieldFromJson(json, "$.metadata.To");
String agentNumber = new String();
if (toAgent == null) {
continue;
}
if (!toAgent.isEmpty()) {
agentNumber = toAgent.split(":")[1];
}
if (numerosAgentes.contains(agentNumber)) {
String intent = (String) JsonUtils.getFieldFromJson(json, "$.parse_data.intent.name");
if (intentByAgent.contains(intent)) {
String SmSMessageSid = (String) JsonUtils.getFieldFromJson(json, "$.metadata.SmsMessageSid");
Optional<Intent> intenId = this.intentRepository.findIntenNameById(intent, agent.getAgenId());
if (!intenId.isPresent()) {
throw new Exception("Intent no esta presente");
}
try {
sender_id = (String) JsonUtils.getFieldFromJson(json, "$.sender_id");
log.info(sender_id);
} catch (Exception e) {
log.info(e.getMessage());
sender_id = (String) JsonUtils.getFieldFromJson(json, "$.metadata.sender_id");
}
List<DeleteDataSensRegistryBean> deleteSensibleBean = new ArrayList<>();
try {
deleteSensibleBean = service.deleteMessage(agent.getAgenId()
, SmSMessageSid, intenId.get().getId(), sender_id);
update_control = true;
} catch (NotFoundException e) {
update_control = true;
} catch (Exception e) {
update_control = false;
}
for (DeleteDataSensRegistryBean registry : deleteSensibleBean) {
DeleteDataSensibleLog reg = new DeleteDataSensibleLog();
reg.setIntenId(registry.getInten_id());
reg.setMessageId(registry.getMessage_sid());
reg.setMultimediaId(registry.getMultimedia_sid());
reg.setSendId(registry.getSender_id());
reg.setDate(Timestamp.valueOf(presentDate));
deleteDataSensibleLogRepository.save(reg);
}
}
}
} else {
update_control = true;
}
DeleteDataSensibleControl control = new DeleteDataSensibleControl();
Optional<DeleteDataSensibleControl> controlBd = deleteDataSensibleControlRepository.findEventIdByAgentId(agent.getAgenId());
if (update_control) {
if (controlBd.isPresent()) {
// Update
control.setId(controlBd.get().getId());
control.setAgentId(agent.getAgenId());
control.setEventId(id);
control.setDate(Timestamp.valueOf(presentDate));
deleteDataSensibleControlRepository.save(control);
} else {
// Create
control.setAgentId(agent.getAgenId());
control.setEventId(id);
control.setDate(Timestamp.valueOf(presentDate));
deleteDataSensibleControlRepository.save(control);
}
}
}
}
private List<String> numbersAgent(List<Map> listNumber){
List<String> result = new ArrayList<>();
for (Map map : listNumber){
String cod = (String) map.get("codigoInternacional");
String number = (String) map.get("numero");
String agent = "+" + cod + number;
result.add(agent);
}
return result;
}
@Override
public void beforeStep(StepExecution stepExecution) {
String tenantId = stepExecution.getJobParameters().getString("tenantId");
ThreadLocalStorage.setTenantName(tenantId);
}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
return stepExecution.getExitStatus();
}
}
package com.bytesw.bytebot.etl.beans;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
@Getter @Setter @ToString
public class EventBean implements Serializable {
private Long id;
private String data;
private String senderId;
}
package com.bytesw.bytebot.etl.beans;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class IntentBean {
private Long id;
private String identifier;
private String sensible;
private Long agenId;
}
package com.bytesw.bytebot.etl.beans;
import lombok.Getter;
import lombok.Setter;
@Getter @Setter
public class ProcessMessageResult {
private boolean processed = true;
private String message;
}
package com.bytesw.bytebot.etl.beans;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.sql.Timestamp;
@Getter @Setter
public class SessionBean {
@Expose
private Long id;
@Expose
private Timestamp sessionDate;
@Expose
private Timestamp lastEventDate;
@Expose
private Timestamp responseDate;
@Expose
private Long userId;
@Expose
private Long channelId;
}
package com.bytesw.bytebot.etl.config;
import com.bytesw.bytebot.etl.batch.listener.JobCompletionListener;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
@Configuration
public class BatchConfig {
@Bean
public JobExecutionListener listener() {
return new JobCompletionListener();
}
@Bean("asyncJobLauncher")
public JobLauncher asyncJobLauncher(JobRepository jobRepository) {
final SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
jobLauncher.setJobRepository(jobRepository);
final SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor();
jobLauncher.setTaskExecutor(simpleAsyncTaskExecutor);
return jobLauncher;
}
}
package com.bytesw.bytebot.etl.config;
import com.bytesw.bytebot.etl.batch.beans.TenantBatchBean;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@ConfigurationProperties(prefix = "batch")
public class BatchProperties {
@Getter @Setter
private List<TenantBatchBean> tenants;
}
package com.bytesw.bytebot.etl.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.Map;
@ConfigurationProperties(prefix = "batch")
public class BatchPropertiesWithoutTenant {
@Getter @Setter
Map<String, String> datasource;
}
package com.bytesw.bytebot.etl.converter;
import com.bytesw.bytebot.etl.enums.MessageTypeEnum;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter
public class MessageTypeConverter implements AttributeConverter<MessageTypeEnum, String> {
@Override
public String convertToDatabaseColumn(MessageTypeEnum agentTypeEnum) {
return (agentTypeEnum != null ? agentTypeEnum.getName() : null);
}
@Override
public MessageTypeEnum convertToEntityAttribute(String s) {
return MessageTypeEnum.fromString(s);
}
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.Action;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import java.util.Optional;
public interface ActionRepository extends CrudRepository<Action, Long>, JpaSpecificationExecutor<Action> {
Optional<Action> findByIdentifier(String identifier);
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.DeleteDataSensibleControl;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.util.Optional;
public interface DeleteDataSensibleControlRepository extends CrudRepository<DeleteDataSensibleControl, Long> {
@Query("SELECT s from DeleteDataSensibleControl s WHERE s.agentId = :agentId")
Optional<DeleteDataSensibleControl> findEventIdByAgentId(@Param("agentId") Long agentId);
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.DeleteDataSensibleLog;
import org.springframework.data.repository.CrudRepository;
public interface DeleteDataSensibleLogRepository extends CrudRepository<DeleteDataSensibleLog, Long> {
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.EventHistory;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
public interface EventHistoryRepository extends CrudRepository<EventHistory, Long> {
@Query("SELECT MAX(e.eventId) FROM EventHistory e")
Long maxEventId();
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.Intent;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.util.Optional;
public interface IntentRepository extends CrudRepository<Intent, Long> {
Optional<Intent> findByIdentifier(String identifier);
@Query("SELECT s from Intent s WHERE s.identifier = :intenIdent and s.agenId = :agenId")
Optional<Intent> findIntenNameById(@Param("intenIdent") String intenIdent, @Param("agenId") Long agenId);
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.Message;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
public interface MessageRepository extends CrudRepository<Message, Long> {
@Query("SELECT s from Message s WHERE s.sessionId = :sessionId")
Long findLastCorrelativeBySession(@Param("sessionId") Long sessionId);
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.Response;
import org.springframework.data.repository.CrudRepository;
public interface ResponseRepository extends CrudRepository<Response, Long> {
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.SessionAction;
import org.springframework.data.repository.CrudRepository;
public interface SessionActionRepository extends CrudRepository<SessionAction, Long> {
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.Session;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.time.OffsetDateTime;
public interface SessionBotRepository extends CrudRepository<Session, Long> {
@Query("UPDATE Session s set s.lastEventDate = :lastEventDate WHERE s.id = :id")
void updateLastEventDateBySession(@Param("id") Long id, @Param("lastEventDate") OffsetDateTime dateTime);
}
package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.User;
import org.springframework.data.repository.CrudRepository;
import java.util.Optional;
public interface UserRepository extends CrudRepository<User, Long> {
Optional<User> findByIdentifier(String identifier);
}
package com.bytesw.bytebot.etl.enums;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
public enum EventTypeEnum {
USER("user"), BOT("bot"), ACTION("action"), START_SESSION("action_session_start");
private final String name;
private static final Map<String, EventTypeEnum> map = new HashMap<>();
static {
for (EventTypeEnum type : EventTypeEnum.values()) {
map.put(type.name, type);
}
}
EventTypeEnum(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static EventTypeEnum fromString(String name) {
if (map.containsKey(name)) {
return map.get(name);
}
throw new NoSuchElementException(name + " not found");
}
}
package com.bytesw.bytebot.etl.enums;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
public enum IntentTypeEnum {
SENSIBLE("1"), NO_SENSIBLE("0");
private final String name;
private static final Map<String, IntentTypeEnum> map = new HashMap<>();
static {
for (IntentTypeEnum type : IntentTypeEnum.values()) {
map.put(type.name, type);
}
}
IntentTypeEnum(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static IntentTypeEnum fromString(String name) {
if (map.containsKey(name)) {
return map.get(name);
}
throw new NoSuchElementException(name + " not found");
}
}
package com.bytesw.bytebot.etl.enums;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
public enum MessageTypeEnum {
REJECTED("R"), ACCEPTED("A");
private final String name;
private static final Map<String, MessageTypeEnum> map = new HashMap<>();
static {
for (MessageTypeEnum type : MessageTypeEnum.values()) {
map.put(type.name, type);
}
}
MessageTypeEnum(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static MessageTypeEnum fromString(String name) {
if (map.containsKey(name)) {
return map.get(name);
}
throw new NoSuchElementException(name + " not found");
}
}
package com.bytesw.bytebot.etl.jdbc;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class ETLMessageJDBCRepository {
@Autowired
@Qualifier("sqlSessionFactory")
private SqlSessionFactory sqlSessionFactory;
public int getLastCorrelativeBySession(Long sessionId) {
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("sessionId", sessionId);
return session.selectOne("com.bytesw.bytebot.dao.jdbc.ETLMessageMapper.getLastCorrelativeBySession", params);
} finally {
session.close();
}
}
}
package com.bytesw.bytebot.etl.jdbc;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class ETLResponseJDBCRepository {
@Autowired
@Qualifier("sqlSessionFactory")
private SqlSessionFactory sqlSessionFactory;
public int getLastCorrelativeBySession(Long sessionId) {
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("sessionId", sessionId);
return session.selectOne("com.bytesw.bytebot.dao.jdbc.ETLResponseMapper.getLastCorrelativeBySession", params);
} finally {
session.close();
}
}
}
package com.bytesw.bytebot.etl.jdbc;
import com.bytesw.bytebot.etl.beans.SessionBean;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
@Component
public class ETLSessionBotJDBCRepository {
@Autowired
@Qualifier("sqlSessionFactory")
private SqlSessionFactory sqlSessionFactory;
public SessionBean getLastSessionByUser(Long userId) {
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("userId", userId);
return session.selectOne("com.bytesw.bytebot.dao.jdbc.ETLSessionMapper.getLastSessionByUser", params);
} finally {
session.close();
}
}
public void updateLastEventDate(Long sessionID, OffsetDateTime lastEventDate) {
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("sessionId", sessionID);
params.put("lastEventDate", lastEventDate);
session.update("com.bytesw.bytebot.dao.jdbc.ETLSessionMapper.updateLastEventDate", params);
} finally {
session.close();
}
}
}
package com.bytesw.bytebot.etl.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
@Cacheable(false)
@Entity
@Getter
@Setter
@ToString
@Table(name = "AVB_ACTION")
@NamedQuery(name = "Action.findByPK", query = "Select p from Action p where p.id = ?1")
public class Action {
@Id
@Column(name = "action_id")
@SequenceGenerator(name = "AVB_ACTION_GENERATOR", sequenceName = "AVB_ACTION_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_ACTION_GENERATOR")
private Long id;
@Column(name = "action_ident")
private String identifier;
}
package com.bytesw.bytebot.etl.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.sql.Timestamp;
@Cacheable(false)
@Entity
@Getter
@Setter
@ToString
@Table(name="avb_delete_sens_msg_control")
public class DeleteDataSensibleControl {
@Id
@Column(name = "dsmc_id")
@SequenceGenerator(name = "AVB_DELETE_MSG_SENS_CONTROL_GENERATOR", sequenceName = "AVB_DELETE_SENS_MSG_CONTROL_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "AVB_DELETE_MSG_SENS_CONTROL_GENERATOR")
private Long id;
@Column(name = "agent_id")
private Long agentId;
@Column(name = "dsmc_date")
private Timestamp date;
@Column(name = "evnt_id")
private Long eventId;
}
package com.bytesw.bytebot.etl.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.sql.Timestamp;
@Cacheable(false)
@Entity
@Getter
@Setter
@ToString
@Table(name="avb_delete_sens_msg_log")
public class DeleteDataSensibleLog {
@Id
@Column(name = "dele_id")
@SequenceGenerator(name = "AVB_DELETE_MSG_SENS_LOG_GENERATOR", sequenceName = "AVB_DELETE_SENS_MSG_LOG_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "AVB_DELETE_MSG_SENS_LOG_GENERATOR")
private Long id;
@Column(name = "inten_id")
private Long intenId;
@Column(name = "send_id")
private String sendId;
@Column(name = "dele_smsg")
private String messageId;
@Column(name = "dele_msmsg")
private String multimediaId;
@Column(name = "dele_fecej")
private Timestamp date;
}
package com.bytesw.bytebot.etl.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.time.OffsetDateTime;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="avb_event_history")
@NamedQuery(name = "EventHistory.findByPK", query = "Select p from EventHistory p where p.id = ?1")
public class EventHistory {
@Id
@Column(name = "evenh_id")
@SequenceGenerator(name = "AVB_EVENT_HISTORY_GENERATOR", sequenceName = "AVB_EVENT_HISTORY_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "AVB_EVENT_HISTORY_GENERATOR")
private Long id;
@Column(name = "evenh_sendid")
private String senderId;
@Column(name = "evenh_evid")
private Long eventId;
@Column(name = "evenh_date")
private OffsetDateTime date;
}
package com.bytesw.bytebot.etl.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="avb_goal")
@NamedQuery(name = "Goal.findByPK", query = "Select p from Goal p where p.id = ?1")
public class Goal {
@Id
@Column(name = "goal_id")
@SequenceGenerator(name = "AVB_GOAL_GENERATOR", sequenceName = "AVB_GOAL_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "AVB_GOAL_GENERATOR")
private Long id;
@Column(name = "goal_ident")
private String identifier;
@Column(name = "agen_id")
private Long agenId;
}
package com.bytesw.bytebot.etl.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
@Cacheable(false)
@Entity
@Getter
@Setter
@ToString
@Table(name = "avb_GoalForActions")
@NamedQuery(name = "GoalForActions.findByPK", query = "Select p from GoalForActions p where p.id = ?1")
public class GoalForActions {
@Id
@Column(name = "gfac_id")
@SequenceGenerator(name = "AVB_GOALFORACTIONS_GENERATOR", sequenceName = "AVB_GOALFORACTIONS_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_GOALFORACTIONS_GENERATOR")
private Long id;
@Column(name = "goal_id")
private Long goalId;
@Column(name = "action_id")
private Long actionId;
}
package com.bytesw.bytebot.etl.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="avb_intent")
@NamedQuery(name = "Intent.findByPK", query = "Select p from Intent p where p.id = ?1")
public class Intent {
@Id
@Column(name = "inten_id")
@SequenceGenerator(name = "AVB_INTENT_DASHBOARD_GENERATOR", sequenceName = "AVB_INTENT_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "AVB_INTENT_DASHBOARD_GENERATOR")
private Long id;
@Column(name = "inten_ident")
private String identifier;
@Column(name = "intent_is_sensible")
private String sensible;
@Column(name = "agen_id")
private Long agenId;
}
package com.bytesw.bytebot.etl.model;
import com.bytesw.bytebot.etl.converter.MessageTypeConverter;
import com.bytesw.bytebot.etl.enums.MessageTypeEnum;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.math.BigDecimal;
import java.time.OffsetDateTime;
@Cacheable(false)
@Entity
@Getter @Setter @ToString @Builder
@Table(name="avb_message")
@NamedQuery(name = "Message.findByPK", query = "Select p from Message p where p.id = ?1")
public class Message {
@Id
@Column(name = "messa_id")
@SequenceGenerator(name = "AVB_MESSAGE_GENERATOR", sequenceName = "AVB_MESSAGE_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "AVB_MESSAGE_GENERATOR")
private Long id;
@Column(name = "session_id")
private Long sessionId;
@Column(name = "messa_date")
private OffsetDateTime date;
@Column(name = "messa_cont")
private String content;
@Column(name = "messa_corre")
private int correlative;
@Column(name = "messa_prob")
private BigDecimal probability;
@Convert(converter = MessageTypeConverter.class)
@Column(name = "messa_type")
private MessageTypeEnum type;
@Column(name = "inten_id")
private Long intentId;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment