Commit d136e061 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!20
parents 7535be84 b99dc87c
......@@ -246,6 +246,14 @@
<artifactId>twilio</artifactId>
<version>8.22.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.12.129</version>
</dependency>
</dependencies>
<build>
......
......@@ -7,8 +7,12 @@ import lombok.Setter;
import java.io.Serializable;
@Getter @Setter
public class BcdControlBean implements Serializable {
public class BdcControlBean implements Serializable {
@Expose private Long id;
@Expose private Long agentId;
@Expose private String uuid;
@Expose private String fileName;
@Expose private String status;
@Expose private String user;
@Expose private String date;
@Expose private Long fileId;
}
......@@ -3,8 +3,7 @@ package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.AgentBean;
import com.bytesw.bytebot.controller.bean.ResponseController;
import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.service.AgentService;
import com.bytesw.bytebot.service.FileManagementService;
import com.bytesw.bytebot.service.*;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson;
......@@ -38,6 +37,9 @@ public class AgentController {
@Autowired
private GsonBuilder gsonBuilder;
@Autowired
private OrquestadorService orquestadorService;
@PostMapping(value = "/page")
@PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> paginationConversationalAgent(@RequestBody Pagination<AgentBean> pagination) {
......@@ -168,7 +170,7 @@ public class AgentController {
Gson gson = gsonBuilder.create();
try {
String uuid = UUID.randomUUID().toString();
FileValidationResponse response = fileManagementService.validateAndSaveFile(uuid, file);
FileValidationResponse response = orquestadorService.executeGenerateBCD(uuid, file);
response.setUser(principal != null ? principal.getName() : null);
return new ResponseEntity<>(gson.toJson(response), HttpStatus.OK);
} catch (Exception e) {
......@@ -177,6 +179,32 @@ public class AgentController {
}
}
@PutMapping("/file-upload/{uuid}")
public ResponseEntity<String> uploadFile(@PathVariable("uuid") String uuid, Principal principal) {
Gson gson = gsonBuilder.create();
try {
FileValidationResponse response = orquestadorService.retry(uuid);
response.setUser(principal != null ? principal.getName() : null);
return new ResponseEntity<>(gson.toJson(response), HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@DeleteMapping("/file-upload/{uuid}")
public ResponseEntity<String> deleteBdc(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) {
Gson gson = gsonBuilder.create();
try {
orquestadorService.deleteBcd(uuid);
String response = "Todo Ok";
return new ResponseEntity<>(gson.toJson(response), HttpStatus.OK);
} catch (Exception e) {
log.error("Error detectado: ", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@GetMapping("/synchronize/{id}")
public ResponseEntity<String> synchronizeFiles(@PathVariable("id") Long id,
@RequestParam("user") String user) {
......
package com.bytesw.bytebot.controller;
import com.bytesw.bytebot.bean.BcdControlBean;
import com.bytesw.bytebot.bean.BdcControlBean;
import com.bytesw.bytebot.service.BcdControlService;
import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.controller.XDFController;
......@@ -12,8 +12,8 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/service/settings/bcdControl")
@ProgramSecurity("BCDCONTROL")
@Log4j2
public class BcdControlController extends XDFController<BcdControlBean, Long> {
public BcdControlController(BcdControlService service) {
public class BdcControlController extends XDFController<BdcControlBean, Long> {
public BdcControlController(BcdControlService service) {
super(service);
}
}
......@@ -30,7 +30,7 @@ import java.util.List;
@RestController()
@RequestMapping("/service/settings/business-parameter")
@ProgramSecurity("business-parameters")
@ProgramSecurity("BUSINESS-PARAMETERS")
@Log4j2
public class BusinessParameterController extends XDFController<BusinessParameterBean, BigInteger> {
@Autowired BusinessParameterService service;
......
......@@ -19,8 +19,8 @@ import java.util.Map;
import java.util.Objects;
@RestController()
@RequestMapping("/service/scheduler-task")
@ProgramSecurity("scheduler")
@RequestMapping("/service/settings/scheduler-task")
@ProgramSecurity("SCHEDULER-TASK")
@Log4j2
public class SchedulerTaskController extends XDFController<SchedulerTaskBean, BigInteger> {
public SchedulerTaskController(SchedulerTaskService service) {
......
......@@ -8,8 +8,6 @@ package com.bytesw.bytebot.http;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
@Getter @Setter
public class FileValidationResponse {
......
......@@ -11,6 +11,7 @@ import java.util.NoSuchElementException;
public enum ValidationStatusEnum {
OK("OK"),
ERROR("ERROR"),
INCOMPATIBLE_EXTENSION("IE"),
HEADER_ERROR ("HE"),
CONTENT_ERROR("CE");
......
......@@ -10,8 +10,8 @@ import java.io.Serializable;
@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 {
@NamedQuery(name = "BdcControl.findByPK", query = "Select u from BdcControl u where u.id = ?1")
public class BdcControl implements Serializable {
@Id
@Column(name = "bcd_id")
......@@ -19,10 +19,22 @@ public class BcdControl implements Serializable {
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_BCD_CONTROL_GENERATOR")
private Long id;
@Column(name = "agen_id")
private Long agentId;
@Column(name = "bcd_uuid")
private String uuid;
@Column(name = "bcd_file")
private String fileName;
@Column(name = "bcd_file_id")
private Long fileId;
@Column(name = "bcd_status")
private String status;
@Column(name = "bcd_user")
private String user;
@Column(name = "bcd_date")
private String date;
}
......@@ -21,7 +21,9 @@ public enum FrequentQuestionStatusEnum {
PENDING_SYNCHRONIZED("PS"),
UPLOADED("LO"),
DELETED("DE");
DELETED("DE"),
ERROR("ER"),
CORRECTO("OK");
private static final Map<String, FrequentQuestionStatusEnum> map = new HashMap<>();
......
......@@ -8,10 +8,10 @@ import java.util.Map;
@Getter
public enum StatusBcdEnum {
CARGANDO("CG"),
CARGADO("CGD"),
INDEXANDO("IDX"),
INDEXADO("IDXD");
CARGANDO("Cargando"),
CARGADO("Cargado"),
INDEXANDO("Indexando"),
INDEXADO("Indexado");
private static final Map<String, StatusBcdEnum> map = new HashMap<>();
......
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.repository;
import com.bytesw.bytebot.model.BdcControl;
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.util.Optional;
public interface BdcControlRepository extends CrudRepository<BdcControl, Long>, JpaSpecificationExecutor<BdcControl> {
@Query("select s from BdcControl s where s.uuid = :uuid")
Optional<BdcControl> findByUuid(@Param("uuid") String uuid);
}
......@@ -376,6 +376,7 @@ public class AgentService extends CustomPaginationService<Agent> {
for (FrequentQuestion frequentQuestion : agent.getFrequentQuestions()) {
FrequentQuestionBean frequentQuestionBean = new FrequentQuestionBean();
frequentQuestionBean.setId(frequentQuestion.getId());
frequentQuestionBean.setUuid(frequentQuestion.getUuid());
frequentQuestionBean.setDescription(frequentQuestion.getDescription());
frequentQuestionBean.setUser(frequentQuestion.getUser());
frequentQuestionBean.setFilename(frequentQuestion.getFilename());
......@@ -389,7 +390,6 @@ public class AgentService extends CustomPaginationService<Agent> {
}
// Deployment channel
bean.setDeploymentChannels(new ArrayList<>());
for (DeploymentChannel deploymentChannel : agent.getDeploymentChannels()) {
......@@ -462,6 +462,10 @@ public class AgentService extends CustomPaginationService<Agent> {
List<Channel> channels = (List<Channel>) channelRepository.findAll();
for (Channel channel : channels) {
List<ChannelParam> channelParamList = channel.getParameters();
for (ChannelParam channelParam : channelParamList) {
channelParam.setTraductions(channelParam.getTraductions().replace("\\", ""));
}
channelsBean.add(ChannelBean.clone(channel));
}
......
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.bytebot.bean.BdcControlBean;
import com.bytesw.bytebot.model.BdcControl;
import com.bytesw.bytebot.repository.BdcControlRepository;
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) {
public class BcdControlService extends XDFService<BdcControl, BdcControlBean, Long> {
protected BcdControlService(BdcControlRepository repository) {
super(repository);
}
@Override
protected BcdControl toModel(BcdControl model, BcdControlBean bean) {
protected BdcControl toModel(BdcControl model, BdcControlBean bean) {
if (model == null) {
model = new BcdControl();
model = new BdcControl();
}
BeanUtils.copyProperties(bean, model);
return model;
}
@Override
protected BcdControlBean toBean(BcdControl model) {
BcdControlBean bean = new BcdControlBean();
protected BdcControlBean toBean(BdcControl model) {
BdcControlBean bean = new BdcControlBean();
BeanUtils.copyProperties(model, bean);
return bean;
}
......
package com.bytesw.bytebot.service;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.DeleteObjectRequest;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.model.BusinessParameter;
import com.bytesw.bytebot.model.QuestionFile;
import com.bytesw.bytebot.repository.BusinessParameterRepository;
import com.bytesw.bytebot.repository.QuestionFileRepository;
import com.bytesw.xdf.exception.NotFoundException;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.PutObjectRequest;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.List;
import java.util.Optional;
@Service
@Log4j2
public class BucketService {
@Value("${application.bucket.tenant}")
private String tenant;
@Value("${application.bucket.region}")
private String region;
@Value("${application.bucket.fileBucket}")
private String fileDir;
@Value("${application.bucket.modelBucket}")
private String modelDir;
@Autowired
private QuestionFileRepository questionFileRepository;
@Autowired
private BusinessParameterRepository businessParameterRepository;
private AmazonS3 getS3Client() {
return AmazonS3ClientBuilder.standard()
.withRegion(region)
.build();
}
public boolean generate(byte[] file, FileValidationResponse response) {
Optional<BusinessParameter> businessParameter = businessParameterRepository.findByKey("Bucket");
boolean result = false;
if (!businessParameter.isPresent()) {
throw new NotFoundException("No existe el parametro de negocio del bucket.");
}
String bucketName = businessParameter.get().getDefaultValue();
File mainFile = new File(response.getFileName());
try {
FileOutputStream stream = new FileOutputStream(mainFile);
stream.write(file);
String newFile = String.format("%s/%s/1.0/%s/%s",tenant, response.getUuid(), fileDir, mainFile.getName());
PutObjectRequest request = new PutObjectRequest(bucketName, newFile, mainFile);
AmazonS3 amazonS3 = getS3Client();
amazonS3.putObject(request);
String modelFile = String.format("%s/%s/1.0/%s",tenant, response.getUuid(), modelDir);
createFolder(bucketName, modelFile, amazonS3);
mainFile.delete();
result = true;
} catch (Exception e) {
log.error("Error al cargar archivo");
}
return result;
}
public static void createFolder(String bucketName, String folderName, AmazonS3 client) {
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(0);
InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName,
folderName+"/", emptyContent, metadata);
client.putObject(putObjectRequest);
}
public void delete(String uuid) {
Optional<BusinessParameter> businessParameter = businessParameterRepository.findByKey("Bucket");
if (!businessParameter.isPresent()) {
throw new NotFoundException("No existe el parametro de negocio del bucket.");
}
String bucketName = businessParameter.get().getDefaultValue();
try {
AmazonS3 s3Client = getS3Client();
Optional<QuestionFile> questionFile = questionFileRepository.findByUuid(uuid);
if (!questionFile.isPresent()) {
throw new NotFoundException("El uuid no se encuentra enlazado con un file");
}
String keyName = String.format("%s/%s/1.0/%s/%s",tenant, uuid, fileDir, questionFile.get().getName());
s3Client.deleteObject(new DeleteObjectRequest(bucketName, keyName));
keyName = String.format("%s/%s/1.0/%s/",tenant, uuid, modelDir);
s3Client.deleteObject(new DeleteObjectRequest(bucketName, keyName));
} catch (AmazonServiceException e) {
e.printStackTrace();
} catch (SdkClientException e) {
e.printStackTrace();
}
}
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());
}
}
}
......@@ -5,6 +5,7 @@
*/
package com.bytesw.bytebot.service;
import com.bytesw.bytebot.etl.model.GoalForActions;
import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.http.FileValidationResult;
import com.bytesw.bytebot.http.enums.ValidationStatusEnum;
......@@ -16,12 +17,9 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import com.bytesw.xdf.exception.NotFoundException;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.ss.usermodel.Cell;
......@@ -282,4 +280,16 @@ public class FileManagementService {
}
return isFileHeader;
}
@Transactional(propagation = Propagation.REQUIRED)
public void deleteGoalForAction(Long id) {
Optional<QuestionFile> file = questionFileRepository.findById(id);
if (!file.isPresent()) {
throw new NotFoundException("File no econtrado.");
}
questionFileRepository.delete(file.get());
}
}
package com.bytesw.bytebot.service;
import com.bytesw.bytebot.etl.utils.JsonUtils;
import com.bytesw.bytebot.http.FileValidationResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.log4j.Log4j2;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@Service
@Log4j2
public class KnowledgeService {
@Value("${application.bucket.tenant}")
private String tenant;
@Value("${application.knowledge.url}")
private String url;
public boolean generate(FileValidationResponse response) throws IOException {
boolean result = false;
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(String.format("%s/clients/%s/versions/1.0", url, tenant));
String json = String.format("{\"filename_csv\": \"%s\", \"index_name\": \"%s\"}",response.getFileName(), response.getUuid());
StringEntity entity = new StringEntity(json);
try {
httppost.setEntity(entity);
httppost.setHeader("Accept", "application/json");
httppost.setHeader("Content-type", "application/json");
ResponseHandler<String> responseHandler = resp -> {
int status = resp.getStatusLine().getStatusCode();
if (status >= 200 && status < 300) {
HttpEntity entityRes = resp.getEntity();
return entityRes != null ? EntityUtils.toString(entityRes) : null;
} else {
throw new ClientProtocolException("Error inesperado: " + status);
}
};
String res = httpclient.execute(httppost, responseHandler);
String status = (String) JsonUtils.getFieldFromJson(res, "$.message.status");
if (status.equals("success")){
result = true;
}
} catch (IOException e) {
log.error(e.getMessage());
}
return result;
}
public boolean delete(String uuid) {
boolean result = false;
try {
HttpDelete httpDelete = new HttpDelete(String.format("%s/clients/%s/indexes/%s/versions/1.0", url, tenant, uuid));
System.out.println("Executing request " + httpDelete.getRequestLine());
ResponseHandler<String> responseHandler = response -> {
int status = response.getStatusLine().getStatusCode();
if (status >= 200 && status < 300) {
HttpEntity entity = response.getEntity();
return entity != null ? EntityUtils.toString(entity) : null;
} else {
throw new ClientProtocolException("Error inesperado: " + status);
}
};
CloseableHttpClient httpclient = HttpClients.createDefault();
String res = httpclient.execute(httpDelete, responseHandler);
httpclient.close();
String status = (String) JsonUtils.getFieldFromJson(res, "$.message.status");
if (status.equals("success")){
result = true;
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
}
package com.bytesw.bytebot.service;
import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.http.FileValidationResult;
import com.bytesw.bytebot.http.enums.ValidationStatusEnum;
import com.bytesw.bytebot.model.BdcControl;
import com.bytesw.bytebot.model.QuestionFile;
import com.bytesw.bytebot.model.enums.FrequentQuestionStatusEnum;
import com.bytesw.bytebot.model.enums.StatusBcdEnum;
import com.bytesw.bytebot.repository.BdcControlRepository;
import com.bytesw.bytebot.repository.QuestionFileRepository;
import com.bytesw.xdf.exception.NotFoundException;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Optional;
@Service
@Transactional
@Log4j2
public class OrquestadorService {
@Autowired
private FileManagementService fileManagementService;
@Autowired
private BucketService bucketService;
@Autowired
private BdcControlRepository bdcControlRepository;
@Autowired
private QuestionFileRepository questionFileRepository;
@Autowired
private KnowledgeService knowledgeService;
public FileValidationResponse executeGenerateBCD(String uuid, MultipartFile file) {
BdcControl model = new BdcControl();
FileValidationResponse response = new FileValidationResponse();
boolean step = false;
try{
//Valida y guarda en base de datos
response = fileManagementService.validateAndSaveFile(uuid,file);
if(response.getFileValidationResult().getStatus().getName() != ValidationStatusEnum.OK.getName()) {
response.setStatus(FrequentQuestionStatusEnum.ERROR.getName());
return response;
}
model.setUuid(response.getUuid());
model.setFileId(response.getId());
model.setFileName(response.getFileName());
model.setDate(response.getUploadDate());
model.setStatus(StatusBcdEnum.CARGADO.getName());
model = bdcControlRepository.save(model);
//Carga archivo a bucket
step = bucketService.generate(file.getBytes(), response);
if (!step) {
throw new NotFoundException("Error a cargar archivo.");
}
step = false;
model.setStatus(StatusBcdEnum.INDEXANDO.getName());
model = bdcControlRepository.save(model);
//Generacion del modelo
step = knowledgeService.generate(response);
if (!step) {
throw new NotFoundException("Error a cargar archivo.");
}
response.setStatus(FrequentQuestionStatusEnum.CORRECTO.getName());
model.setStatus(StatusBcdEnum.INDEXADO.getName());
model = bdcControlRepository.save(model);
}catch (Exception e) {
response.setStatus(FrequentQuestionStatusEnum.ERROR.getName());
}
return response;
}
public FileValidationResponse retry(String uuid) {
Optional<BdcControl> modelBdc = bdcControlRepository.findByUuid(uuid);
if (!modelBdc.isPresent()) {
throw new NotFoundException("No se subio archivo a la BD");
}
boolean step = false;
BdcControl model = modelBdc.get();
FileValidationResponse response = modelToFileValidation(model);
try {
if (model.getStatus().equals(StatusBcdEnum.CARGADO.getName())) {
Optional<QuestionFile> questionFile = questionFileRepository.findByUuid(uuid);
if (!questionFile.isPresent()) {
throw new NotFoundException("No se encontro archivo en la BD");
}
step = bucketService.generate(questionFile.get().getData(), response);
if (!step) {
throw new NotFoundException("Error a cargar archivo.");
}
model.setStatus(StatusBcdEnum.INDEXANDO.getName());
model = bdcControlRepository.save(model);
step = false;
}
if (model.getStatus().equals(StatusBcdEnum.INDEXANDO.getName())) {
step = knowledgeService.generate(response);
if (!step) {
throw new NotFoundException("Error a cargar knowledge.");
}
}
model.setStatus(StatusBcdEnum.INDEXADO.getName());
model = bdcControlRepository.save(model);
response.setStatus(FrequentQuestionStatusEnum.CORRECTO.getName());
} catch (IOException e) {
response.setStatus(FrequentQuestionStatusEnum.ERROR.getName());
}
return response;
}
public void deleteBcd(String uuid) {
Optional<BdcControl> bdcControl = bdcControlRepository.findByUuid(uuid);
if (!bdcControl.isPresent()) {
throw new NotFoundException("Control no encontrado.");
}
BdcControl model = bdcControl.get();
if (model.getStatus().equals(StatusBcdEnum.INDEXADO.getName())) {
boolean step = knowledgeService.delete(uuid);
if (!step) {
throw new NotFoundException("Error a eliminar modelo del bucket");
}
model.setStatus(StatusBcdEnum.INDEXANDO.getName());
model = bdcControlRepository.save(model);
}
if (model.getStatus().equals(StatusBcdEnum.INDEXANDO.getName())) {
bucketService.delete(uuid);
model.setStatus(StatusBcdEnum.CARGADO.getName());
model = bdcControlRepository.save(model);
}
Optional<QuestionFile> questionFile = questionFileRepository.findByUuid(uuid);
if (questionFile.isPresent()) {
questionFileRepository.deleteById(bdcControl.get().getFileId());
}
bdcControlRepository.delete(model);
}
private FileValidationResponse modelToFileValidation(BdcControl model){
FileValidationResponse response = new FileValidationResponse();
response.setId(model.getId());
response.setStatus(model.getStatus());
response.setUuid(model.getUuid());
response.setFileName(model.getFileName());
response.setUploadDate(model.getDate());
FileValidationResult result = new FileValidationResult();
result.setStatus(ValidationStatusEnum.OK);
response.setFileValidationResult(result);
return response;
}
}
......@@ -4,7 +4,8 @@ server:
servlet.context-path: ${APPLICATION_PATH:/bytebot}
port: ${APPLICATION_PORT:9077}
web:
static-content-location: file:/home/cristian/Documents/AVB_Backend/bytebot-html/
#static-content-location: file:/home/mgutierrez/Documentos/Bytesw/bytebot-workspace/dist/bytebot-html/
static-content-location: file:/home/mgutierrez/Descargas/dist-1/dist/bytebot-html/
#NOTA debe terminar con /
security:
......@@ -55,7 +56,7 @@ application:
multi-tenant-conf:
exclude-service: /
authorization-service.url: http://localhost:17580
security: oauth2sso # none, basic, oauth2sso
security: none #oauth2sso # none, basic, oauth2sso
security.method: true
security-exclude: /service/oauth/userinfo, /actuator/**, /mylogout, /login, /logout, /goodbye, /error, /anon, /cache.manifest, /favicon.ico, /service/file, /goodbye /byteboot
messaging:
......@@ -93,6 +94,13 @@ application:
host: localhost
port: 8161
queue-name: task_queue
bucket:
tenant: T186A1
region: us-east-1
fileBucket: KB_Files
modelBucket: KB_Model
knowledge:
url: "http://127.0.0.1:3000/byteknowledgebaseApi"
spring:
main:
......@@ -104,7 +112,7 @@ spring:
datasource:
database-type: postgres
schemaName: avb
url: jdbc:postgresql://localhost:5432/bytebot?useSSL=false&currentSchema=avb
url: jdbc:postgresql://192.168.0.115:5432/bytebot?useSSL=false&currentSchema=avb
driverClassName: 'org.postgresql.Driver'
username: postgres
password: postgres
......@@ -120,11 +128,11 @@ spring:
oauth2-client:
clientId: xdf-client
clientSecret: xdf-secret
accessTokenUri: http://192.168.1.6:18080/oauth/token
userAuthorizationUri: http://192.168.1.6:18080/oauth/authorize
accessTokenUri: http://192.168.0.115:18080/oauth/token
userAuthorizationUri: http://192.168.0.115:18080/oauth/authorize
oauth2-resource:
userInfoUri: http://192.168.1.6:18080/oauth/userinfo
logoutUri: http://192.168.1.6:18080/oauth/userlogout
userInfoUri: http://192.168.0.115:18080/oauth/userinfo
logoutUri: http://192.168.0.115:18080/oauth/userlogout
tenants:
-
id: T186A1
......@@ -132,7 +140,7 @@ spring:
datasource:
database-type: postgres
schemaName: avb
url: jdbc:postgresql://localhost:5432/bytebot?useSSL=false&currentSchema=avb
url: jdbc:postgresql://192.168.0.115:5432/bytebot?useSSL=false&currentSchema=avb
driverClassName: 'org.postgresql.Driver'
username: postgres
password: postgres
......@@ -142,16 +150,16 @@ spring:
testWhileIdle: true
hikari.registerMbeans: true
security:
basepath: http://192.168.1.6:9077/bytebot
basepath: http://localhost:9077/bytebot
provider: byte # oracle, amazon
oauth2-client:
clientId: xdf-client
clientSecret: xdf-secret
accessTokenUri: http://192.168.1.6:18080/oauth/token
userAuthorizationUri: http://192.168.1.6:18080/oauth/authorize
accessTokenUri: http://192.168.0.115:18080/oauth/token
userAuthorizationUri: http://192.168.0.115:18080/oauth/authorize
oauth2-resource:
userInfoUri: http://192.168.1.6:18080/oauth/userinfo
logoutUri: http://192.168.1.6:18080/oauth/userlogout
userInfoUri: http://192.168.0.115:18080/oauth/userinfo
logoutUri: http://192.168.0.115:18080/oauth/userlogout
jpa:
......@@ -174,11 +182,11 @@ batch:
datasource:
jdbc-driver: 'org.postgresql.Driver'
username: postgres
password:
jdbc-url: jdbc:postgresql://192.168.21.74:5432/avb?useSSL=false
password: postgres
jdbc-url: jdbc:postgresql://localhost:5432/bytebot?useSSL=false&currentSchema=avb
query: 'select * from events WHERE id > %d order by id asc'
logging.level.root: DEBUG
logging.level.root: INFO
logging.pattern.console: '%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger.%M - %msg%n'
logging.level.com.zaxxer.hikari: ERROR
......
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