Commit 2475de3e authored by Roberto Loayza Miljanovich's avatar Roberto Loayza Miljanovich

Merge branch 'dev_marcos' into 'developer'

Merge To Developer

See merge request ByteBot/web/bytebot-service!12
parents fff3f7b6 1aaa0bc6
......@@ -240,6 +240,12 @@
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.twilio.sdk/twilio -->
<dependency>
<groupId>com.twilio.sdk</groupId>
<artifactId>twilio</artifactId>
<version>8.22.0</version>
</dependency>
</dependencies>
<build>
......
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.io.Serializable;
import java.util.List;
@Getter
@Setter
public class CalendarBean implements Serializable {
@Expose
private String id;
@Expose
private long version;
@Expose
private String name;
//@TODO: Revisar List<WeekScheduler> weekSchedulerList de la clase Calendar
@Expose
private List<WeekSchedulerBean> weekSchedulerBeanList;
@Expose
private List<CalendarExceptionBean> calendarExceptionBeanList;
}
\ No newline at end of file
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;
}
......@@ -35,6 +35,7 @@ public class CountryBean {
@Expose
private List<String> timezones;
public static CountryBean clone(Country country) {
CountryBean bean = new CountryBean();
......
......@@ -30,4 +30,10 @@ public class DeploymentChannelParamValueBean {
@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 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 com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigInteger;
@Getter
@Setter
public class SchedulerTaskBean implements Serializable {
@Expose
private BigInteger id;
@Expose
private long version;
@Expose
private String description;
@Expose
private String internals;
@Expose
private String cronExpression;
@Expose
private String stringParameters;
@Expose
private String calendarID;
@Expose
private String calendarName;
// @Expose
// private int idEtl;
}
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;
}
......@@ -7,6 +7,7 @@ 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
......@@ -14,11 +15,7 @@ public class SummaryBean implements Serializable {
@Expose
private BigInteger value;
@Expose
private List<BigInteger> history;
@Expose
private BigDecimal percent;
@Expose
private boolean up = false;
@Expose
private boolean down = false;
private List<ArrayList<Object>> history;
}
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 OffsetDateTime from;
@Expose
private OffsetDateTime to;
@Expose
private String calendarID;
@Expose
private String calendarName;
}
......@@ -7,14 +7,12 @@ import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.service.AgentService;
import com.bytesw.bytebot.service.FileManagementService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.multitenant.core.ThreadLocalStorage;
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.time.LocalDate;
import java.util.UUID;
import lombok.extern.log4j.Log4j2;
......
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.create(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("/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.AgentBean;
import com.bytesw.bytebot.bean.SummaryMessageBySentenceBean;
import com.bytesw.bytebot.service.dashboard.CustomerInteractionDashboardService;
import com.bytesw.bytebot.service.dashboard.OperativeDashboardService;
......
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.etl.beans.GoalBean;
import com.bytesw.bytebot.service.GoalService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import com.google.gson.GsonBuilder;
import io.swagger.annotations.ApiParam;
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 java.util.Map;
@RestController()
@RequestMapping("/service/settings/goal")
@ProgramSecurity("GOAL")
@Log4j2
public class GoalController extends XDFController<GoalBean, Long> {
@Autowired
private GoalService goalService;
@Autowired
private GsonBuilder gsonBuilder;
public GoalController(GoalService service) {
super(service);
}
@PostMapping(value = "/goalForAction")
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> createGoalForAction(@RequestBody Map<String, Object> body) {
GoalBean info = goalService.saveGoalForAction(body);
return new ResponseEntity(gson.toJson(info), HttpStatus.OK);
}
@DeleteMapping(value = "/goalForAction/{id}")
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> GoalForAction(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) {
String info = "";
try{
goalService.deleteGoalForAction(id);
info = id.toString();
return new ResponseEntity(gson.toJson(info), HttpStatus.OK);
} catch (Exception e) {
info = e.getMessage();
}
return new ResponseEntity(gson.toJson(info), HttpStatus.INTERNAL_SERVER_ERROR);
}
@PutMapping(value = "/goalForAction/{id}")
@PreAuthorize("hasPermission(this, 'edit')")
public ResponseEntity<String> updateConversationalAgent(@PathVariable("id") Long id,
@RequestBody Map<String, Object> body) {
String info = "";
try{
goalService.updateGoalForActions(body, id);
return new ResponseEntity(gson.toJson(info), HttpStatus.OK);
} catch (Exception e) {
info = e.getMessage();
}
return new ResponseEntity(gson.toJson(info), HttpStatus.INTERNAL_SERVER_ERROR);
}
@GetMapping(value = "/goalForAction/{id}")
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> getActionByGoalId(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) {
HttpStatus hs = HttpStatus.OK;
try {
return new ResponseEntity<>(gsonBuilder.create().toJson(goalService.getGoalForActions(id)), hs);
} catch (Exception e) {
String info = "Error detectado al obtener informacion";
hs = HttpStatus.INTERNAL_SERVER_ERROR;
return new ResponseEntity<>(gsonBuilder.create().toJson(info), hs);
}
}
@GetMapping(value = "/goalForAction/")
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> getActionByGoalIdAll() {
HttpStatus hs = HttpStatus.OK;
try {
return new ResponseEntity<>(gsonBuilder.create().toJson(goalService.getGoalForActionsAll()), 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.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.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/scheduler-task")
@ProgramSecurity("scheduler")
@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.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.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;
......@@ -20,11 +21,14 @@ import java.util.Map;
* -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<>();
......@@ -61,5 +65,4 @@ public class DataBaseItemReaderFactory implements ItemReaderFactory<DynaBean, Ro
return dataSource;
}
}
......@@ -3,11 +3,9 @@ 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 lombok.extern.log4j.Log4j2;
import org.springframework.batch.item.ItemProcessor;
@Log4j2
public class ConvertToBeanProcessor implements ItemProcessor<DynaBean, DynaBean> {
public class ConvertToBeanProcessor implements ItemProcessor<DynaBean, DynaBean> {
private ObjectMapper mapper = new ObjectMapper();
......
......@@ -19,7 +19,8 @@ import java.util.List;
@Log4j2
public class ByteBotJPAWriter implements ItemWriter<DynaBean>, StepExecutionListener {
@Getter @Setter
@Getter
@Setter
private ProcessMessageService service;
@Override
......
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(), "$.telefonos_desplegados");
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);
}
}
}
}
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 com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class ActionBean {
@Expose
private Long id;
@Expose
private String ident;
}
package com.bytesw.bytebot.etl.beans;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class GoalBean {
@Expose
private Long id;
@Expose
private String identifier;
@Expose
private Long agenId;
}
\ No newline at end of file
package com.bytesw.bytebot.etl.beans;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class GoalForActionsBean {
@Expose
private Long id;
@Expose
private Long goalId;
@Expose
private Long actionId;
}
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.dao;
import com.bytesw.bytebot.etl.model.Action;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.util.Optional;
......
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.ETLChannel;
import org.springframework.data.repository.CrudRepository;
import java.util.Optional;
public interface ETLChannelRepository extends CrudRepository<ETLChannel, Long> {
import com.bytesw.bytebot.etl.model.DeleteDataSensibleLog;
import org.springframework.data.repository.CrudRepository;
Optional<ETLChannel> findByIdentifier(String identifier);
public interface DeleteDataSensibleLogRepository extends CrudRepository<DeleteDataSensibleLog, Long> {
}
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.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.model;
import com.bytesw.xdf.model.converter.BooleanToStringConverter;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
......@@ -9,26 +8,21 @@ import javax.persistence.*;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="BBOT_ACTION")
@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")
@TableGenerator(name = "BBOT_ACTION_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_ACTION_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_ACTION_GENERATOR")
@Column(name = "action_id")
@TableGenerator(name = "AVB_ACTION_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_ACTION_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_ACTION_GENERATOR")
private Long id;
@Column(name = "ACTION_IDENT")
@Column(name = "action_ident")
private String identifier;
@ManyToOne(optional = false)
@JoinColumn(name = "GOAL_ID", referencedColumnName = "GOAL_ID")
private Goal goal;
@Column(name = "ACTION_RGOAL")
@Convert(converter = BooleanToStringConverter.class)
private boolean meetGoal;
}
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")
@TableGenerator(name = "AVB_DELETE_MSG_SENS_CONTROL_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_DELETE_MSG_SENS_CONTROL_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,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")
@TableGenerator(name = "AVB_DELETE_MSG_SENS_LOG_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_DELETE_MSG_SENS_LOG_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,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.*;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="BBOT_CHANNEL_DASHBOARD")
@NamedQuery(name = "ETLChannel.findByPK", query = "Select p from ETLChannel p where p.id = ?1")
public class ETLChannel {
@Id
@Column(name = "CHANN_ID")
@TableGenerator(name = "BBOT_CHANNEL_DASHBOARD_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_CHANNEL_DASHBOARD_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_CHANNEL_DASHBOARD_GENERATOR")
private Long id;
@Column(name = "CHANN_IDENT")
private String identifier;
}
......@@ -10,23 +10,23 @@ import java.time.OffsetDateTime;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="BBOT_EVENT_HISTORY")
@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")
@TableGenerator(name = "BBOT_EVENT_HISTORY_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_EVENT_HISTORY_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_EVENT_HISTORY_GENERATOR")
@Column(name = "evenh_id")
@TableGenerator(name = "AVB_EVENT_HISTORY_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_EVENT_HISTORY_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "AVB_EVENT_HISTORY_GENERATOR")
private Long id;
@Column(name = "EVENH_SENDID")
@Column(name = "evenh_sendid")
private String senderId;
@Column(name = "EVENH_EVID")
@Column(name = "evenh_evid")
private Long eventId;
@Column(name = "EVENH_DATE")
@Column(name = "evenh_date")
private OffsetDateTime date;
}
......@@ -9,17 +9,20 @@ import javax.persistence.*;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="BBOT_GOAL")
@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")
@TableGenerator(name = "BBOT_GOAL_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_GOAL_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_GOAL_GENERATOR")
@Column(name = "goal_id")
@TableGenerator(name = "AVB_GOAL_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_GOAL_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "AVB_GOAL_GENERATOR")
private Long id;
@Column(name = "GOAL_IDENT")
@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")
@TableGenerator(name = "AVB_GOALFORACTIONS_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_GOALFORACTIONS_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_GOALFORACTIONS_GENERATOR")
private Long id;
@Column(name = "goal_id")
private Long goalId;
@Column(name = "action_id")
private Long actionId;
}
......@@ -6,21 +6,27 @@ import lombok.ToString;
import javax.persistence.*;
//BBOT_INTENT
//AVB_INTENT
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="BBOT_INTENT")
@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")
@TableGenerator(name = "BBOT_INTENT_DASHBOARD_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_INTENT_DASHBOARD_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_INTENT_DASHBOARD_GENERATOR")
@Column(name = "inten_id")
@TableGenerator(name = "AVB_INTENT_DASHBOARD_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_INTENT_DASHBOARD_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "AVB_INTENT_DASHBOARD_GENERATOR")
private Long id;
@Column(name = "INTEN_IDENT")
@Column(name = "inten_ident")
private String identifier;
@Column(name = "intent_is_sensible")
private String sensible;
@Column(name = "agen_id")
private Long agenId;
}
......@@ -14,36 +14,36 @@ import java.time.OffsetDateTime;
@Cacheable(false)
@Entity
@Getter @Setter @ToString @Builder
@Table(name="BBOT_MESSAGE")
@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")
@TableGenerator(name = "BBOT_MESSAGE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_MESSAGE_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_MESSAGE_GENERATOR")
@Column(name = "messa_id")
@TableGenerator(name = "AVB_MESSAGE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_MESSAGE_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "AVB_MESSAGE_GENERATOR")
private Long id;
@Column(name = "SESSION_ID")
@Column(name = "session_id")
private Long sessionId;
@Column(name = "MESSA_DATE")
@Column(name = "messa_date")
private OffsetDateTime date;
@Column(name = "MESSA_CONT")
@Column(name = "messa_cont")
private String content;
@Column(name = "MESSA_CORRE")
@Column(name = "messa_corre")
private int correlative;
@Column(name = "MESSA_PROB")
@Column(name = "messa_prob")
private BigDecimal probability;
@Convert(converter = MessageTypeConverter.class)
@Column(name = "MESSA_TYPE")
@Column(name = "messa_type")
private MessageTypeEnum type;
@Column(name = "INTEN_ID")
@Column(name = "inten_id")
private Long intentId;
}
......@@ -10,26 +10,26 @@ import java.time.OffsetDateTime;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="BBOT_RESPONSE")
@Table(name="avb_response")
@NamedQuery(name = "Response.findByPK", query = "Select p from Response p where p.id = ?1")
public class Response {
@Id
@Column(name = "RESPO_ID")
@TableGenerator(name = "BBOT_RESPONSE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_RESPONSE_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_RESPONSE_GENERATOR")
@Column(name = "respo_id")
@TableGenerator(name = "AVB_RESPONSE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_RESPONSE_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "AVB_RESPONSE_GENERATOR")
private Long id;
@Column(name = "RESPO_DATE")
@Column(name = "respo_date")
private OffsetDateTime date;
@Column(name = "RESPO_CONT")
@Column(name = "respo_cont")
private String content;
@Column(name = "RESPO_CORR")
@Column(name = "respo_corr")
private int correlative;
@Column(name = "SESSION_ID")
@Column(name = "session_id")
private Long sessionId;
}
package com.bytesw.bytebot.etl.model;
import com.bytesw.bytebot.model.Channel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
......@@ -10,31 +11,31 @@ import java.time.OffsetDateTime;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="BBOT_SESSION")
@Table(name="avb_session")
@NamedQuery(name = "Session.findByPK", query = "Select p from Session p where p.id = ?1")
public class Session {
@Id
@Column(name = "SESSION_ID")
@TableGenerator(name = "BBOT_SESSION_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_SESSION_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_SESSION_GENERATOR")
@Column(name = "session_id")
@TableGenerator(name = "AVB_SESSION_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_SESSION_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "AVB_SESSION_GENERATOR")
private Long id;
@Column(name = "SESSION_DATE", nullable = false)
@Column(name = "session_date", nullable = false)
private OffsetDateTime sessionDate;
@Column(name = "SESSION_LEDAT", nullable = false)
@Column(name = "session_ledat", nullable = false)
private OffsetDateTime lastEventDate;
@Column(name = "SESSION_FRDAT", nullable = false)
@Column(name = "session_frdat", nullable = false)
private OffsetDateTime responseDate;
@ManyToOne
@JoinColumn(name = "CHANN_ID", referencedColumnName = "CHANN_ID")
private ETLChannel channel;
@JoinColumn(name = "chan_id", referencedColumnName = "chan_id")
private Channel channel;
@ManyToOne(optional = false)
@JoinColumn(name = "USER_ID", referencedColumnName = "USER_ID")
@JoinColumn(name = "user_id", referencedColumnName = "user_id")
private User user;
}
......@@ -10,24 +10,24 @@ import java.time.OffsetDateTime;
@Cacheable(false)
@Entity
@Getter @Setter @ToString
@Table(name="BBOT_ACTION_SESSION")
@Table(name="avb_action_session")
@NamedQuery(name = "SessionAction.findByPK", query = "Select p from SessionAction p where p.id = ?1")
public class SessionAction {
@Id
@Column(name = "ASESS_ID")
@TableGenerator(name = "BBOT_ACTION_SESSION_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_ACTION_SESSION_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_ACTION_SESSION_GENERATOR")
@Column(name = "asess_id")
@TableGenerator(name = "AVB_ACTION_SESSION_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_ACTION_SESSION_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "AVB_ACTION_SESSION_GENERATOR")
private Long id;
@ManyToOne(optional = false)
@JoinColumn(name = "ACTION_ID", referencedColumnName = "ACTION_ID")
@JoinColumn(name = "action_id", referencedColumnName = "action_id")
private Action action;
@Column(name = "ASESS_DATE")
@Column(name = "asess_date")
private OffsetDateTime date;
@Column(name = "SESSION_ID")
@Column(name = "session_id")
private Long sessionId;
}
......@@ -8,17 +8,17 @@ import javax.persistence.*;
@Cacheable(false)
@Entity @Getter @Setter @ToString
@Table(name="BBOT_USER")
@Table(name="avb_user")
@NamedQuery(name = "User.findByPK", query = "Select p from User p where p.id = ?1")
public class User {
@Id
@Column(name = "USER_ID")
@TableGenerator(name = "BBOT_USER_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_USER_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "BBOT_USER_GENERATOR")
@Column(name = "user_id")
@TableGenerator(name = "AVB_USER_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_USER_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "AVB_USER_GENERATOR")
private Long id;
@Column(name = "USER_IDENT")
@Column(name = "user_ident")
private String identifier;
}
package com.bytesw.bytebot.etl.services;
import com.bytesw.bytebot.etl.batch.beans.DeleteDataSensRegistryBean;
import com.bytesw.bytebot.etl.dao.DeleteDataSensibleControlRepository;
import com.bytesw.bytebot.service.provider.TwilioService;
import com.bytesw.xdf.exception.NotFoundException;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Log4j2
public class DeleteSensMessageService {
@Autowired
private TwilioService twilioService;
@Autowired
DeleteDataSensibleControlRepository deleteDataSensibleControlRepository;
public List<DeleteDataSensRegistryBean> deleteMessage(Long agentId, String SmsMessage, Long inten_id, String sender_id) throws Exception {
List<DeleteDataSensRegistryBean> deleteMessages = new ArrayList<DeleteDataSensRegistryBean>();
Map<String, Object> data = new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("agent_id", agentId.intValue());
try {
Map<String, Object> result = new HashMap<>();
data = twilioService.generateInfo(SmsMessage, params);
if (data.isEmpty()) {
throw new Exception("Parámetros vacíos");
}
DeleteDataSensRegistryBean registry = new DeleteDataSensRegistryBean();
if (data.get("status") != null) {
List<String> images = new ArrayList<String>();
images = (List<String>) data.get("data");
for (String image : images) {
if (image.trim().isEmpty()) {
continue;
}
// Info del Bean
registry.setMultimedia_sid(image);
registry.setMessage_sid(SmsMessage);
registry.setUpdate_time(OffsetDateTime.now());
registry.setInten_id(inten_id);
registry.setSender_id(sender_id);
// Agregado a la lista
deleteMessages.add(registry);
}
}
return deleteMessages;
} catch (NotFoundException e) {
log.debug(e);
throw new NotFoundException(e.getMessage());
} catch (Exception e) {
log.debug(e);
throw new Exception(e.getMessage());
}
}
}
......@@ -2,6 +2,7 @@ package com.bytesw.bytebot.etl.services;
import com.bytesw.bytebot.etl.dao.SessionBotRepository;
import com.bytesw.bytebot.etl.model.Session;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
......@@ -14,6 +15,7 @@ import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Log4j2
public abstract class MessageProcessedSupport {
protected static final String SENDER_ID_FIELD_NAME = "senderId";
......@@ -43,15 +45,13 @@ public abstract class MessageProcessedSupport {
}
dateDecimal = new BigDecimal(String.valueOf(objectTimestamp));
}
Long timestamp = dateDecimal.longValue();
Long timestamp = (long) (dateDecimal.doubleValue() * 1000);
if (String.valueOf(timestamp).length() < 13) {
int numberOfZero = 13 - String.valueOf(timestamp).length();
for (int i = 0; i < numberOfZero; i++) {
timestamp = timestamp * 10;
}
}
OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
return date;
}
......
package com.bytesw.bytebot.etl.services;
import com.bytesw.bytebot.etl.beans.ProcessMessageResult;
import com.bytesw.bytebot.etl.dao.DeleteDataSensibleControlRepository;
import com.bytesw.bytebot.etl.dao.EventHistoryRepository;
import com.bytesw.bytebot.etl.enums.EventTypeEnum;
import com.bytesw.bytebot.etl.model.EventHistory;
......@@ -19,18 +20,20 @@ public class ProcessMessageService {
@Autowired
private EventHistoryRepository eventHistoryRepository;
@Autowired
private DeleteDataSensibleControlRepository deleteDataSensibleControlRepository;
public void saveHistory(Long id, String senderId) {
EventHistory eventHistory = new EventHistory();
eventHistory.setDate(OffsetDateTime.now());
eventHistory.setEventId(id);
eventHistory.setSenderId(senderId);
eventHistoryRepository.save(eventHistory);
}
public ProcessMessageResult processMessage(String json, String senderId) throws Exception {
ProcessMessageResult result = new ProcessMessageResult();
log.debug(json);
MessageProcessed messageProcessed = detectType(json);
if (messageProcessed == null) {
result.setProcessed(false);
......@@ -50,6 +53,14 @@ public class ProcessMessageService {
String name = (String) JsonUtils.getFieldFromJson(json, "$.name");
type = EventTypeEnum.fromString(event);
if (type != null) {
// Verify if message is valid
if (EventTypeEnum.USER.equals(type)) {
String message_id = (String) JsonUtils.getFieldFromJson(json, "$.message_id");
if (message_id == null) {
return null;
}
}
if (EventTypeEnum.ACTION.equals(type) && EventTypeEnum.START_SESSION.getName().equals(name)) {
type = EventTypeEnum.START_SESSION;
}
......@@ -60,7 +71,6 @@ public class ProcessMessageService {
} catch (Exception e) {
log.debug(e);
}
return messageProcessed;
}
......
......@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.transaction.Transactional;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
@Service
......@@ -43,6 +44,8 @@ public class StartSessionMessageProcessed extends MessageProcessedSupport implem
Double timestamp = (Double) JsonUtils.getFieldFromJson(json, this.fields.get(TIMESTAMP_FIELD_NAME));
if (timestamp != null) {
// Validate if the below method is ok
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSX");
OffsetDateTime sessionDate = getOffsetDateTimeFromTimestampPython(timestamp);
if (sessionDate != null) {
Session session = new Session();
......
package com.bytesw.bytebot.etl.services;
import com.bytesw.bytebot.etl.batch.beans.DeleteDataSensBean;
import com.bytesw.bytebot.etl.beans.SessionBean;
import com.bytesw.bytebot.etl.dao.ETLChannelRepository;
import com.bytesw.bytebot.etl.dao.IntentRepository;
import com.bytesw.bytebot.etl.dao.MessageRepository;
import com.bytesw.bytebot.etl.dao.UserRepository;
import com.bytesw.bytebot.etl.enums.MessageTypeEnum;
import com.bytesw.bytebot.etl.jdbc.ETLMessageJDBCRepository;
import com.bytesw.bytebot.etl.jdbc.ETLSessionBotJDBCRepository;
import com.bytesw.bytebot.etl.model.*;
import com.bytesw.bytebot.etl.model.Intent;
import com.bytesw.bytebot.etl.model.Message;
import com.bytesw.bytebot.etl.model.Session;
import com.bytesw.bytebot.etl.model.User;
import com.bytesw.bytebot.etl.utils.JsonUtils;
import com.bytesw.bytebot.jdbc.DeleteDataSensJDBCRepository;
import com.bytesw.bytebot.model.Channel;
import com.bytesw.bytebot.model.enums.AgentParameterEnum;
import com.bytesw.bytebot.model.enums.AgentStatusEnum;
import com.bytesw.bytebot.repository.ChannelRepository;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -18,8 +27,12 @@ import javax.annotation.PostConstruct;
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Log4j2
@Service
@Transactional
public class UserMessageProcessed extends MessageProcessedSupport implements MessageProcessed {
......@@ -31,7 +44,7 @@ public class UserMessageProcessed extends MessageProcessedSupport implements Mes
private ETLMessageJDBCRepository messageJDBCRepository;
@Autowired
private ETLChannelRepository channelRepository;
private ChannelRepository chanelRepository;
@Autowired
private UserRepository userRepository;
......@@ -42,6 +55,9 @@ public class UserMessageProcessed extends MessageProcessedSupport implements Mes
@Autowired
private IntentRepository intentRepository;
@Autowired
private DeleteDataSensJDBCRepository deleteDataSensJDBCRepository;
@Value("${application.etl.text-user.threshold:0.5}")
private BigDecimal threshold;
......@@ -63,26 +79,27 @@ public class UserMessageProcessed extends MessageProcessedSupport implements Mes
if (!userFound.isPresent()) {
return false;
}
SessionBean session = sessionBotJDBCRepository.getLastSessionByUser(userFound.get().getId());
if (session != null) {
Message message = cloneMessage(json, session.getId());
if (message != null) {
int correlative = messageJDBCRepository.getLastCorrelativeBySession(message.getSessionId());
correlative++;
message.setCorrelative(correlative);
messageRepository.save(message);
String channel = (String) JsonUtils.getFieldFromJson(json, this.fields.get(CHANNEL_FIELD_NAME));
updateSession(session.getId(), message.getDate(), channel);
return true;
/* ID del agente */
Long agentId = identifierAgent(json);
if (agentId >= 1) {
Message message = cloneMessage(json, session.getId(), agentId);
if (message != null) {
int correlative = messageJDBCRepository.getLastCorrelativeBySession(message.getSessionId());
correlative++;
message.setCorrelative(correlative);
messageRepository.save(message);
String channel = (String) JsonUtils.getFieldFromJson(json, this.fields.get(CHANNEL_FIELD_NAME));
updateSession(session.getId(), message.getDate(), channel);
return true;
}
}
}
}
return false;
}
......@@ -92,17 +109,16 @@ public class UserMessageProcessed extends MessageProcessedSupport implements Mes
Session session = sessionFond.get();
session.setLastEventDate(date);
if (channelIdentifier != null && session.getChannel() == null) {
Optional<ETLChannel> channelFound = channelRepository.findByIdentifier(channelIdentifier);
Optional<Channel> channelFound = chanelRepository.findByName(channelIdentifier);
if (channelFound.isPresent()) {
session.setChannel(channelFound.get());
}
}
sessionBotRepository.save(session);
}
}
private Message cloneMessage(String json, Long sessionId) {
private Message cloneMessage(String json, Long sessionId, Long agentId) {
Double timestamp = (Double) JsonUtils.getFieldFromJson(json, this.fields.get(TIMESTAMP_FIELD_NAME));
Object confidence = JsonUtils.getFieldFromJson(json, this.fields.get(CONFIDENCE_FIELD_NAME));
String content = (String) JsonUtils.getFieldFromJson(json, this.fields.get(CONTENT_FIELD_NAME));
......@@ -131,11 +147,44 @@ public class UserMessageProcessed extends MessageProcessedSupport implements Mes
if (MessageTypeEnum.ACCEPTED.equals(message.getType())) {
String intentName = (String) JsonUtils.getFieldFromJson(json, this.fields.get(INTENT_NAME));
Optional<Intent> optionalIntent = intentRepository.findByIdentifier(intentName);
Optional<Intent> optionalIntent = intentRepository.findIntenNameById(intentName, agentId);
if (optionalIntent.isPresent()) {
message.setIntentId(optionalIntent.get().getId());
}
}
return message;
}
//-------
private Long identifierAgent(String json){
Long agentId = 0l;
String number= (String) JsonUtils.getFieldFromJson(json, "$.metadata.To");
if (number != null) {
number = number.split(":")[1];
List<DeleteDataSensBean> deleteDataSensBeans = deleteDataSensJDBCRepository
.getListAgentChannel(AgentStatusEnum.DEPLOYED.getName(), AgentParameterEnum.ACCESS_TWILIO.getName());
for (DeleteDataSensBean deleteDataSensBean: deleteDataSensBeans) {
Object numeros = JsonUtils.getFieldFromJson(deleteDataSensBean.getChannelValue(), "$.telefonos_desplegados");
List<String> numerosAgentes = numbersAgent((List<Map>) numeros);
if (numerosAgentes.contains(number)) {
agentId = deleteDataSensBean.getAgenId();
break;
}
}
}
return agentId;
}
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;
}
//------
}
package com.bytesw.bytebot.jdbc;
import com.bytesw.bytebot.bean.DeploymentChannelParamValueBean;
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.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class AgentJDBCRepository {
@Autowired
@Qualifier("sqlSessionFactory")
private SqlSessionFactory sqlsession;
@Cacheable(value = "deploy_agents")
public List<DeploymentChannelParamValueBean> getCredentialsFromAgentStatus(String status) {
SqlSession session = sqlsession.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("status", status);
return session.selectList("com.bytesw.bytebot.dao.jdbc.AgentMapper.getCredentialsFromAgentandChannel", params);
} finally {
session.close();
}
}
}
......@@ -5,11 +5,13 @@ 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 com.bytesw.bytebot.bean.SessionByClientBean;
import java.sql.Timestamp;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
@Component
public class BotSessionJDCBRepository {
......
package com.bytesw.bytebot.jdbc;
import com.bytesw.bytebot.etl.batch.beans.DeleteDataSensBean;
import com.bytesw.bytebot.etl.batch.beans.DeleteDataSensControlBean;
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.List;
import java.util.Map;
@Component
public class DeleteDataSensJDBCRepository {
@Autowired
@Qualifier("sqlSessionFactory")
private SqlSessionFactory sqlSessionFactory;
public List<DeleteDataSensBean> getListAgentChannel(String status, String channel){
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("status", status);
params.put("channel", channel);
return session.selectList("com.bytesw.bytebot.dao.jdbc.ETLDataSensibleMapper.getAgentChannel", params);
} finally {
session.close();
}
}
public DeleteDataSensControlBean getControl(Long id){
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("agenId", id);
return session.selectOne("com.bytesw.bytebot.dao.jdbc.ETLDataSensibleMapper.getControl", params);
} finally {
session.close();
}
}
public List<String> getIntentByAgent(String sensible, Long id){
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("sensible", sensible);
params.put("agenId", id);
return session.selectList("com.bytesw.bytebot.dao.jdbc.ETLDataSensibleMapper.getIntentByAgent", params);
} finally {
session.close();
}
}
}
......@@ -67,8 +67,6 @@ public class MessageJDBCRepository {
params.put("directionSort", "DESC");
}
completeDates(params, pagination.getFilterExpression());
//params.put("startDate", startDate);
//params.put("endDate", endDate);
return session.selectList("com.bytesw.bytebot.dao.jdbc.MessageMapper.getSummaryByIntentAndSentence", params);
} finally {
session.close();
......
......@@ -9,55 +9,60 @@ import com.bytesw.bytebot.model.enums.AgentTypeEnum;
import com.bytesw.bytebot.model.enums.LanguageEnum;
import com.bytesw.bytebot.model.enums.StatusEnum;
import lombok.*;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
@Entity
@Getter @Setter @ToString @EqualsAndHashCode(of = "id")
@Getter @Setter @EqualsAndHashCode(of = "id")
@NoArgsConstructor
@Table(name = "BBOT_AGENT")
@Table(name = "avb_agent")
@NamedQuery(name = "Agent.findByPK", query = "Select u from Agent u where u.id = ?1")
public class Agent implements Serializable {
@Id
@Column(name = "AGEN_ID")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_AGENT_GENERATOR")
@TableGenerator(name = "BBOT_AGENT_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "BBOT_AGENT_SEQ", allocationSize = 1)
@Column(name = "agen_id")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_AGENT_GENERATOR")
@TableGenerator(name = "AVB_AGENT_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "AVB_AGENT_SEQ", allocationSize = 1)
private Long id;
@Column(name = "AGEN_IDEN")
@Column(name = "agen_iden")
private String name;
@Column(name = "AGEN_DESCR")
@Column(name = "agen_descr")
private String description;
@Column(name = "AGEN_VERS")
@Column(name = "agen_vers")
private String version;
@Column(name = "AGEN_LANG")
@Column(name = "agen_lang")
@Convert(converter = LanguageConverter.class)
private LanguageEnum language;
@Column(name = "AGEN_TZONE")
@Column(name = "agen_tzone")
private String timezone;
@Column(name = "agen_delete_sensible_period")
private String period;
@Lob
@Type(type = "org.hibernate.type.TextType")
@Basic(fetch = FetchType.LAZY)
@Column(name = "AGEN_AVAT")
@Column(name = "agen_avat")
private String avatar;
@ManyToOne
@JoinColumn(name = "COUN_ID", referencedColumnName = "COUN_ID")
@JoinColumn(name = "coun_id", referencedColumnName = "coun_id")
private Country country;
@Column(name = "AGEN_STATE")
@Column(name = "agen_state")
@Convert(converter = AgentStatusConverter.class)
private AgentStatusEnum status;
@Column(name = "AGEN_TYPE")
@Column(name = "agen_type")
@Convert(converter = AgentTypeConverter.class)
private AgentTypeEnum type;
......
package com.bytesw.bytebot.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
//@Audited
@Entity
@DiscriminatorValue(value=AnnualCalendarException.DISCRIMINATOR_VALUE)
@NamedQuery(name = "AnnualCalendarException.findByPK", query = "Select u from AnnualCalendarException u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString
public class AnnualCalendarException extends CalendarException {
public static final String DISCRIMINATOR_VALUE = "Y";
@Column(name = "CALE_EXC_MONTH", nullable = false)
private int month;
@Column(name = "CALE_EXC_DAYMO", nullable = false)
private int dayOfMonth;
}
package com.bytesw.bytebot.model;
import com.bytesw.xdf.model.converter.BooleanToStringConverter;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;
@Audited
@Entity
@Table(name = "AVB_BUSINESS_PARAMETER")
@NamedQuery(name = "BusinessParameter.findByPK", query = "Select u from BusinessParameter u where u.id = ?1")
@Getter @Setter @EqualsAndHashCode @ToString(exclude = "id")
public class BusinessParameter implements Serializable {
@Id
@Column(name = "BUPA_ID")
@SequenceGenerator(name = "AVB_BUSINESS_PARAMETER_GENERATOR", sequenceName = "AVB_BUSINESS_PARAMETER_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_BUSINESS_PARAMETER_GENERATOR")
private BigInteger id;
@Version
@Column(name = "VERSION")
@Basic(optional = false)
private long version;
@Column(name = "BUPA_KEY", nullable = false, unique = true)
private String key;
@Column(name = "BUPA_DESCR", nullable = false)
private String description;
@Column(name = "BUPA_REQUI", nullable = false)
@Convert(converter = BooleanToStringConverter.class)
private Boolean required;
@Column(name = "BUPA_DEFVA")
private String defaultValue;
}
package com.bytesw.bytebot.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.OffsetDateTime;
@Audited
@Entity
@Table(name = "AVB_BUSINESS_PARAMETER_CONFIG")
@NamedQuery(name = "BusinessParameterConfiguration.findByPK", query = "Select u from BusinessParameterConfiguration u where u.id = ?1")
@Getter @Setter @EqualsAndHashCode @ToString(exclude = "id")
public class BusinessParameterConfiguration implements Serializable, Comparable<BusinessParameterConfiguration> {
@Id
@Column(name = "BUPC_ID")
@SequenceGenerator(name = "AVB_BUSINESS_PARAMETER_CONFIG_GENERATOR", sequenceName = "AVB_BUSINESS_PARAM_CONFIG_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_BUSINESS_PARAMETER_CONFIG_GENERATOR")
private BigInteger id;
@Version
@Column(name = "VERSION")
@Basic(optional = false)
private long version;
@Column(name = "BUPC_FROM", nullable = false)
private OffsetDateTime from;
@Column(name = "BUPC_TO")
private OffsetDateTime to;
@Column(name = "BUPC_VALUE", nullable = false)
private String value;
@ManyToOne(optional = false)
@JoinColumn(name = "BUPA_ID", referencedColumnName = "BUPA_ID", nullable = false)
private BusinessParameter businessParameter;
@Override
public int compareTo(BusinessParameterConfiguration o) {
return from.compareTo(o.getFrom());
}
}
package com.bytesw.bytebot.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
//@Audited
@Entity
@Table(name = "AVB_CALENDAR")
@NamedQuery(name = "Calendar.findByPK", query = "Select u from Calendar u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString(exclude = "id")
public class Calendar implements Serializable {
@Id
@Column(name = "cale_id")
private String id;
@Version
@Column(name = "cale_version")
@Basic(optional = false)
private long version;
@Column(name = "cale_name", nullable = false)
private String name;
@OneToMany(mappedBy = "calendar")
private List<WeekScheduler> weekSchedulerList;
}
package com.bytesw.bytebot.model;
import com.bytesw.bytebot.model.converters.CalendarExceptionTypeConverter;
import com.bytesw.bytebot.model.converters.FrequencyTypeConverter;
import com.bytesw.bytebot.model.enums.CalendarExceptionType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;
//@Audited
@Entity
@Inheritance(
strategy = InheritanceType.SINGLE_TABLE
)
@DiscriminatorColumn(name="CALE_EXC_FRECU", discriminatorType = DiscriminatorType.STRING)
@Table(name = "AVB_CALENDAR_EXCEPTION")
@Getter
@Setter
@EqualsAndHashCode
@ToString(exclude = "id")
public abstract class CalendarException implements Serializable {
@Id
@Column(name = "CALE_EXC_ID")
// @SequenceGenerator(name = "AVB_CALENDAR_EXCEPTION_GENERATOR", sequenceName = "AVB_CALENDAR_EXCEPTION_SEQ", initialValue = 1, allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_CALENDAR_EXCEPTION_GENERATOR")
private BigInteger id;
@Version
@Column(name = "CALE_EXC_VERSION")
@Basic(optional = false)
private long version;
@Column(name = "CALE_EXC_TYPE")
@Convert(converter = CalendarExceptionTypeConverter.class)
private CalendarExceptionType calendarExceptionType;
@Column(name = "CALE_EXC_FRECU", insertable = false, updatable = false)
private String frequencyType;
@Column(name = "CALE_EXC_DESCR")
private String description;
@ManyToOne(optional = false)
@JoinColumn(name = "CALE_ID", referencedColumnName = "CALE_ID", nullable = false)
private Calendar calendar;
}
\ No newline at end of file
package com.bytesw.bytebot.model;
import com.bytesw.bytebot.model.converters.CalendarExceptionTypeConverter;
import com.bytesw.bytebot.model.enums.CalendarExceptionType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
//@Audited
@Entity
@Inheritance(
strategy = InheritanceType.SINGLE_TABLE
)
@DiscriminatorColumn(name="CALE_EXC_FRECU", discriminatorType = DiscriminatorType.STRING)
@Table(name = "AVB_CALENDAR_EXCEPTION")
@Getter
@Setter
@EqualsAndHashCode
@ToString(exclude = "id")
public class CalendarExceptionFull implements Serializable {
@Id
@Column(name = "CALE_EXC_ID")
// @SequenceGenerator(name = "AVB_CALENDAR_EXCEPTION_GENERATOR", sequenceName = "AVB_CALENDAR_EXCEPTION_SEQ", initialValue = 1, allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_CALENDAR_EXCEPTION_GENERATOR")
private BigInteger id;
@Version
@Column(name = "CALE_EXC_VERSION")
@Basic(optional = false)
private long version;
@Column(name = "CALE_EXC_TYPE")
@Convert(converter = CalendarExceptionTypeConverter.class)
private CalendarExceptionType calendarExceptionType;
@Column(name = "CALE_EXC_FRECU", insertable = false, updatable = false)
private String frequencyType;
@Column(name = "CALE_EXC_DESCR")
private String description;
@Column(name = "CALE_ID")
private String calendarID;
// @ManyToOne(optional = false)
// @JoinColumn(name = "CALE_ID", referencedColumnName = "CALE_ID", nullable = false)
// private Calendar calendar;
@Column(name = "CALE_EXC_MONTH")
private BigInteger month;
@Column(name = "CALE_EXC_DAYMO")
private BigInteger dayOfMonth;
@Column(name = "CALE_EXC_WEEK")
private BigInteger weekOfMonth;
@Column(name = "CALE_EXC_DAYWE")
private BigInteger dayOfWeek;
@Column(name = "CALE_EXC_DATE")
private LocalDate date;
@Column(name = "CALE_EXC_FROM")
private OffsetDateTime from;
@Column(name = "CALE_EXC_TO")
private OffsetDateTime to;
}
\ No newline at end of file
......@@ -20,18 +20,16 @@ import java.util.List;
* licencia de uso que firmó con Byte.
*/
@Entity
@Table(name = "BBOT_CHANNEL")
@Getter
@Setter
@ToString
@Table(name = "AVB_CHANNEL")
@Getter @Setter @ToString
@EqualsAndHashCode(of = {"id"}, callSuper = false)
public class Channel {
@Id
@Column(name = "CHAN_ID")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_CHANNEL_GENERATOR")
@TableGenerator(name = "BBOT_CHANNEL_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "BBOT_CHANNEL_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_CHANNEL_GENERATOR")
@TableGenerator(name = "AVB_CHANNEL_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "AVB_CHANNEL_SEQ", allocationSize = 1)
private Long id;
@Column(name = "CHAN_IDEN")
......
......@@ -20,7 +20,7 @@ import javax.persistence.*;
* licencia de uso que firmó con Byte.
*/
@Entity
@Table(name = "BBOT_CHANNEL_PARAM")
@Table(name = "AVB_CHANNEL_PARAM")
@Getter
@Setter
@ToString
......@@ -29,9 +29,9 @@ public class ChannelParam {
@Id
@Column(name = "CHPA_ID")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_CHANNEL_PARAM_GENERATOR")
@TableGenerator(name = "BBOT_CHANNEL_PARAM_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "BBOT_CHANNEL_PARAM_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_CHANNEL_PARAM_GENERATOR")
@TableGenerator(name = "AVB_CHANNEL_PARAM_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "AVB_CHANNEL_PARAM_SEQ", allocationSize = 1)
private Long id;
@Column(name = "CHPA_IDEN")
......
......@@ -9,20 +9,19 @@ import java.util.List;
@Getter
@Setter
@ToString
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
@Table(name = "BBOT_COUNTRY")
@Table(name = "avb_country")
@NamedQuery(name = "Country.findByPK", query = "Select u from Country u where u.id = ?1")
public class Country {
@Id
@Column(name = "COUN_ID")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_COUNTRY_GENERATOR")
@TableGenerator(name = "BBOT_COUNTRY_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "BBOT_COUNTRY_SEQ", allocationSize = 1)
@Column(name = "coun_id")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_COUNTRY_GENERATOR")
@TableGenerator(name = "AVB_COUNTRY_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "AVB_COUNTRY_SEQ", allocationSize = 1)
private Long id;
@Column(name = "COUN_NAME", nullable = false)
@Column(name = "coun_name", nullable = false)
private String name;
@OneToMany(mappedBy = "country")
......
......@@ -22,18 +22,17 @@ import java.util.List;
* licencia de uso que firmó con Byte.
*/
@Entity
@Table(name = "BBOT_DEPLOYMENT_CHANNEL")
@Table(name = "AVB_DEPLOYMENT_CHANNEL")
@Getter
@Setter
@ToString
@EqualsAndHashCode(of = {"id"}, callSuper = false)
public class DeploymentChannel {
@Id
@Column(name = "DCHA_ID")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_DEPLOYMENT_CHANNEL_GENERATOR")
@TableGenerator(name = "BBOT_DEPLOYMENT_CHANNEL_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "BBOT_DEPLOYMENT_CHANNEL_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_DEPLOYMENT_CHANNEL_GENERATOR")
@TableGenerator(name = "AVB_DEPLOYMENT_CHANNEL_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "AVB_DEPLOYMENT_CHANNEL_SEQ", allocationSize = 1)
private Long id;
@Column(name = "DCHA_NAME")
......
......@@ -19,7 +19,7 @@ import javax.persistence.*;
* licencia de uso que firmó con Byte.
*/
@Entity
@Table(name = "BBOT_DEPLOYMENT_CHANNEL_PARAM_VALUE")
@Table(name = "AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE")
@Getter
@Setter
@ToString
......@@ -28,9 +28,9 @@ public class DeploymentChannelParamValue {
@Id
@Column(name = "CHPV_ID")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_DEPLOYMENT_CHANNEL_PARAM_VALUE_GENERATOR")
@TableGenerator(name = "BBOT_DEPLOYMENT_CHANNEL_PARAM_VALUE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "BBOT_DEPLOYMENT_CHANNEL_PARAM_VALUE_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE_GENERATOR")
@TableGenerator(name = "AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE_SEQ", allocationSize = 1)
private Long id;
@ManyToOne
......
......@@ -25,7 +25,7 @@ import java.time.OffsetDateTime;
* licencia de uso que firmó con Byte.
*/
@Entity
@Table(name = "BBOT_FREQUENT_QUESTION")
@Table(name = "AVB_FREQUENT_QUESTION")
@Getter
@Setter
@ToString
......@@ -33,9 +33,9 @@ import java.time.OffsetDateTime;
public class FrequentQuestion {
@Id
@Column(name = "FQUE_ID")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_FREQUENT_QUESTION_GENERATOR")
@TableGenerator(name = "BBOT_FREQUENT_QUESTION_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "BBOT_FREQUENT_QUESTION_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_FREQUENT_QUESTION_GENERATOR")
@TableGenerator(name = "AVB_FREQUENT_QUESTION_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "AVB_FREQUENT_QUESTION_SEQ", initialValue = 1, allocationSize = 1)
private Long id;
@Column(name = "FQUE_UUID")
......
package com.bytesw.bytebot.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable;
//@Audited
@Entity
@Table(name = "avb_process_etl")
@NamedQuery(name = "ProcessETL.findByPK", query = "Select u from ProcessETL u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString(exclude = "id")
public class ProcessETL implements Serializable {
@Id
@Column(name = "etl_id")
private int id;
@Version
@Column(name = "etl_version")
@Basic(optional = false)
private long version;
@Column(name = "etl_name", nullable = false)
private String name;
}
......@@ -22,6 +22,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.Type;
@Entity
@Getter
......@@ -29,15 +30,15 @@ import lombok.ToString;
@ToString
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
@Table(name = "BBOT_QUESTION_FILE")
@Table(name = "AVB_QUESTION_FILE")
@NamedQuery(name = "QuestionFile.findByPK", query = "Select u from QuestionFile u where u.id = ?1")
public class QuestionFile {
@Id
@Column(name = "QUFI_ID")
@TableGenerator(name = "BBOT_QUESTION_FILE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "BBOT_QUESTION_FILE_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_QUESTION_FILE_GENERATOR")
@TableGenerator(name = "AVB_QUESTION_FILE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT", pkColumnValue = "AVB_QUESTION_FILE_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "AVB_QUESTION_FILE_GENERATOR")
private Long id;
@Column(name = "QUFI_UUID", nullable = false)
......@@ -52,7 +53,7 @@ public class QuestionFile {
@Column(name = "QUFI_UDATE", columnDefinition = "TIMESTAMP")
private LocalDateTime uploadDate;
@Lob
@Type(type="org.hibernate.type.BinaryType")
@Basic(fetch = FetchType.LAZY)
@Column(name = "QUFI_DATA", length= 100000, nullable = false)
private byte[] data;
......
package com.bytesw.bytebot.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import java.time.OffsetDateTime;
//@Audited
@Entity
@DiscriminatorValue(value= RangeCalendarException.DISCRIMINATOR_VALUE)
@NamedQuery(name = "RangeCalendarException.findByPK", query = "Select u from RangeCalendarException u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString
public class RangeCalendarException extends CalendarException {
public static final String DISCRIMINATOR_VALUE = "R";
@Column(name = "CALE_EXC_FROM", nullable = false)
private OffsetDateTime from;
@Column(name = "CALE_EXC_TO", nullable = false)
private OffsetDateTime to;
}
\ No newline at end of file
package com.bytesw.bytebot.model;
import com.bytesw.xdf.model.converter.BooleanToStringConverter;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;
//@Audited
@Entity
@Table(name = "AVB_SCHEDULER_TASK")
@NamedQuery(name = "SchedulerTask.findByPK", query = "Select u from SchedulerTask u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString(exclude = "id")
public class SchedulerTask implements Serializable {
@Id
@Column(name = "SHTA_ID")
// @SequenceGenerator(name = "AVB_SCHEDULER_TASK_GENERATOR", sequenceName = "AVB_SCHEDULER_TASK_SEQ", initialValue = 1, allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_SCHEDULER_TASK_GENERATOR")
private BigInteger id;
@Version
@Column(name = "SHTA_VERSION")
@Basic(optional = false)
private long version;
@Column(name = "SHTA_DESCR", nullable = false)
private String description;
@Column(name = "SHTA_INTER", nullable = false)
@Convert(converter = BooleanToStringConverter.class)
private Boolean internals;
@Column(name = "SHTA_CROEX", nullable = false)
private String cronExpression;
@Column(name = "SHTA_PARAM")
private String stringParameters;
@Column(name= "cale_id")
private String calendarID;
@ManyToOne(optional = false)
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "CALE_ID", referencedColumnName = "CALE_ID", nullable = false)
private Calendar calendar;
/*@ManyToOne(optional = false)
@JoinColumn(name = "ETL_ID", referencedColumnName = "ETL_ID", nullable = false)
private ProcessETL processETL;*/
@Column(name = "etl_id")
private Integer processETL;
}
......@@ -17,22 +17,23 @@ import javax.persistence.*;
*/
@Entity
@Getter @Setter @ToString @EqualsAndHashCode(of = "id")
@Getter @Setter
@NoArgsConstructor
@Table(name = "BBOT_TIMEZONE")
@Table(name = "avb_timezone")
@NamedQuery(name = "Timezone.findByPK", query = "Select u from Timezone u where u.id = ?1")
public class Timezone {
@Id
@Column(name = "TZON_ID")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "BBOT_TIMEZONE_GENERATOR")
@TableGenerator(name = "BBOT_TIMEZONE_GENERATOR", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "BBOT_TIMEZONE_SEQ", allocationSize = 1)
@Column(name = "tzon_id")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "avb_timezone_generator")
@TableGenerator(name = "avb_timezone_generator", table = "sequence_table", pkColumnName = "seq_name", valueColumnName = "seq_count",
pkColumnValue = "avb_timezone_seq", allocationSize = 1)
private Long id;
@Column(name = "TZON_ZONE", nullable = false)
@Column(name = "tzon_zone", nullable = false)
private String timezone;
@ManyToOne
@JoinColumn(name = "COUN_ID", referencedColumnName = "COUN_ID")
@JoinColumn(name = "coun_id", referencedColumnName = "coun_id")
private Country country;
}
package com.bytesw.bytebot.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import java.time.LocalDate;
//@Audited
@Entity
@DiscriminatorValue(value= UniqueCalendarException.DISCRIMINATOR_VALUE)
@NamedQuery(name = "UniqueCalendarException.findByPK", query = "Select u from UniqueCalendarException u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString
public class UniqueCalendarException extends CalendarException {
public static final String DISCRIMINATOR_VALUE = "U";
@Column(name = "CALE_EXC_DATE", nullable = true)
private LocalDate date;
}
package com.bytesw.bytebot.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
//@Audited
@Entity
@DiscriminatorValue(value= UniqueWeeklyCalendarException.DISCRIMINATOR_VALUE)
@NamedQuery(name = "UniqueWeeklyCalendarException.findByPK", query = "Select u from UniqueWeeklyCalendarException u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString
public class UniqueWeeklyCalendarException extends CalendarException {
public static final String DISCRIMINATOR_VALUE = "W";
@Column(name = "CALE_EXC_MONTH", nullable = false)
private int month;
@Column(name = "CALE_EXC_WEEK", nullable = false)
private int weekOfMonth;
@Column(name = "CALE_EXC_DAYWE", nullable = false)
private int dayOfWeek;
}
package com.bytesw.bytebot.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
//@Audited
@Entity
@Table(name = "AVB_WEEK_SCHEDULER")
@NamedQuery(name = "WeekScheduler.findByPK", query = "Select u from WeekScheduler u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString(exclude = "calendar")
public class WeekScheduler implements Serializable {
@Id
@Column(name = "WESC_ID")
// @SequenceGenerator(name = "AVB_WEEK_SCHEDULER_GENERATOR", sequenceName = "AVB_WEEK_SCHEDULER_SEQ", initialValue = 1, allocationSize = 1)
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_WEEK_SCHEDULER_GENERATOR")
private BigInteger id;
@Version
@Column(name = "WESC_VERSION")
@Basic(optional = false)
private long version;
@Column(name = "WESC_DAY", nullable = false)
private int dayOfWeek;
@Column(name = "WESC_FROM", nullable = false)
private OffsetDateTime from;
@Column(name = "WESC_TO", nullable = false)
private OffsetDateTime to;
@Column(name = "CALE_ID")
private String calendarID;
@ManyToOne(optional = false)
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "cale_id", referencedColumnName = "cale_id", nullable = false)
private Calendar calendar;
}
package com.bytesw.bytebot.model.converters;
import com.bytesw.bytebot.model.enums.CalendarExceptionType;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
/**
* @author Renzo Carranza
* @version 26/08/2021
* <p>
* Copyright (c) 2019 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.
*/
@Converter
public class CalendarExceptionTypeConverter implements AttributeConverter<CalendarExceptionType, String> {
@Override
public String convertToDatabaseColumn(CalendarExceptionType calendarExceptionType) {
if (calendarExceptionType == null) return null;
return calendarExceptionType.getName();
}
@Override
public CalendarExceptionType convertToEntityAttribute(String s) {
return CalendarExceptionType.fromString(s);
}
}
package com.bytesw.bytebot.model.converters;
import com.bytesw.bytebot.model.enums.FrequencyType;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter
public class FrequencyTypeConverter implements AttributeConverter<FrequencyType, String> {
@Override
public String convertToDatabaseColumn(FrequencyType frequencyType) {
if (frequencyType == null) return null;
return frequencyType.getName();
}
@Override
public FrequencyType convertToEntityAttribute(String s) {
return FrequencyType.fromString(s);
}
}
package com.bytesw.bytebot.model.enums;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
@Getter
public enum AgentParameterEnum {
ACCESS_ID("account-identifier"),
ACCESS_TOKEN("authentication-token"),
ACCESS_TWILIO("twillio-number");
private static final Map<String, AgentParameterEnum> map = new HashMap<>();
private String name;
AgentParameterEnum(String name){ this.name = name;}
public String getName() {return name;}
static {
for (AgentParameterEnum type : AgentParameterEnum.values()) {
map.put(type.name, type);
}
}
public static AgentParameterEnum fromString(String name) {
return map.get(name);
}
}
package com.bytesw.bytebot.model.enums;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
public enum CalendarExceptionType {
HOLIDAY("H"), WORK_EXCEPTION("W"), NO_WORK_EXCEPTION("N");
private final String name;
private static final Map<String, CalendarExceptionType> map = new HashMap<>();
static {
for (CalendarExceptionType type : CalendarExceptionType.values()) {
map.put(type.name, type);
}
}
CalendarExceptionType(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static CalendarExceptionType fromString(String name) {
if (map.containsKey(name)) {
return map.get(name);
}
throw new NoSuchElementException(name + " not found");
}
}
\ No newline at end of file
package com.bytesw.bytebot.model.enums;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
@Getter
public enum ChannelEnum {
WHATSAPP("WhatsApp"),
MESSENGER("Facebook Messenger");
private static final Map<String, ChannelEnum> map = new HashMap<>();
private String name;
ChannelEnum(String name){ this.name = name;}
public String getName() {return name;}
static {
for (ChannelEnum type : ChannelEnum.values()) {
map.put(type.name, type);
}
}
public static ChannelEnum fromString(String name) {
return map.get(name);
}
}
package com.bytesw.bytebot.model.enums;
import com.bytesw.bytebot.model.AnnualCalendarException;
import com.bytesw.bytebot.model.RangeCalendarException;
import com.bytesw.bytebot.model.UniqueCalendarException;
import com.bytesw.bytebot.model.UniqueWeeklyCalendarException;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
public enum FrequencyType {
ANNUAL(AnnualCalendarException.DISCRIMINATOR_VALUE),
UNIQUE(UniqueCalendarException.DISCRIMINATOR_VALUE),
UniqueWeekly(UniqueWeeklyCalendarException.DISCRIMINATOR_VALUE),
RANGE(RangeCalendarException.DISCRIMINATOR_VALUE);
private final String name;
private static final Map<String, FrequencyType> map = new HashMap<>();
static {
for (FrequencyType type : FrequencyType.values()) {
map.put(type.name, type);
}
}
FrequencyType(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static FrequencyType fromString(String name) {
if (map.containsKey(name)) {
return map.get(name);
}
throw new NoSuchElementException(name + " not found");
}
}
package com.bytesw.bytebot.model.enums;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
@Getter
public enum MetricMessageTypeEnum {
RECEIVED("received"),
SENT("sent"),
SESSION("session");
private static final Map<String, MetricMessageTypeEnum> map = new HashMap<>();
private String name;
MetricMessageTypeEnum(String name){ this.name = name;}
public String getName() {return name;}
static {
for (MetricMessageTypeEnum type : MetricMessageTypeEnum.values()) {
map.put(type.name, type);
}
}
public static MetricMessageTypeEnum fromString(String name) {
return map.get(name);
}
}
package com.bytesw.bytebot.model.enums;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
public enum ProcessETLEnum {
PROCESS_DELETE ( "Eliminación de Data Sensible");
private final String name;
private static final Map<String, ProcessETLEnum> map = new HashMap<>();
static {
for (ProcessETLEnum type : ProcessETLEnum.values()) {
map.put(type.name, type);
}
}
ProcessETLEnum (String name) {
this.name = name;
}
public String getName() {
return name;
}
public static ProcessETLEnum fromString(String name) {
if (map.containsKey(name)) {
return map.get(name);
}
throw new NoSuchElementException(name + " not found");
}
}
\ No newline at end of file
package com.bytesw.bytebot.model.enums;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
@Getter
public enum ProviderErrorEnum {
AUTHENTICATE("Authenticate"),
CONEXION("name resolution");
private static final Map<String, ProviderErrorEnum> map = new HashMap<>();
private String name;
ProviderErrorEnum(String name){ this.name = name;}
public String getName() {return name;}
static {
for (ProviderErrorEnum type : ProviderErrorEnum.values()) {
map.put(type.name, type);
}
}
public static ProviderErrorEnum fromString(String name) {
return map.get(name);
}
}
package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.Agent;
import com.bytesw.bytebot.model.enums.AgentStatusEnum;
import com.bytesw.bytebot.bean.AgentBean;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* @author Sebastián Chicoma Sandmann.
* @version 9-sep-2020
......@@ -16,4 +20,6 @@ import org.springframework.data.repository.CrudRepository;
* licencia de uso que firmó con Byte.
*/
public interface AgentRepository extends CrudRepository<Agent, Long>, JpaSpecificationExecutor<Agent> {
List<Agent> findByStatus(AgentStatusEnum status);
}
package com.bytesw.bytebot.repository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import com.bytesw.bytebot.model.BusinessParameterConfiguration;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.math.BigInteger;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Optional;
public interface BusinessParameterConfigurationRepository extends CrudRepository<BusinessParameterConfiguration, BigInteger>, JpaSpecificationExecutor<BusinessParameterConfiguration> {
@Query("select b from BusinessParameterConfiguration b where b.businessParameter.key = :key and ((b.from < :fromDate and b.to >= :fromDate) OR (b.to is null))")
List<BusinessParameterConfiguration> findValidByKey(@Param("key") String key, @Param("fromDate") OffsetDateTime fromDate);
@Query("select b from BusinessParameterConfiguration b where b.businessParameter.key = :key and ((b.from < :currentDate and b.to >= :currentDate) OR (b.from < :currentDate and b.to is null))")
Optional<BusinessParameterConfiguration> findCurrentValueByKey(@Param("key") String key, @Param("currentDate") OffsetDateTime currentDate);
@Query("select b from BusinessParameterConfiguration b where b.businessParameter.id = :id")
List<BusinessParameterConfiguration> findBusinessParameterConfigurationListByBusinessParameter(@Param("id") BigInteger id);
@Query("select b from BusinessParameterConfiguration b where b.businessParameter.id = :id and (b.to > :toDate or b.to is null) order by b.from desc")
List<BusinessParameterConfiguration> findBusinessParameterConfigurationListByBusinessParameterWithLowestDateFrom(@Param("id") BigInteger id, @Param("toDate") OffsetDateTime toDate);
}
package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.BusinessParameter;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.math.BigInteger;
import java.util.Optional;
/**
* @author Renzo Carranza
* @version 26/08/2021
* <p>
* Copyright (c) 2019 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.
*/
public interface BusinessParameterRepository extends CrudRepository<BusinessParameter, BigInteger>, JpaSpecificationExecutor<BusinessParameter> {
@Query("select b from BusinessParameter b where b.key = :key")
Optional<BusinessParameter> findByKey(@Param("key") String key);
}
package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.CalendarException;
import com.bytesw.bytebot.model.CalendarExceptionFull;
import com.bytesw.bytebot.model.enums.CalendarExceptionType;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Optional;
public interface CalendarExceptionFullRepository extends CrudRepository<CalendarExceptionFull, BigInteger>, JpaSpecificationExecutor<CalendarExceptionFull> {
@Query("select s from CalendarExceptionFull s where s.calendarID = :calendarId")
Optional<List<CalendarExceptionFull>> findByCalendarId(@Param("calendarId") String calendarId);
}
package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.CalendarException;
import com.bytesw.bytebot.model.enums.CalendarExceptionType;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Optional;
public interface CalendarExceptionRepository extends CrudRepository<CalendarException, BigInteger>, JpaSpecificationExecutor<CalendarException> {
@Query("select s from RangeCalendarException s where s.calendar.id = :calendarId and s.from < :date and s.to > :date and s.calendarExceptionType = :type")
Optional<CalendarException> findByRangeExceptionByCalendarIdAndDateAndType(@Param("calendarId") String calendarId, @Param("date") OffsetDateTime date, @Param("type") CalendarExceptionType type);
@Query("select s from AnnualCalendarException s where s.calendar.id = :calendarId and s.month = :month and s.dayOfMonth = :dayOfMonth")
Optional<CalendarException> findByAnnualExceptionByCalendarIdAndYearAndDay(@Param("calendarId") String calendarId, @Param("month") int month, @Param("dayOfMonth") int dayOfMonth);
@Query("select s from UniqueCalendarException s where s.calendar.id = :calendarId and s.date = :date")
Optional<CalendarException> findByUniqueExceptionByCalendarIdAndDate(@Param("calendarId") String calendarId, @Param("date") LocalDate date);
@Query("select s from UniqueWeeklyCalendarException s where s.calendar.id = :calendarId and s.month = :month and s.dayOfWeek = :dayOfWeek and s.weekOfMonth = :weekOfMonth")
Optional<CalendarException> findByUniqueWeeklyExceptionByCalendarIdAndDayOfWeekAndWeekOfMonth(@Param("calendarId") String calendarId, @Param("month") int month, @Param("dayOfWeek") int dayOfWeek, @Param("weekOfMonth") int weekOfMonth);
@Query("select s from RangeCalendarException s where s.calendar.id = :calendarId and s.from >= :date and s.calendarExceptionType = :type")
Optional<CalendarException> findByRangeExceptionByCalendarIdFromDateAndType(@Param("calendarId") String calendarId, @Param("date") OffsetDateTime date, @Param("type") CalendarExceptionType type);
@Query("select s from CalendarException s where s.calendar.id = :calendarId")
Optional<List<CalendarException>> findByCalendarId(@Param("calendarId") String calendarId);
}
package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.Calendar;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
public interface CalendarRepository extends CrudRepository<Calendar, String>, JpaSpecificationExecutor<Calendar> {
}
\ No newline at end of file
......@@ -3,6 +3,8 @@ package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.Channel;
import org.springframework.data.repository.CrudRepository;
import java.util.Optional;
/**
* @author Sebastián Chicoma Sandmann.
* @version 9-sep-2020
......@@ -15,4 +17,6 @@ import org.springframework.data.repository.CrudRepository;
* licencia de uso que firmó con Byte.
*/
public interface ChannelRepository extends CrudRepository<Channel, Long> {
Optional<Channel> findByName(String name);
}
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