Commit f8749f30 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!25
parents 32751635 836b9b9c
...@@ -9,13 +9,12 @@ RUN apk add --update curl && \ ...@@ -9,13 +9,12 @@ RUN apk add --update curl && \
RUN export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:/bin/java::") RUN export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:/bin/java::")
RUN export PATH=$JAVA_HOME/bin:$PATH RUN export PATH=$JAVA_HOME/bin:$PATH
VOLUME /tmp # VOLUME /tmp
ARG JAR_FILE RUN echo 'target/bytebot-service-1.0.1-SNAPSHOT.jar'
RUN echo ${JAR_FILE} COPY 'target/bytebot-service-1.0.1-SNAPSHOT.jar' app.jar
COPY ${JAR_FILE} app.jar # ENV JAVA_OPTS="-Xms512m -Xmx1024m"
ENV JAVA_OPTS="-Xms512m -Xmx1024m"
EXPOSE 8080 EXPOSE 8080
EXPOSE 8443 EXPOSE 8443
EXPOSE 22 EXPOSE 22
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] ENTRYPOINT [ "sh", "-c", "java -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
FROM python:3.8-slim
USER root
COPY . .
RUN apt update && \
apt install -y nano curl awscli
RUN chmod +x entrypoint.sh
RUN mkdir /data
VOLUME [ "/data" ]
CMD ["sh","entrypoint.sh"]
\ No newline at end of file
#!/bin/bash
aws s3 sync s3://$bucket$path /data/$directory/
while :
do
echo "Container is still running"
sleep 5
done
\ No newline at end of file
package com.bytesw.bytebot.etl.batch.listener; package com.bytesw.bytebot.etl.batch.listener;
import lombok.extern.log4j.Log4j2;
import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.listener.JobExecutionListenerSupport; import org.springframework.batch.core.listener.JobExecutionListenerSupport;
@Log4j2
public class JobCompletionListener extends JobExecutionListenerSupport { public class JobCompletionListener extends JobExecutionListenerSupport {
@Override @Override
public void afterJob(JobExecution jobExecution) { public void afterJob(JobExecution jobExecution) {
if (jobExecution.getStatus() == BatchStatus.COMPLETED) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
System.out.println("BATCH JOB COMPLETED SUCCESSFULLY"); log.debug("BATCH JOB COMPLETED SUCCESSFULLY");
} }
} }
......
...@@ -24,6 +24,7 @@ import com.bytesw.bytebot.model.enums.AgentStatusEnum; ...@@ -24,6 +24,7 @@ import com.bytesw.bytebot.model.enums.AgentStatusEnum;
import com.bytesw.bytebot.model.enums.FrequencyType; import com.bytesw.bytebot.model.enums.FrequencyType;
import com.bytesw.bytebot.model.enums.ProcessETLEnum; import com.bytesw.bytebot.model.enums.ProcessETLEnum;
import com.bytesw.bytebot.repository.*; import com.bytesw.bytebot.repository.*;
import com.bytesw.bytebot.service.BusinessParameterService;
import com.bytesw.xdf.multitenant.core.ThreadLocalStorage; import com.bytesw.xdf.multitenant.core.ThreadLocalStorage;
import com.google.gson.Gson; import com.google.gson.Gson;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
...@@ -147,7 +148,7 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -147,7 +148,7 @@ public class ScheduleService implements SchedulingConfigurer {
private CalendarExceptionFullRepository calendarExceptionFullRepository; private CalendarExceptionFullRepository calendarExceptionFullRepository;
@Autowired @Autowired
private BusinessParameterRepository businessParameterRepository; private BusinessParameterService businessParameterService;
private boolean schedulerFlag = false; private boolean schedulerFlag = false;
...@@ -196,9 +197,9 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -196,9 +197,9 @@ public class ScheduleService implements SchedulingConfigurer {
private void configureTask(String tenantIdentifier, String identifier, ScheduledTaskRegistrar taskRegistrar) { private void configureTask(String tenantIdentifier, String identifier, ScheduledTaskRegistrar taskRegistrar) {
tenant = tenantIdentifier; tenant = tenantIdentifier;
taskRegister = taskRegistrar; taskRegister = taskRegistrar;
Optional<BusinessParameter> zone = businessParameterRepository.findByKey(parameter); String zone = businessParameterService.getBusinessParameterForKey(parameter);
if (zone.isPresent()) { if (zone != null) {
timeZone = TimeZone.getTimeZone(zone.get().getDefaultValue()); timeZone = TimeZone.getTimeZone(zone);
} else { } else {
timeZone = TimeZone.getTimeZone(zoneDefault); timeZone = TimeZone.getTimeZone(zoneDefault);
} }
...@@ -258,23 +259,29 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -258,23 +259,29 @@ 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<BusinessParameter> zone = businessParameterRepository.findByKey(parameter); String zone = businessParameterService.getBusinessParameterForKey(parameter);
if (zone.isPresent()) { if (zone != null) {
timeZone = TimeZone.getTimeZone(zone.get().getDefaultValue()); timeZone = TimeZone.getTimeZone(zone);
} else { } else {
timeZone = TimeZone.getTimeZone(zoneDefault); timeZone = TimeZone.getTimeZone(zoneDefault);
} }
Optional<List<WeekScheduler>> dates = weekSchedulerRepository.findByCalendarId(calendarId); Optional<List<WeekScheduler>> dates = weekSchedulerRepository.findByCalendarId(calendarId);
OffsetTime actual = OffsetTime.now(); OffsetTime actual = OffsetTime.now();
OffsetDateTime now = OffsetDateTime.now();
for(WeekScheduler weekScheduler: dates.get()) { for(WeekScheduler weekScheduler: dates.get()) {
int day = now.getDayOfWeek().getValue() == 7? 1: (now.getDayOfWeek().getValue() + 1);
if(day != weekScheduler.getDayOfWeek()){
schedulerFlag = false;
continue;
}
if (actual.isBefore(weekScheduler.getTo()) && actual.isAfter(weekScheduler.getFrom())) { if (actual.isBefore(weekScheduler.getTo()) && actual.isAfter(weekScheduler.getFrom())) {
Optional<List<CalendarExceptionFull>> calendarException = calendarExceptionFullRepository.findByCalendarId(calendarId); Optional<List<CalendarExceptionFull>> calendarException = calendarExceptionFullRepository.findByCalendarId(calendarId);
if (calendarException.isPresent()){ if (calendarException.isPresent()){
schedulerFlag = validateException(calendarException.get()); schedulerFlag = validateException(calendarException.get());
break;
} else { } else {
schedulerFlag = true; schedulerFlag = true;
} }
break;
} else { } else {
schedulerFlag = false; schedulerFlag = false;
} }
...@@ -285,7 +292,6 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -285,7 +292,6 @@ public class ScheduleService implements SchedulingConfigurer {
.getListAgentChannel(AgentStatusEnum.DEPLOYED.getName(), AgentParameterEnum.ACCESS_TWILIO.getName()); .getListAgentChannel(AgentStatusEnum.DEPLOYED.getName(), AgentParameterEnum.ACCESS_TWILIO.getName());
String keyDataSens = ""; String keyDataSens = "";
for (DeleteDataSensBean data : deleteDataSensBeans) { for (DeleteDataSensBean data : deleteDataSensBeans) {
Agent agent = agentRepository.findById(data.getAgenId()).get();
Trigger trigger = new CronTrigger(cronExpression, timeZone); Trigger trigger = new CronTrigger(cronExpression, timeZone);
keyDataSens = String.format("deleteSensible-%s-%s", tenantIdentifier, data.getAgenId()); keyDataSens = String.format("deleteSensible-%s-%s", tenantIdentifier, data.getAgenId());
if (!futureMap.containsKey(keyDataSens)) { if (!futureMap.containsKey(keyDataSens)) {
...@@ -321,7 +327,7 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -321,7 +327,7 @@ public class ScheduleService implements SchedulingConfigurer {
result = false; result = false;
} }
} else if (exception.getFrequencyType().equals(FrequencyType.UNIQUE.getName())) { } else if (exception.getFrequencyType().equals(FrequencyType.UNIQUE.getName())) {
if (now.toLocalDate() == exception.getDate()) { if (now.toLocalDate().equals(exception.getDate())) {
result = false; result = false;
} }
} else if (exception.getFrequencyType().equals(FrequencyType.UniqueWeekly.getName())) { } else if (exception.getFrequencyType().equals(FrequencyType.UniqueWeekly.getName())) {
...@@ -347,8 +353,8 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -347,8 +353,8 @@ public class ScheduleService implements SchedulingConfigurer {
@Scheduled(cron = "${application.byte-bot.batch.cron}") @Scheduled(cron = "${application.byte-bot.batch.cron}")
@SchedulerLock(name = "Dashboard-ETL", lockAtLeastFor = "PT40S", lockAtMostFor = "PT50S") @SchedulerLock(name = "Dashboard-ETL", lockAtLeastFor = "PT40S", lockAtMostFor = "PT50S")
protected void createJob() { protected void createJob() {
List<Agent> agentDeployed = agentRepository.findByStatus(AgentStatusEnum.DEPLOYED); List<Agent> agentDeployed = agentRepository.findByStatus(AgentStatusEnum.DEPLOYED);
log.info("INICIADO");
if (!agentDeployed.isEmpty()) { if (!agentDeployed.isEmpty()) {
ThreadLocalStorage.setTenantName(tenant); ThreadLocalStorage.setTenantName(tenant);
Job job = jobBuilderFactory.get("processJob") Job job = jobBuilderFactory.get("processJob")
...@@ -389,7 +395,9 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -389,7 +395,9 @@ public class ScheduleService implements SchedulingConfigurer {
/* Métodos ETL de data sensible */ /* Métodos ETL de data sensible */
private Job createJobDataSens(DeleteDataSensBean data) { private Job createJobDataSens(DeleteDataSensBean data) {
System.out.println("ETL de eliminacion"); log.info("ETL de eliminacion");
data = deleteDataSensJDBCRepository.getAgentChannelByAgentID(AgentStatusEnum.DEPLOYED.getName(),
AgentParameterEnum.ACCESS_TWILIO.getName(), data.getAgenId());
ThreadLocalStorage.setTenantName(tenant); ThreadLocalStorage.setTenantName(tenant);
return jobBuilderFactory.get( String.format("processDataSensible-%d",data.getAgenId())) return jobBuilderFactory.get( String.format("processDataSensible-%d",data.getAgenId()))
.incrementer(new RunIdIncrementer()).listener(listener) .incrementer(new RunIdIncrementer()).listener(listener)
...@@ -426,13 +434,13 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -426,13 +434,13 @@ public class ScheduleService implements SchedulingConfigurer {
DeleteDataSensControlBean control = deleteDataSensJDBCRepository.getControl(data.getAgenId()); DeleteDataSensControlBean control = deleteDataSensJDBCRepository.getControl(data.getAgenId());
OffsetDateTime endDate = OffsetDateTime.now(); OffsetDateTime endDate = OffsetDateTime.now();
Long id = 0L; Long id = 0L;
int differenceTime = 0; Long differenceTime = 0L;
if (control != null) { if (control != null) {
OffsetDateTime lastSessionDate = OffsetDateTime.ofInstant(control.getDateDelete().toInstant(), ZoneId.systemDefault()); OffsetDateTime lastSessionDate = OffsetDateTime.ofInstant(control.getDateDelete().toInstant(), ZoneId.systemDefault());
Duration difference = Duration.between(lastSessionDate, endDate); Duration difference = Duration.between(lastSessionDate, endDate);
differenceTime = (int) (difference.getSeconds() / 60); differenceTime = (difference.getSeconds() / 60);
if (differenceTime < data.getDeletePeriod()) { if (differenceTime < data.getDeletePeriod()) {
log.info("Agente " + data.getValue() + " aun no cumple con el periodo de espera."); log.info("Agente " + data.getValue() + " aun no cumple con el periodo de espera.");
......
...@@ -117,6 +117,8 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio ...@@ -117,6 +117,8 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
} }
} }
} }
} else {
update_control = true;
} }
DeleteDataSensibleControl control = new DeleteDataSensibleControl(); DeleteDataSensibleControl control = new DeleteDataSensibleControl();
Optional<DeleteDataSensibleControl> controlBd = deleteDataSensibleControlRepository.findEventIdByAgentId(agent.getAgenId()); Optional<DeleteDataSensibleControl> controlBd = deleteDataSensibleControlRepository.findEventIdByAgentId(agent.getAgenId());
......
...@@ -31,6 +31,19 @@ public class DeleteDataSensJDBCRepository { ...@@ -31,6 +31,19 @@ public class DeleteDataSensJDBCRepository {
} }
} }
public DeleteDataSensBean getAgentChannelByAgentID(String status, String channel, Long id){
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Object> params = new HashMap<>();
params.put("status", status);
params.put("channel", channel);
params.put("agentId", id);
return session.selectOne("com.bytesw.bytebot.dao.jdbc.ETLDataSensibleMapper.getAgentChannelByAgentId", params);
} finally {
session.close();
}
}
public DeleteDataSensControlBean getControl(Long id){ public DeleteDataSensControlBean getControl(Long id){
SqlSession session = sqlSessionFactory.openSession(); SqlSession session = sqlSessionFactory.openSession();
try { try {
......
package com.bytesw.bytebot.repository; package com.bytesw.bytebot.repository;
import com.bytesw.bytebot.model.Country; import com.bytesw.bytebot.model.Country;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import java.util.List;
/** /**
* @author Sebastián Chicoma Sandmann. * @author Sebastián Chicoma Sandmann.
* @version 9-sep-2020 * @version 9-sep-2020
...@@ -15,4 +18,7 @@ import org.springframework.data.repository.CrudRepository; ...@@ -15,4 +18,7 @@ import org.springframework.data.repository.CrudRepository;
* licencia de uso que firmó con Byte. * licencia de uso que firmó con Byte.
*/ */
public interface CountryRepository extends CrudRepository<Country, Long> { public interface CountryRepository extends CrudRepository<Country, Long> {
@Query("select c from Country c order by c.name")
List<Country> findAllOrder();
} }
...@@ -451,7 +451,7 @@ public class AgentService extends CustomPaginationService<Agent> { ...@@ -451,7 +451,7 @@ public class AgentService extends CustomPaginationService<Agent> {
public List<CountryBean> getCountries() { public List<CountryBean> getCountries() {
List<CountryBean> countriesBean = new ArrayList<>(); List<CountryBean> countriesBean = new ArrayList<>();
List<Country> countries = (List<Country>) countryRepository.findAll(); List<Country> countries = countryRepository.findAllOrder();
for (Country country : countries) { for (Country country : countries) {
countriesBean.add(CountryBean.clone(country)); countriesBean.add(CountryBean.clone(country));
......
...@@ -55,10 +55,7 @@ public class BucketService { ...@@ -55,10 +55,7 @@ public class BucketService {
private QuestionFileRepository questionFileRepository; private QuestionFileRepository questionFileRepository;
@Autowired @Autowired
private BusinessParameterConfigurationRepository businessParameterConfigurationRepository; private BusinessParameterService businessParameterService;
@Autowired
private BusinessParameterRepository businessParameterRepository;
private AmazonS3 getS3Client() { private AmazonS3 getS3Client() {
return AmazonS3ClientBuilder.standard() return AmazonS3ClientBuilder.standard()
...@@ -67,23 +64,11 @@ public class BucketService { ...@@ -67,23 +64,11 @@ public class BucketService {
} }
public boolean generate(byte[] file, FileValidationResponse response) { public boolean generate(byte[] file, FileValidationResponse response) {
Optional<BusinessParameter> deployment = businessParameterRepository.findByKey(parameter); String bucketName = businessParameterService.getBusinessParameterForKey(parameter);
String bucketName = new String(); if (bucketName == null) {
if (!deployment.isPresent()) {
response.setMessage("NOT.FOUND.BUSINESS.PARAMETER");
throw new NotFoundException();
}
List<BusinessParameterConfiguration> deploy = businessParameterConfigurationRepository
.findBusinessParameterConfigurationListByBusinessParameter(deployment.get().getId());
if (deploy.isEmpty()) {
response.setMessage("NOT.FOUND.BUSINESS.PARAMETER"); response.setMessage("NOT.FOUND.BUSINESS.PARAMETER");
throw new NotFoundException(); throw new NotFoundException();
} }
if (deploy.get(0).getFrom().isAfter(OffsetDateTime.now())) {
bucketName = deploy.get(0).getValue();
} else if (deployment.get().getDefaultValue() != null) {
bucketName = deployment.get().getDefaultValue();
}
boolean result = false; boolean result = false;
File mainFile = new File(response.getFileName()); File mainFile = new File(response.getFileName());
...@@ -114,11 +99,10 @@ public class BucketService { ...@@ -114,11 +99,10 @@ public class BucketService {
} }
public void delete(String uuid) { public void delete(String uuid) {
Optional<BusinessParameter> businessParameter = businessParameterRepository.findByKey(parameter); String bucketName = businessParameterService.getBusinessParameterForKey(parameter);
if (!businessParameter.isPresent()) { if (bucketName == null) {
throw new NotFoundException(); throw new NotFoundException();
} }
String bucketName = businessParameter.get().getDefaultValue();
try { try {
AmazonS3 s3Client = getS3Client(); AmazonS3 s3Client = getS3Client();
Optional<QuestionFile> questionFile = questionFileRepository.findByUuid(uuid); Optional<QuestionFile> questionFile = questionFileRepository.findByUuid(uuid);
...@@ -136,13 +120,4 @@ public class BucketService { ...@@ -136,13 +120,4 @@ public class BucketService {
} }
} }
public void list() {
AmazonS3 s3 = getS3Client();
List<Bucket> buckets = s3.listBuckets();
System.out.println("Your {S3} buckets are:");
for (Bucket b : buckets) {
System.out.println("* " + b.getName());
}
}
} }
...@@ -283,7 +283,6 @@ public class BusinessParameterService extends XDFService<BusinessParameter, Busi ...@@ -283,7 +283,6 @@ public class BusinessParameterService extends XDFService<BusinessParameter, Busi
public boolean validateKey(BusinessParameterBean bean) { public boolean validateKey(BusinessParameterBean bean) {
Optional<BusinessParameter> businessParameterOptional = this.businessParameterRepository.findByKey(bean.getKey()); Optional<BusinessParameter> businessParameterOptional = this.businessParameterRepository.findByKey(bean.getKey());
System.out.println(businessParameterOptional);
if (businessParameterOptional.isPresent()) { if (businessParameterOptional.isPresent()) {
BusinessParameterBean businessParameterBeanOptional = toBean(businessParameterOptional.get()); BusinessParameterBean businessParameterBeanOptional = toBean(businessParameterOptional.get());
if (!businessParameterBeanOptional.getId().equals(bean.getId())) { if (!businessParameterBeanOptional.getId().equals(bean.getId())) {
...@@ -305,4 +304,45 @@ public class BusinessParameterService extends XDFService<BusinessParameter, Busi ...@@ -305,4 +304,45 @@ public class BusinessParameterService extends XDFService<BusinessParameter, Busi
} }
return beanList; return beanList;
} }
public String getBusinessParameterForKey(String parameter) {
Optional<BusinessParameter> businessParameter = businessParameterRepository.findByKey(parameter);
if(!businessParameter.isPresent()) {
return null;
}
String parameterResult = null;
if (businessParameter.get().getRequired()) {
parameterResult = businessParameter.get().getDefaultValue();
}
List<BusinessParameterConfiguration> parameterConfig = businessParameterConfigurationRepository
.findBusinessParameterConfigurationListByBusinessParameter(businessParameter.get().getId());
if (parameterConfig.isEmpty()) {
return parameterResult;
}
OffsetDateTime nowTime = OffsetDateTime.now();
for (BusinessParameterConfiguration config: parameterConfig) {
if (config.getTo() == null) {
if (nowTime.isAfter(config.getFrom())) {
parameterResult = config.getValue();
break;
}
} else {
if (config.getFrom().equals(config.getTo())) {
if (config.getFrom().isBefore(nowTime)) {
parameterResult = config.getValue();
break;
}
}
if (config.getFrom().isBefore(config.getTo()) && nowTime.isAfter(config.getFrom()) && config.getTo().isAfter(nowTime)) {
parameterResult = config.getValue();
break;
}
}
}
return parameterResult;
}
} }
...@@ -4,14 +4,10 @@ import com.bytesw.bytebot.http.FileValidationResponse; ...@@ -4,14 +4,10 @@ import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.http.FileValidationResult; import com.bytesw.bytebot.http.FileValidationResult;
import com.bytesw.bytebot.http.enums.ValidationStatusEnum; import com.bytesw.bytebot.http.enums.ValidationStatusEnum;
import com.bytesw.bytebot.model.BdcControl; import com.bytesw.bytebot.model.BdcControl;
import com.bytesw.bytebot.model.BusinessParameter;
import com.bytesw.bytebot.model.BusinessParameterConfiguration;
import com.bytesw.bytebot.model.QuestionFile; import com.bytesw.bytebot.model.QuestionFile;
import com.bytesw.bytebot.model.enums.FrequentQuestionStatusEnum; import com.bytesw.bytebot.model.enums.FrequentQuestionStatusEnum;
import com.bytesw.bytebot.model.enums.StatusBcdEnum; import com.bytesw.bytebot.model.enums.StatusBcdEnum;
import com.bytesw.bytebot.repository.BdcControlRepository; import com.bytesw.bytebot.repository.BdcControlRepository;
import com.bytesw.bytebot.repository.BusinessParameterConfigurationRepository;
import com.bytesw.bytebot.repository.BusinessParameterRepository;
import com.bytesw.bytebot.repository.QuestionFileRepository; import com.bytesw.bytebot.repository.QuestionFileRepository;
import com.bytesw.xdf.exception.NotFoundException; import com.bytesw.xdf.exception.NotFoundException;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
...@@ -21,8 +17,6 @@ import org.springframework.stereotype.Service; ...@@ -21,8 +17,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
...@@ -46,10 +40,7 @@ public class OrquestadorService { ...@@ -46,10 +40,7 @@ public class OrquestadorService {
private KnowledgeService knowledgeService; private KnowledgeService knowledgeService;
@Autowired @Autowired
private BusinessParameterRepository businessParameterRepository; private BusinessParameterService businessParameterService;
@Autowired
private BusinessParameterConfigurationRepository businessParameterConfigurationRepository;
@Value("${application.bucket.deployment}") @Value("${application.bucket.deployment}")
private String parameter; private String parameter;
...@@ -60,23 +51,12 @@ public class OrquestadorService { ...@@ -60,23 +51,12 @@ public class OrquestadorService {
boolean step = false; boolean step = false;
try{ try{
//Modo de despliegue //Modo de despliegue
Optional<BusinessParameter> deployment = businessParameterRepository.findByKey(parameter); String modeDeployment = businessParameterService.getBusinessParameterForKey(parameter);
String modeDeployment = new String(); if (modeDeployment == null) {
if (!deployment.isPresent()) {
response.setMessage("NOT.FOUND.BUSINESS.PARAMETER");
throw new NotFoundException();
}
List<BusinessParameterConfiguration> deploy = businessParameterConfigurationRepository
.findBusinessParameterConfigurationListByBusinessParameter(deployment.get().getId());
if (deploy.isEmpty()) {
response.setMessage("NOT.FOUND.BUSINESS.PARAMETER"); response.setMessage("NOT.FOUND.BUSINESS.PARAMETER");
throw new NotFoundException(); throw new NotFoundException();
} }
if (deploy.get(0).getFrom().isAfter(OffsetDateTime.now())) {
modeDeployment = deploy.get(0).getValue();
} else if (deployment.get().getDefaultValue() != null) {
modeDeployment = deployment.get().getDefaultValue();
}
//Valida y guarda en base de datos //Valida y guarda en base de datos
response = fileManagementService.saveFile(uuid, file); response = fileManagementService.saveFile(uuid, file);
if(response.getFileValidationResult().getStatus().getName() != ValidationStatusEnum.OK.getName()) { if(response.getFileValidationResult().getStatus().getName() != ValidationStatusEnum.OK.getName()) {
...@@ -84,7 +64,6 @@ public class OrquestadorService { ...@@ -84,7 +64,6 @@ public class OrquestadorService {
return response; return response;
} }
model.setUuid(response.getUuid()); model.setUuid(response.getUuid());
model.setFileId(response.getId()); model.setFileId(response.getId());
model.setFileName(response.getFileName()); model.setFileName(response.getFileName());
...@@ -133,23 +112,11 @@ public class OrquestadorService { ...@@ -133,23 +112,11 @@ public class OrquestadorService {
BdcControl model = modelBdc.get(); BdcControl model = modelBdc.get();
FileValidationResponse response = modelToFileValidation(model); FileValidationResponse response = modelToFileValidation(model);
try { try {
Optional<BusinessParameter> deployment = businessParameterRepository.findByKey(parameter); String modeDeployment = businessParameterService.getBusinessParameterForKey(parameter);
String modeDeployment = new String(); if (modeDeployment == null) {
if (!deployment.isPresent()) {
response.setMessage("NOT.FOUND.BUSINESS.PARAMETER");
throw new NotFoundException();
}
List<BusinessParameterConfiguration> deploy = businessParameterConfigurationRepository
.findBusinessParameterConfigurationListByBusinessParameter(deployment.get().getId());
if (deploy.isEmpty()) {
response.setMessage("NOT.FOUND.BUSINESS.PARAMETER"); response.setMessage("NOT.FOUND.BUSINESS.PARAMETER");
throw new NotFoundException(); throw new NotFoundException();
} }
if (deploy.get(0).getFrom().isAfter(OffsetDateTime.now())) {
modeDeployment = deploy.get(0).getValue();
} else if (deployment.get().getDefaultValue() != null) {
modeDeployment = deployment.get().getDefaultValue();
}
if (model.getStatus().equals(StatusBcdEnum.CARGADO.getName())) { if (model.getStatus().equals(StatusBcdEnum.CARGADO.getName())) {
Optional<QuestionFile> questionFile = questionFileRepository.findByUuid(uuid); Optional<QuestionFile> questionFile = questionFileRepository.findByUuid(uuid);
......
...@@ -88,7 +88,6 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas ...@@ -88,7 +88,6 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
schedulerTask = toModel(schedulerTask, schedulerTaskBean); schedulerTask = toModel(schedulerTask, schedulerTaskBean);
schedulerTask = schedulerTaskRepository.save(schedulerTask); schedulerTask = schedulerTaskRepository.save(schedulerTask);
scheduleService.restartTask(schedulerTask); scheduleService.restartTask(schedulerTask);
System.out.println(schedulerTask);
return toBean(schedulerTask); return toBean(schedulerTask);
} }
......
...@@ -8,14 +8,12 @@ ...@@ -8,14 +8,12 @@
SELECT COUNT(MESSA_ID) SELECT COUNT(MESSA_ID)
FROM AVB_MESSAGE FROM AVB_MESSAGE
WHERE MESSA_DATE &lt;= #{endDate} AND MESSA_DATE &gt;= #{startDate} WHERE MESSA_DATE &lt;= #{endDate} AND MESSA_DATE &gt;= #{startDate}
and INTEN_ID IS NOT NULL
</select> </select>
<select id="countMessagesInRangeForHour" resultType="int" flushCache="true"> <select id="countMessagesInRangeForHour" resultType="int" flushCache="true">
SELECT COUNT(MESSA_ID) SELECT COUNT(MESSA_ID)
FROM AVB_MESSAGE FROM AVB_MESSAGE
WHERE MESSA_DATE &lt;= #{endDate} AND MESSA_DATE &gt;= #{startDate} WHERE MESSA_DATE &lt;= #{endDate} AND MESSA_DATE &gt;= #{startDate}
and INTEN_ID IS NOT NULL
</select> </select>
<!-- @TODO Pendiente agregar la fecha --> <!-- @TODO Pendiente agregar la fecha -->
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
<select id="countSessionsInRange" resultType="int" flushCache="true"> <select id="countSessionsInRange" resultType="int" flushCache="true">
select count(session_id) from avb_session select count(session_id) from avb_session
WHERE SESSION_LEDAT &lt;= #{endDate} WHERE SESSION_DATE &lt;= #{endDate}
AND SESSION_LEDAT &gt;= #{startDate} AND SESSION_DATE &gt;= #{startDate}
</select> </select>
<select id="avgSessionsByCustomerInRange" resultType="Double" flushCache="true"> <select id="avgSessionsByCustomerInRange" resultType="Double" flushCache="true">
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
( (
select count(USER_ID) as SESSION_CANT select count(USER_ID) as SESSION_CANT
from AVB_SESSION bas from AVB_SESSION bas
WHERE SESSION_LEDAT &lt;= #{endDate} AND SESSION_LEDAT &gt;= #{startDate} GROUP BY USER_ID WHERE SESSION_DATE &lt;= #{endDate} AND SESSION_DATE &gt;= #{startDate} GROUP BY USER_ID
) AVB_SESSION_COUNT ) AVB_SESSION_COUNT
</select> </select>
......
...@@ -8,14 +8,12 @@ ...@@ -8,14 +8,12 @@
SELECT COUNT(MESSA_ID) SELECT COUNT(MESSA_ID)
FROM AVB_MESSAGE FROM AVB_MESSAGE
WHERE MESSA_DATE &lt;= #{endDate} AND MESSA_DATE &gt;= #{startDate} WHERE MESSA_DATE &lt;= #{endDate} AND MESSA_DATE &gt;= #{startDate}
and INTEN_ID IS NOT NULL
</select> </select>
<select id="countMessagesInRangeForHour" resultType="int" flushCache="true"> <select id="countMessagesInRangeForHour" resultType="int" flushCache="true">
SELECT COUNT(MESSA_ID) SELECT COUNT(MESSA_ID)
FROM AVB_MESSAGE FROM AVB_MESSAGE
WHERE MESSA_DATE &lt;= #{endDate} AND MESSA_DATE &gt;= #{startDate} WHERE MESSA_DATE &lt;= #{endDate} AND MESSA_DATE &gt;= #{startDate}
and INTEN_ID IS NOT NULL
</select> </select>
<!-- @TODO Pendiente agregar la fecha --> <!-- @TODO Pendiente agregar la fecha -->
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
<select id="countSessionsInRange" resultType="int" flushCache="true"> <select id="countSessionsInRange" resultType="int" flushCache="true">
select count(session_id) from avb_session select count(session_id) from avb_session
WHERE SESSION_LEDAT &lt;= #{endDate} WHERE SESSION_DATE &lt;= #{endDate}
AND SESSION_LEDAT &gt;= #{startDate} AND SESSION_DATE &gt;= #{startDate}
</select> </select>
<select id="avgSessionsByCustomerInRange" resultType="Double" flushCache="true"> <select id="avgSessionsByCustomerInRange" resultType="Double" flushCache="true">
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
( (
select count(USER_ID) as SESSION_CANT select count(USER_ID) as SESSION_CANT
from AVB_SESSION bas from AVB_SESSION bas
WHERE SESSION_LEDAT &lt;= #{endDate} AND SESSION_LEDAT &gt;= #{startDate} GROUP BY USER_ID WHERE SESSION_DATE &lt;= #{endDate} AND SESSION_DATE &gt;= #{startDate} GROUP BY USER_ID
) AVB_SESSION_COUNT ) AVB_SESSION_COUNT
</select> </select>
......
...@@ -17,6 +17,19 @@ ...@@ -17,6 +17,19 @@
WHERE agen_state=#{status} AND chpa_label=#{channel} WHERE agen_state=#{status} AND chpa_label=#{channel}
</select> </select>
<select id="getAgentChannelByAgentId" resultType="ChannelByAgent" flushCache="true">
SELECT chpv_id as id,
chpv_value as channelValue,
AG.agen_iden as value,
AG.agen_id as agenId,
AG.agen_delete_sensible_period as deletePeriod
FROM AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE ADCP
JOIN AVB_CHANNEL_PARAM ACP ON ACP.chpa_id=ADCP.chpa_id
JOIN avb_deployment_channel AD on AD.dcha_id=ADCP.dcha_id
JOIN avb_agent AG on AG.agen_id=AD.agen_id
WHERE agen_state=#{status} AND chpa_label=#{channel} and AG.agen_id = #{agentId}
</select>
<select id="getControl" resultType="DeleteControl" flushCache="true"> <select id="getControl" resultType="DeleteControl" flushCache="true">
SELECT dsmc_id as id, SELECT dsmc_id as id,
agent_id as agentId, agent_id as agentId,
......
...@@ -17,6 +17,19 @@ ...@@ -17,6 +17,19 @@
WHERE agen_state=#{status} AND chpa_label=#{channel} WHERE agen_state=#{status} AND chpa_label=#{channel}
</select> </select>
<select id="getAgentChannelByAgentId" resultType="ChannelByAgent" flushCache="true">
SELECT chpv_id as id,
chpv_value as channelValue,
AG.agen_iden as value,
AG.agen_id as agenId,
AG.agen_delete_sensible_period as deletePeriod
FROM AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE ADCP
JOIN AVB_CHANNEL_PARAM ACP ON ACP.chpa_id=ADCP.chpa_id
JOIN avb_deployment_channel AD on AD.dcha_id=ADCP.dcha_id
JOIN avb_agent AG on AG.agen_id=AD.agen_id
WHERE agen_state=#{status} AND chpa_label=#{channel} and AG.agen_id = #{agentId}
</select>
<select id="getControl" resultType="DeleteControl" flushCache="true"> <select id="getControl" resultType="DeleteControl" flushCache="true">
SELECT dsmc_id as id, SELECT dsmc_id as id,
agent_id as agentId, agent_id as agentId,
......
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