Commit e0102006 authored by Roberto Loayza Miljanovich's avatar Roberto Loayza Miljanovich

Merge branch 'dev_marcos' into 'developer'

Dev marcos

See merge request ByteBot/web/bytebot-service!17
parents 0869aecc 458bbc2b
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 BcdControlBean implements Serializable {
@Expose private Long id;
@Expose private Long agentId;
@Expose private String status;
}
...@@ -18,9 +18,9 @@ public class WeekSchedulerBean { ...@@ -18,9 +18,9 @@ public class WeekSchedulerBean {
@Expose @Expose
private int dayOfWeek; private int dayOfWeek;
@Expose @Expose
private OffsetDateTime from; private OffsetTime from;
@Expose @Expose
private OffsetDateTime to; private OffsetTime to;
@Expose @Expose
private String calendarID; private String calendarID;
@Expose @Expose
......
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.BcdControlBean;
import com.bytesw.bytebot.service.BcdControlService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RequestMapping("/service/settings/bcdControl")
@ProgramSecurity("BCDCONTROL")
@Log4j2
public class BcdControlController extends XDFController<BcdControlBean, Long> {
public BcdControlController(BcdControlService service) {
super(service);
}
}
...@@ -46,6 +46,7 @@ import org.springframework.stereotype.Service; ...@@ -46,6 +46,7 @@ import org.springframework.stereotype.Service;
import java.time.Duration; import java.time.Duration;
import java.time.OffsetDateTime; import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.Calendar; import java.util.Calendar;
...@@ -189,7 +190,7 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -189,7 +190,7 @@ public class ScheduleService implements SchedulingConfigurer {
/*ETL eliminacion de data sensible*/ /*ETL eliminacion de data sensible*/
public void processDeleteData(String tenantIdentifier, ScheduledTaskRegistrar taskRegistrar, String calendarId) { public void processDeleteData(String tenantIdentifier, ScheduledTaskRegistrar taskRegistrar, String calendarId) {
Optional<List<WeekScheduler>> dates = weekSchedulerRepository.findByCalendarId(calendarId); Optional<List<WeekScheduler>> dates = weekSchedulerRepository.findByCalendarId(calendarId);
OffsetDateTime actual = OffsetDateTime.now(); OffsetTime actual = OffsetTime.now();
for(WeekScheduler weekScheduler: dates.get()) { for(WeekScheduler weekScheduler: dates.get()) {
if (actual.isBefore(weekScheduler.getTo()) && actual.isAfter(weekScheduler.getFrom())) { if (actual.isBefore(weekScheduler.getTo()) && actual.isAfter(weekScheduler.getFrom())) {
//schedulerFlag = true; //schedulerFlag = true;
......
package com.bytesw.bytebot.etl.dao; package com.bytesw.bytebot.etl.dao;
import com.bytesw.bytebot.etl.model.Action; import com.bytesw.bytebot.etl.model.Action;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import java.util.Optional; import java.util.Optional;
public interface ActionRepository extends CrudRepository<Action, Long> { public interface ActionRepository extends CrudRepository<Action, Long>, JpaSpecificationExecutor<Action> {
Optional<Action> findByIdentifier(String identifier); Optional<Action> findByIdentifier(String identifier);
} }
package com.bytesw.bytebot.model;
import lombok.*;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Getter
@Setter
@ToString
@Table(name = "avb_bcd_control")
@NamedQuery(name = "BcdControl.findByPK", query = "Select u from BcdControl u where u.id = ?1")
public class BcdControl implements Serializable {
@Id
@Column(name = "bcd_id")
@SequenceGenerator(name = "AVB_BCD_CONTROL_GENERATOR", sequenceName = "AVB_BCD_CONTROL_SEQ", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_BCD_CONTROL_GENERATOR")
private Long id;
@Column(name = "agen_id")
private Long agentId;
@Column(name = "bcd_status")
private String status;
}
...@@ -32,7 +32,7 @@ public class Calendar implements Serializable { ...@@ -32,7 +32,7 @@ public class Calendar implements Serializable {
@Column(name = "cale_name", nullable = false) @Column(name = "cale_name", nullable = false)
private String name; private String name;
@OneToMany(mappedBy = "calendar") // @OneToMany(mappedBy = "calendar")
private List<WeekScheduler> weekSchedulerList; // private List<WeekScheduler> weekSchedulerList;
} }
...@@ -39,17 +39,17 @@ public class WeekScheduler implements Serializable { ...@@ -39,17 +39,17 @@ public class WeekScheduler implements Serializable {
private int dayOfWeek; private int dayOfWeek;
@Column(name = "WESC_FROM", nullable = false) @Column(name = "WESC_FROM", nullable = false)
private OffsetDateTime from; private OffsetTime from;
@Column(name = "WESC_TO", nullable = false) @Column(name = "WESC_TO", nullable = false)
private OffsetDateTime to; private OffsetTime to;
@Column(name = "CALE_ID") @Column(name = "CALE_ID")
private String calendarID; private String calendarID;
@ManyToOne(optional = false) // @ManyToOne(optional = false)
@NotFound(action = NotFoundAction.IGNORE) // @NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "cale_id", referencedColumnName = "cale_id", nullable = false) // @JoinColumn(name = "cale_id", referencedColumnName = "cale_id", nullable = false)
private Calendar calendar; // private Calendar calendar;
} }
package com.bytesw.bytebot.model.enums;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
@Getter
public enum StatusBcdEnum {
CARGANDO("CG"),
CARGADO("CGD"),
INDEXANDO("IDX"),
INDEXADO("IDXD");
private static final Map<String, StatusBcdEnum> map = new HashMap<>();
private String name;
StatusBcdEnum(String name) {
this.name = name;
}
static {
for (StatusBcdEnum type : StatusBcdEnum.values()) {
map.put(type.name, type);
}
}
public static StatusBcdEnum fromString(String name) {
return map.get(name);
}
}
package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.BcdControl;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
public interface BcdControlRepository extends CrudRepository<BcdControl, Long>, JpaSpecificationExecutor<BcdControl> {
}
package com.bytesw.bytebot.service;
import com.bytesw.bytebot.bean.BcdControlBean;
import com.bytesw.bytebot.model.BcdControl;
import com.bytesw.bytebot.repository.BcdControlRepository;
import com.bytesw.xdf.service.XDFService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
@Log4j2
public class BcdControlService extends XDFService<BcdControl, BcdControlBean, Long> {
protected BcdControlService(BcdControlRepository repository) {
super(repository);
}
@Override
protected BcdControl toModel(BcdControl model, BcdControlBean bean) {
if (model == null) {
model = new BcdControl();
}
BeanUtils.copyProperties(bean, model);
return model;
}
@Override
protected BcdControlBean toBean(BcdControl model) {
BcdControlBean bean = new BcdControlBean();
BeanUtils.copyProperties(model, bean);
return bean;
}
}
...@@ -20,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -63,6 +65,8 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String> ...@@ -63,6 +65,8 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String>
CalendarBean bean = new CalendarBean(); CalendarBean bean = new CalendarBean();
BeanUtils.copyProperties(model, bean); BeanUtils.copyProperties(model, bean);
bean.setWeekSchedulerBeanList(this.weekSchedulerService.getWeekSchedulerByCalId(model.getId().trim())); bean.setWeekSchedulerBeanList(this.weekSchedulerService.getWeekSchedulerByCalId(model.getId().trim()));
/**/
return bean; return bean;
} }
...@@ -115,6 +119,8 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String> ...@@ -115,6 +119,8 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String>
private void saveWeekScheduler(CalendarBean bean, Calendar calendar) { private void saveWeekScheduler(CalendarBean bean, Calendar calendar) {
List<WeekSchedulerBean> weekSchedulerBeanList = bean.getWeekSchedulerBeanList(); List<WeekSchedulerBean> weekSchedulerBeanList = bean.getWeekSchedulerBeanList();
Optional<List<WeekScheduler>> weekSchedulerBeanListBD = weekSchedulerRepository.findByCalendarId(calendar.getId().trim());
List<BigInteger> weekIds = new ArrayList<>();
for (WeekSchedulerBean weekSchedulerBean : weekSchedulerBeanList) { for (WeekSchedulerBean weekSchedulerBean : weekSchedulerBeanList) {
WeekScheduler weekScheduler; WeekScheduler weekScheduler;
...@@ -126,28 +132,42 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String> ...@@ -126,28 +132,42 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String>
this.weekSchedulerRepository.delete(weekSchedulerOptional.get()); this.weekSchedulerRepository.delete(weekSchedulerOptional.get());
continue; continue;
} }
weekIds.add(weekSchedulerOptional.get().getId());
weekScheduler = weekSchedulerOptional.get(); weekScheduler = weekSchedulerOptional.get();
} else { } else {
weekScheduler = new WeekScheduler(); weekScheduler = new WeekScheduler();
weekScheduler.setDayOfWeek(weekSchedulerBean.getDayOfWeek()); weekScheduler.setDayOfWeek(weekSchedulerBean.getDayOfWeek());
} }
weekScheduler.setCalendar(calendar); // weekScheduler.setCalendar(calendar);
weekScheduler.setCalendarID(calendar.getId());
weekScheduler.setFrom(weekSchedulerBean.getFrom()); weekScheduler.setFrom(weekSchedulerBean.getFrom());
weekScheduler.setTo(weekSchedulerBean.getTo()); weekScheduler.setTo(weekSchedulerBean.getTo());
this.weekSchedulerRepository.save(weekScheduler); this.weekSchedulerRepository.save(weekScheduler);
} else if (!delete) { } else if (!delete) {
weekScheduler = new WeekScheduler(); weekScheduler = new WeekScheduler();
weekScheduler.setCalendar(calendar); // weekScheduler.setCalendar(calendar);
weekScheduler.setCalendarID(calendar.getId());
weekScheduler.setDayOfWeek(weekSchedulerBean.getDayOfWeek()); weekScheduler.setDayOfWeek(weekSchedulerBean.getDayOfWeek());
weekScheduler.setFrom(weekSchedulerBean.getFrom()); weekScheduler.setFrom(weekSchedulerBean.getFrom());
weekScheduler.setTo(weekSchedulerBean.getTo()); weekScheduler.setTo(weekSchedulerBean.getTo());
this.weekSchedulerRepository.save(weekScheduler); this.weekSchedulerRepository.save(weekScheduler);
} }
}
if (weekSchedulerBeanListBD.isPresent()){
for (WeekScheduler weekScheduler: weekSchedulerBeanListBD.get()) {
if (!weekIds.contains(weekScheduler.getId())) {
weekSchedulerRepository.deleteById(weekScheduler.getId());
}
}
} }
} }
private void saveCalendarException(CalendarBean bean, Calendar calendar) { private void saveCalendarException(CalendarBean bean, Calendar calendar) {
List<CalendarExceptionBean> calendarExceptionBeanList = bean.getCalendarExceptionBeanList(); List<CalendarExceptionBean> calendarExceptionBeanList = bean.getCalendarExceptionBeanList();
Optional<List<CalendarException>> calendarExceptionListBD = calendarExceptionRepository.findByCalendarId(calendar.getId().trim());
List<BigInteger> exceptionIds = new ArrayList<>();
CalendarException calendarException = null; CalendarException calendarException = null;
for (CalendarExceptionBean calendarExceptionBean : calendarExceptionBeanList) { for (CalendarExceptionBean calendarExceptionBean : calendarExceptionBeanList) {
...@@ -163,6 +183,7 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String> ...@@ -163,6 +183,7 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String>
if (!calendarExceptionOptional.get().getFrequencyType().equals(calendarExceptionBean.getFrequencyType())) { if (!calendarExceptionOptional.get().getFrequencyType().equals(calendarExceptionBean.getFrequencyType())) {
calendarExceptionRepository.delete(calendarExceptionOptional.get()); calendarExceptionRepository.delete(calendarExceptionOptional.get());
} else { } else {
exceptionIds.add(calendarExceptionBean.getId());
calendarExceptionBean.setCalendar(bean); calendarExceptionBean.setCalendar(bean);
calendarException = calendarExceptionService.toModel(calendarExceptionOptional.get(), calendarExceptionBean); calendarException = calendarExceptionService.toModel(calendarExceptionOptional.get(), calendarExceptionBean);
calendarExceptionRepository.save(calendarException); calendarExceptionRepository.save(calendarException);
...@@ -178,6 +199,13 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String> ...@@ -178,6 +199,13 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String>
calendarException.setCalendar(calendar); calendarException.setCalendar(calendar);
calendarExceptionRepository.save(calendarException); calendarExceptionRepository.save(calendarException);
} }
if (calendarExceptionListBD.isPresent()){
for (CalendarException calException: calendarExceptionListBD.get()) {
if (!exceptionIds.contains(calException.getId())) {
calendarExceptionRepository.deleteById(calException.getId());
}
}
}
} }
} }
...@@ -43,8 +43,8 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -43,8 +43,8 @@ import org.springframework.web.multipart.MultipartFile;
@Log4j2 @Log4j2
public class FileManagementService { public class FileManagementService {
String[] validExtensions = new String[]{"xls", "xlsx"}; String[] validExtensions = new String[]{"xls", "xlsx", "csv"};
String[] fileHeaders = new String[]{"TOPICO", "SUBTOPICO", "PREGUNTA", "RESPUESTA"}; String[] fileHeaders = new String[]{"Class", "Question", "Answer"};
@Autowired @Autowired
private QuestionFileRepository questionFileRepository; private QuestionFileRepository questionFileRepository;
...@@ -61,7 +61,7 @@ public class FileManagementService { ...@@ -61,7 +61,7 @@ public class FileManagementService {
for (String validExension : validExtensions) { for (String validExension : validExtensions) {
if (validExension.equalsIgnoreCase(fileExtension.trim())) { if (validExension.equalsIgnoreCase(fileExtension.trim())) {
acceptedExtension = true; acceptedExtension = true;
continue; continue;//Break?
} }
} }
......
package com.bytesw.bytebot.service;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
@Log4j2
public class OrquestadorService {
}
...@@ -53,7 +53,7 @@ public class WeekSchedulerService extends XDFService<WeekScheduler, WeekSchedule ...@@ -53,7 +53,7 @@ public class WeekSchedulerService extends XDFService<WeekScheduler, WeekSchedule
throw new NotFoundException("Calendar not found " + bean.getCalendarID()); throw new NotFoundException("Calendar not found " + bean.getCalendarID());
} }
model.setCalendar(calendarOptional.get()); // model.setCalendarID(calendarOptional.get());
return model; return model;
} }
......
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