Commit ba62812c authored by Roberto Loayza's avatar Roberto Loayza

Despliegue de base de conocimiento.

parent 53a752db
......@@ -185,7 +185,6 @@ public class ScheduleService implements SchedulingConfigurer {
} else {
timeZone = TimeZone.getDefault();
}
System.out.println(timeZone);
Trigger trigger = new CronTrigger(cronExpression, timeZone);
/* ETL de Dashboard */
......@@ -222,6 +221,13 @@ public class ScheduleService implements SchedulingConfigurer {
future.cancel(true);
futureMap.remove(key);
}
if (!keys.isEmpty()) {
for (String Key: keys) {
ScheduledFuture future = futureMap.get(Key);
future.cancel(true);
futureMap.remove(key);
}
}
}
/*ETL eliminacion de data sensible*/
......@@ -230,7 +236,6 @@ public class ScheduleService implements SchedulingConfigurer {
OffsetTime actual = OffsetTime.now();
for(WeekScheduler weekScheduler: dates.get()) {
if (actual.isBefore(weekScheduler.getTo()) && actual.isAfter(weekScheduler.getFrom())) {
//schedulerFlag = true;
Optional<List<CalendarExceptionFull>> calendarException = calendarExceptionFullRepository.findByCalendarId(calendarId);
if (calendarException.isPresent()){
schedulerFlag = validateException(calendarException.get());
......@@ -242,12 +247,12 @@ public class ScheduleService implements SchedulingConfigurer {
}
if (schedulerFlag) {
Trigger trigger = new CronTrigger(cronExpression, timeZone);
List<DeleteDataSensBean> deleteDataSensBeans = deleteDataSensJDBCRepository
.getListAgentChannel(AgentStatusEnum.DEPLOYED.getName(), AgentParameterEnum.ACCESS_TWILIO.getName());
String keyDataSens = "";
for (DeleteDataSensBean data : deleteDataSensBeans) {
Agent agent = agentRepository.findById(data.getAgenId()).get();
Trigger trigger = new CronTrigger(cronExpression, timeZone);
keyDataSens = String.format("deleteSensible-%s-%s", tenantIdentifier, data.getValue());
if (!futureMap.containsKey(keyDataSens)) {
keys.add(keyDataSens);
......@@ -324,7 +329,7 @@ public class ScheduleService implements SchedulingConfigurer {
private ItemReader getReader(String tenantIdentifier) {
if (properties == null) {
throw new RuntimeException("Prope rties not found");
throw new RuntimeException("Properties not found");
}
Optional<TenantBatchBean> tenantFound = findTenant(tenantIdentifier);
......
......@@ -5,6 +5,7 @@
*/
package com.bytesw.bytebot.service;
import com.amazonaws.services.dynamodbv2.xspec.S;
import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.http.FileValidationResult;
import com.bytesw.bytebot.http.enums.ValidationStatusEnum;
......@@ -129,8 +130,9 @@ public class FileManagementService {
//@Validaciones: De Contenido(Todos deben tener valor)
int rowNumber = 0;
int rowError = 0;
Iterator<Row> rowIterator = sheet.iterator();
Map<Integer, Object> recordsRowErrorMap = new HashMap<>();;
Map<Integer, Object> recordsRowErrorMap = new HashMap<>();
while (rowIterator.hasNext()) {
Row row = (Row) rowIterator.next();
......@@ -193,12 +195,20 @@ public class FileManagementService {
if (!recordsErrorMap.isEmpty()) {
if (recordsErrorMap.size() != fileHeaders.length){
recordsRowErrorMap.put(rowNumber + 1, recordsErrorMap);
} else {
rowError++;
}
}
rowNumber++;
}
if (rowError > 0) {
Map<String, String> rowErrorResult = new HashMap<>();
rowErrorResult.put("ROW.NULL", "ROW.DATA.NULL");
recordsRowErrorMap.put(rowError, rowErrorResult);
}
if (!recordsRowErrorMap.isEmpty()) {
log.info("Hay errores en el contenido del archivo: " + recordsRowErrorMap);
result.setStatus(ValidationStatusEnum.CONTENT_ERROR);
......@@ -246,44 +256,88 @@ public class FileManagementService {
String line;
InputStream is = file.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
Map<String, String> headerErrorMap = new HashMap<>();
Map<Integer, Object> recordsRowErrorMap = new HashMap<>();
int rowData = 1;
while ((line = br.readLine()) != null) {
List<String> row = new ArrayList<>();
String[] data = line.split(";");
if (data.length != fileHeaders.length) {
Map<String, String> dataError = new HashMap<>();
dataError.put("DATA", "DATA.INCOMPLETE");
result.setHeadersErrorMap(dataError);
result.setStatus(ValidationStatusEnum.ERROR);
response.setFileValidationResult(result);
return response;
if (data.length <= 1) {
headerErrorMap.put("FORMAT.SEPARATION", "ERROR.SEPARATION.FORMAT");
}
if (data.length < fileHeaders.length) {
Map<String, String> recordsErrorMap = new HashMap<>();
recordsErrorMap.put(ValidationStatusEnum.DATA_INCOMPLETE.getName(), "DATA.INCOMPLETE");
recordsRowErrorMap.put(rowData, recordsErrorMap);
}
for (String dato : data) {
if (validateData(dato)) {
Map<String, String> errorFormat = new HashMap<>();
errorFormat.put("DATA", "FORMAT.INCORRECT");
result.setHeadersErrorMap(errorFormat);
result.setStatus(ValidationStatusEnum.ERROR);
response.setFileValidationResult(result);
return response;
headerErrorMap.put("FORMAT.DATA", "WRONG.DATA.INCORRECT");
}
row.add(dato);
}
rowData++;
rows.add(row);
}
if(!headerErrorMap.isEmpty()) {
result.setHeadersErrorMap(headerErrorMap);
result.setStatus(ValidationStatusEnum.HEADER_ERROR);
response.setFileValidationResult(result);
return response;
}
if (!recordsRowErrorMap.isEmpty()) {
log.info("Hay errores en el contenido del archivo: " + recordsRowErrorMap);
result.setStatus(ValidationStatusEnum.CONTENT_ERROR);
result.setRecordsErrorMap(recordsRowErrorMap);
response.setFileValidationResult(result);
return response;
}
List<String> headersList = new ArrayList<>();
for (String header: rows.get(0)) {
headersList.add(header.replace('"', ' '));
}
Map<String, String> headerErrorMap = validateHeaders(headersList);
headerErrorMap = validateHeaders(headersList);
if (!headerErrorMap.isEmpty()) {
result.setHeadersErrorMap(headerErrorMap);
result.setStatus(ValidationStatusEnum.ERROR);
result.setStatus(ValidationStatusEnum.HEADER_ERROR);
response.setFileValidationResult(result);
return response;
}
rows.remove(0);
} catch (IOException e) {
System.err.println(e.getMessage());
}
int rowNumber = 0;
Map<Integer, Object> recordsRowErrorMap = new HashMap<>();
for (List<String> item: rows) {
Map<String, Object> recordsXRow = new HashMap<>();
Map<String, String> recordsErrorMap = validateRecordsXRow(recordsXRow);
if (!recordsErrorMap.isEmpty()) {
if (recordsErrorMap.size() != fileHeaders.length){
recordsRowErrorMap.put(rowNumber + 1, recordsErrorMap);
}
}
rowNumber++;
}
if (!recordsRowErrorMap.isEmpty()) {
log.info("Hay errores en el contenido del archivo: " + recordsRowErrorMap);
result.setStatus(ValidationStatusEnum.CONTENT_ERROR);
result.setRecordsErrorMap(recordsRowErrorMap);
response.setFileValidationResult(result);
return response;
}
result.setStatus(ValidationStatusEnum.OK);
QuestionFile questionFileBD = new QuestionFile();
......@@ -326,7 +380,7 @@ public class FileManagementService {
}
for (String header : headersList) {
if (header.toUpperCase().trim().equalsIgnoreCase(keyHeader)) {
if (header.toUpperCase().trim().equals(keyHeader)) {
int ocurrences = headerOcurrencesMap.get(keyHeader);
headerOcurrencesMap.put(keyHeader, ocurrences + 1);
headerOrganized.put(keyHeader, index);
......
......@@ -48,6 +48,7 @@ public class KnowledgeService {
};
String res = httpclient.execute(httppost, responseHandler);
String status = (String) JsonUtils.getFieldFromJson(res, "$.message.status");
httpclient.close();
if (status.equals("success")){
result = true;
}
......
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