Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ejercicio2-framework-back
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josue
ejercicio2-framework-back
Commits
60f4a48c
Commit
60f4a48c
authored
Jan 09, 2022
by
Roberto Loayza Miljanovich
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_marcos' into 'developer'
Dev marcos See merge request ByteBot/web/bytebot-service!22
parents
d136e061
4e812b11
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
525 additions
and
138 deletions
+525
-138
pom.xml
pom.xml
+1
-1
AgentController.java
...n/java/com/bytesw/bytebot/controller/AgentController.java
+8
-6
HealthController.java
.../java/com/bytesw/bytebot/controller/HealthController.java
+0
-15
ScheduleService.java
...com/bytesw/bytebot/etl/batch/service/ScheduleService.java
+85
-11
DataSensibleJPAWriter.java
...ytesw/bytebot/etl/batch/writer/DataSensibleJPAWriter.java
+3
-3
Intent.java
src/main/java/com/bytesw/bytebot/etl/model/Intent.java
+0
-1
UserMessageProcessed.java
...com/bytesw/bytebot/etl/services/UserMessageProcessed.java
+2
-2
FileValidationResponse.java
.../java/com/bytesw/bytebot/http/FileValidationResponse.java
+1
-0
ValidationStatusEnum.java
...a/com/bytesw/bytebot/http/enums/ValidationStatusEnum.java
+2
-0
Agent.java
src/main/java/com/bytesw/bytebot/model/Agent.java
+2
-0
AnnualCalendarException.java
...ava/com/bytesw/bytebot/model/AnnualCalendarException.java
+1
-1
Calendar.java
src/main/java/com/bytesw/bytebot/model/Calendar.java
+1
-1
CalendarException.java
...main/java/com/bytesw/bytebot/model/CalendarException.java
+1
-1
CalendarExceptionFull.java
.../java/com/bytesw/bytebot/model/CalendarExceptionFull.java
+0
-5
Channel.java
src/main/java/com/bytesw/bytebot/model/Channel.java
+2
-0
ChannelParam.java
src/main/java/com/bytesw/bytebot/model/ChannelParam.java
+2
-0
Country.java
src/main/java/com/bytesw/bytebot/model/Country.java
+2
-0
DeploymentChannel.java
...main/java/com/bytesw/bytebot/model/DeploymentChannel.java
+2
-0
DeploymentChannelParamValue.java
...com/bytesw/bytebot/model/DeploymentChannelParamValue.java
+2
-0
FrequentQuestion.java
src/main/java/com/bytesw/bytebot/model/FrequentQuestion.java
+4
-4
ProcessETL.java
src/main/java/com/bytesw/bytebot/model/ProcessETL.java
+1
-1
QuestionFile.java
src/main/java/com/bytesw/bytebot/model/QuestionFile.java
+2
-0
RangeCalendarException.java
...java/com/bytesw/bytebot/model/RangeCalendarException.java
+1
-1
SchedulerTask.java
src/main/java/com/bytesw/bytebot/model/SchedulerTask.java
+1
-1
Timezone.java
src/main/java/com/bytesw/bytebot/model/Timezone.java
+2
-1
UniqueCalendarException.java
...ava/com/bytesw/bytebot/model/UniqueCalendarException.java
+1
-1
UniqueWeeklyCalendarException.java
...m/bytesw/bytebot/model/UniqueWeeklyCalendarException.java
+1
-1
WeekScheduler.java
src/main/java/com/bytesw/bytebot/model/WeekScheduler.java
+1
-1
FrequentQuestionStatusConverter.java
...bot/model/converters/FrequentQuestionStatusConverter.java
+3
-1
StatusConverter.java
.../com/bytesw/bytebot/model/converters/StatusConverter.java
+3
-0
SFTPRoute.java
src/main/java/com/bytesw/bytebot/routes/SFTPRoute.java
+5
-5
AgentService.java
src/main/java/com/bytesw/bytebot/service/AgentService.java
+5
-2
BucketService.java
src/main/java/com/bytesw/bytebot/service/BucketService.java
+38
-12
FileManagementService.java
...ava/com/bytesw/bytebot/service/FileManagementService.java
+178
-13
KnowledgeService.java
...ain/java/com/bytesw/bytebot/service/KnowledgeService.java
+7
-8
OrquestadorService.java
...n/java/com/bytesw/bytebot/service/OrquestadorService.java
+88
-19
SchedulerTaskService.java
...java/com/bytesw/bytebot/service/SchedulerTaskService.java
+42
-0
application.yml
src/main/resources/application.yml
+25
-20
No files found.
pom.xml
View file @
60f4a48c
...
...
@@ -9,7 +9,7 @@
<packaging>
jar
</packaging>
<properties>
<xdf.version>
3.
3
.0
</xdf.version>
<xdf.version>
3.
4
.0
</xdf.version>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
...
...
src/main/java/com/bytesw/bytebot/controller/AgentController.java
View file @
60f4a48c
...
...
@@ -11,6 +11,8 @@ import com.google.gson.GsonBuilder;
import
io.swagger.annotations.ApiParam
;
import
java.security.Principal
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
import
lombok.extern.log4j.Log4j2
;
...
...
@@ -104,7 +106,6 @@ public class AgentController {
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Error detectado: "
,
e
);
hs
=
HttpStatus
.
INTERNAL_SERVER_ERROR
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
ExceptionUtils
.
getFullStackTrace
(
e
)),
hs
);
}
...
...
@@ -175,8 +176,8 @@ public class AgentController {
return
new
ResponseEntity
<>(
gson
.
toJson
(
response
),
HttpStatus
.
OK
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
@PutMapping
(
"/file-upload/{uuid}"
)
...
...
@@ -195,13 +196,14 @@ public class AgentController {
@DeleteMapping
(
"/file-upload/{uuid}"
)
public
ResponseEntity
<
String
>
deleteBdc
(
@ApiParam
(
value
=
"uuid"
,
required
=
true
)
@PathVariable
(
"uuid"
)
String
uuid
)
{
Gson
gson
=
gsonBuilder
.
create
();
Map
<
String
,
String
>
resp
=
new
HashMap
<>();
try
{
orquestadorService
.
deleteBcd
(
uuid
);
String
response
=
"Todo Ok"
;
return
new
ResponseEntity
<>(
gson
.
toJson
(
resp
onse
),
HttpStatus
.
OK
);
resp
.
put
(
"message"
,
"OK"
)
;
return
new
ResponseEntity
<>(
gson
.
toJson
(
resp
),
HttpStatus
.
OK
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error detectado: "
,
e
);
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
resp
.
put
(
"message"
,
"ERROR"
);
return
new
ResponseEntity
<>(
gson
.
toJson
(
resp
),
HttpStatus
.
OK
);
}
}
...
...
src/main/java/com/bytesw/bytebot/controller/HealthController.java
deleted
100644 → 0
View file @
d136e061
package
com
.
bytesw
.
bytebot
.
controller
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
public
class
HealthController
{
@GetMapping
(
"/health"
)
public
ResponseEntity
<
Void
>
health
()
{
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
}
}
src/main/java/com/bytesw/bytebot/etl/batch/service/ScheduleService.java
View file @
60f4a48c
...
...
@@ -65,7 +65,7 @@ public class ScheduleService implements SchedulingConfigurer {
@Qualifier
(
"schedulerLockTaskScheduler"
)
TaskScheduler
poolScheduler
;
@Value
(
"${application.byte-bot.batch.cron
: 0 0/1 * * * *
}"
)
@Value
(
"${application.byte-bot.batch.cron}"
)
private
String
cronExpression
;
@Value
(
"${application.byte-bot.batch.chunk:500}"
)
...
...
@@ -135,10 +135,25 @@ public class ScheduleService implements SchedulingConfigurer {
@Autowired
private
CalendarExceptionFullRepository
calendarExceptionFullRepository
;
@Autowired
private
BusinessParameterRepository
businessParameterRepository
;
private
boolean
schedulerFlag
=
false
;
private
List
<
String
>
keys
=
new
ArrayList
<>();
private
String
tenant
;
private
ScheduledTaskRegistrar
taskRegister
;
private
TimeZone
timeZone
;
@Value
(
"${application.timezone.zone}"
)
private
String
parameter
;
@Value
(
"${application.timezone.default}"
)
private
String
zoneDefault
;
@Override
public
void
configureTasks
(
ScheduledTaskRegistrar
taskRegistrar
)
{
if
(
scheduledTaskRegistrar
==
null
)
{
...
...
@@ -168,7 +183,16 @@ public class ScheduleService implements SchedulingConfigurer {
}
private
void
configureTask
(
String
tenantIdentifier
,
String
identifier
,
ScheduledTaskRegistrar
taskRegistrar
)
{
Trigger
trigger
=
new
CronTrigger
(
cronExpression
,
TimeZone
.
getDefault
());
tenant
=
tenantIdentifier
;
taskRegister
=
taskRegistrar
;
Optional
<
BusinessParameter
>
zone
=
businessParameterRepository
.
findByKey
(
parameter
);
if
(
zone
.
isPresent
())
{
timeZone
=
TimeZone
.
getTimeZone
(
zone
.
get
().
getDefaultValue
());
}
else
{
timeZone
=
TimeZone
.
getTimeZone
(
zoneDefault
);
}
Trigger
trigger
=
new
CronTrigger
(
cronExpression
,
timeZone
);
/* ETL de Dashboard */
String
key
=
String
.
format
(
"%s-%s"
,
tenantIdentifier
,
identifier
);
futureMap
.
put
(
key
,
taskRegistrar
.
getScheduler
().
schedule
(()
->
scheduleCron
(
createJob
(
tenantIdentifier
),
tenantIdentifier
),
trigger
));
...
...
@@ -179,40 +203,85 @@ public class ScheduleService implements SchedulingConfigurer {
/* Busca las listas de SchedulerTask */
List
<
SchedulerTask
>
listSchedulerTask
=
schedulerTaskRepository
.
findByEtlId
(
processDelete
.
getId
());
for
(
SchedulerTask
schedulerTask
:
listSchedulerTask
)
{
Trigger
triggerDelete
=
new
CronTrigger
(
schedulerTask
.
getCronExpression
(),
TimeZone
.
getDefault
()
);
String
keyScheduler
=
String
.
format
(
"%s-%s
"
,
tenantIdentifier
,
schedulerTask
.
getCalendarID
());
Trigger
triggerDelete
=
new
CronTrigger
(
schedulerTask
.
getCronExpression
(),
timeZone
);
String
keyScheduler
=
String
.
format
(
"%s-%s
-%s"
,
tenantIdentifier
,
schedulerTask
.
getCalendarID
().
trim
(),
schedulerTask
.
getId
());
futureMap
.
put
(
keyScheduler
,
taskRegistrar
.
getScheduler
()
.
schedule
(()
->
processDeleteData
(
tenantIdentifier
,
taskRegistrar
,
schedulerTask
.
getCalendarID
().
trim
()),
triggerDelete
));
}
}
public
void
restartTask
(
SchedulerTask
model
)
{
String
key
=
String
.
format
(
"%s-%s-%s"
,
tenant
,
model
.
getCalendarID
().
trim
(),
model
.
getId
());
Trigger
trigger
=
new
CronTrigger
(
model
.
getCronExpression
(),
timeZone
);
if
(
futureMap
.
containsKey
(
key
))
{
cancelTask
(
model
);
}
futureMap
.
put
(
key
,
taskRegister
.
getScheduler
()
.
schedule
(()
->
processDeleteData
(
tenant
,
taskRegister
,
model
.
getCalendarID
().
trim
()),
trigger
));
}
public
void
cancelTaskDelete
(
Long
id
)
{
String
keyDataSens
=
String
.
format
(
"deleteSensible-%s-%s"
,
tenant
,
id
);
if
(
futureMap
.
containsKey
(
keyDataSens
))
{
ScheduledFuture
future
=
futureMap
.
get
(
keyDataSens
);
future
.
cancel
(
true
);
futureMap
.
remove
(
keyDataSens
);
if
(
keys
.
contains
(
keyDataSens
))
{
keys
.
remove
(
keyDataSens
);
}
}
}
public
void
cancelTask
(
SchedulerTask
model
)
{
String
key
=
String
.
format
(
"%s-%s-%s"
,
tenant
,
model
.
getCalendarID
().
trim
(),
model
.
getId
());
if
(
futureMap
.
containsKey
(
key
)){
ScheduledFuture
future
=
futureMap
.
get
(
key
);
future
.
cancel
(
true
);
futureMap
.
remove
(
key
);
}
if
(!
keys
.
isEmpty
())
{
for
(
String
keyTask:
keys
)
{
if
(
futureMap
.
containsKey
(
keyTask
))
{
ScheduledFuture
future
=
futureMap
.
get
(
keyTask
);
future
.
cancel
(
true
);
futureMap
.
remove
(
keyTask
);
}
}
}
}
/*ETL eliminacion de data sensible*/
public
void
processDeleteData
(
String
tenantIdentifier
,
ScheduledTaskRegistrar
taskRegistrar
,
String
calendarId
)
{
Optional
<
BusinessParameter
>
zone
=
businessParameterRepository
.
findByKey
(
parameter
);
if
(
zone
.
isPresent
())
{
timeZone
=
TimeZone
.
getTimeZone
(
zone
.
get
().
getDefaultValue
());
}
else
{
timeZone
=
TimeZone
.
getTimeZone
(
zoneDefault
);
}
Optional
<
List
<
WeekScheduler
>>
dates
=
weekSchedulerRepository
.
findByCalendarId
(
calendarId
);
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
());
break
;
}
else
{
schedulerFlag
=
true
;
}
}
else
{
schedulerFlag
=
false
;
}
}
if
(
schedulerFlag
)
{
Trigger
trigger
=
new
CronTrigger
(
cronExpression
,
TimeZone
.
getDefault
());
List
<
DeleteDataSensBean
>
deleteDataSensBeans
=
deleteDataSensJDBCRepository
.
getListAgentChannel
(
AgentStatusEnum
.
DEPLOYED
.
getName
(),
AgentParameterEnum
.
ACCESS_TWILIO
.
getName
());
String
keyDataSens
=
""
;
for
(
DeleteDataSensBean
data
:
deleteDataSensBeans
)
{
keyDataSens
=
String
.
format
(
"deleteSensible-%s-%s"
,
tenantIdentifier
,
data
.
getValue
());
Agent
agent
=
agentRepository
.
findById
(
data
.
getAgenId
()).
get
();
Trigger
trigger
=
new
CronTrigger
(
"0 0/1 * * * *"
,
timeZone
);
keyDataSens
=
String
.
format
(
"deleteSensible-%s-%s"
,
tenantIdentifier
,
data
.
getAgenId
());
if
(!
futureMap
.
containsKey
(
keyDataSens
))
{
keys
.
add
(
keyDataSens
);
futureMap
.
put
(
keyDataSens
,
taskRegistrar
.
getScheduler
()
...
...
@@ -221,7 +290,11 @@ public class ScheduleService implements SchedulingConfigurer {
}
}
else
{
keys
.
forEach
(
x
->
{
futureMap
.
remove
(
x
);
if
(
futureMap
.
containsKey
(
x
))
{
ScheduledFuture
future
=
futureMap
.
get
(
x
);
future
.
cancel
(
true
);
futureMap
.
remove
(
x
);
}
});
}
}
...
...
@@ -303,8 +376,9 @@ public class ScheduleService implements SchedulingConfigurer {
/* Métodos ETL de data sensible */
private
Job
createJobDataSens
(
String
tenantIdentifier
,
DeleteDataSensBean
data
)
{
System
.
out
.
println
(
"ETL de eliminacion"
);
ThreadLocalStorage
.
setTenantName
(
tenantIdentifier
);
return
jobBuilderFactory
.
get
(
String
.
format
(
"processDataSensible%d"
,+
data
.
getAgenId
()))
return
jobBuilderFactory
.
get
(
String
.
format
(
"processDataSensible
-
%d"
,+
data
.
getAgenId
()))
.
incrementer
(
new
RunIdIncrementer
()).
listener
(
listener
)
.
flow
(
createStepDataSens
(
tenantIdentifier
,
data
)).
end
().
build
();
}
...
...
src/main/java/com/bytesw/bytebot/etl/batch/writer/DataSensibleJPAWriter.java
View file @
60f4a48c
...
...
@@ -58,7 +58,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
@Override
@Transactional
public
void
write
(
List
<?
extends
DynaBean
>
list
)
throws
Exception
{
Object
numeros
=
JsonUtils
.
getFieldFromJson
(
agent
.
getChannelValue
(),
"$.telefono
s_desplegados
"
);
Object
numeros
=
JsonUtils
.
getFieldFromJson
(
agent
.
getChannelValue
(),
"$.telefono
_despliegue
"
);
List
<
String
>
numerosAgentes
=
numbersAgent
((
List
<
Map
>)
numeros
);
for
(
DynaBean
dynaBean
:
list
)
{
Long
id
=
Long
.
parseLong
(
dynaBean
.
get
(
"id"
).
toString
());
...
...
@@ -75,7 +75,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
if
(
toAgent
==
null
)
{
continue
;
}
if
(
toAgent
.
isEmpty
())
{
if
(
!
toAgent
.
isEmpty
())
{
agentNumber
=
toAgent
.
split
(
":"
)[
1
];
}
if
(
numerosAgentes
.
contains
(
agentNumber
))
{
...
...
@@ -142,7 +142,7 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
private
List
<
String
>
numbersAgent
(
List
<
Map
>
listNumber
){
List
<
String
>
result
=
new
ArrayList
<>();
for
(
Map
map
:
listNumber
){
String
cod
=
(
String
)
map
.
get
(
"
C
odigoInternacional"
);
String
cod
=
(
String
)
map
.
get
(
"
c
odigoInternacional"
);
String
number
=
(
String
)
map
.
get
(
"numero"
);
String
agent
=
"+"
+
cod
+
number
;
result
.
add
(
agent
);
...
...
src/main/java/com/bytesw/bytebot/etl/model/Intent.java
View file @
60f4a48c
...
...
@@ -6,7 +6,6 @@ import lombok.ToString;
import
javax.persistence.*
;
//AVB_INTENT
@Cacheable
(
false
)
@Entity
@Getter
@Setter
@ToString
...
...
src/main/java/com/bytesw/bytebot/etl/services/UserMessageProcessed.java
View file @
60f4a48c
...
...
@@ -164,7 +164,7 @@ public class UserMessageProcessed extends MessageProcessedSupport implements Mes
List
<
DeleteDataSensBean
>
deleteDataSensBeans
=
deleteDataSensJDBCRepository
.
getListAgentChannel
(
AgentStatusEnum
.
DEPLOYED
.
getName
(),
AgentParameterEnum
.
ACCESS_TWILIO
.
getName
());
for
(
DeleteDataSensBean
deleteDataSensBean:
deleteDataSensBeans
)
{
Object
numeros
=
JsonUtils
.
getFieldFromJson
(
deleteDataSensBean
.
getChannelValue
(),
"$.telefono
s_desplegados
"
);
Object
numeros
=
JsonUtils
.
getFieldFromJson
(
deleteDataSensBean
.
getChannelValue
(),
"$.telefono
_despliegue
"
);
List
<
String
>
numerosAgentes
=
numbersAgent
((
List
<
Map
>)
numeros
);
if
(
numerosAgentes
.
contains
(
number
))
{
agentId
=
deleteDataSensBean
.
getAgenId
();
...
...
@@ -178,7 +178,7 @@ public class UserMessageProcessed extends MessageProcessedSupport implements Mes
private
List
<
String
>
numbersAgent
(
List
<
Map
>
listNumber
){
List
<
String
>
result
=
new
ArrayList
<>();
for
(
Map
map
:
listNumber
){
String
cod
=
(
String
)
map
.
get
(
"
C
odigoInternacional"
);
String
cod
=
(
String
)
map
.
get
(
"
c
odigoInternacional"
);
String
number
=
(
String
)
map
.
get
(
"numero"
);
String
agent
=
"+"
+
cod
+
number
;
result
.
add
(
agent
);
...
...
src/main/java/com/bytesw/bytebot/http/FileValidationResponse.java
View file @
60f4a48c
...
...
@@ -17,6 +17,7 @@ public class FileValidationResponse {
private
String
status
;
private
String
user
;
private
String
uploadDate
;
private
String
message
;
private
FileValidationResult
fileValidationResult
;
}
src/main/java/com/bytesw/bytebot/http/enums/ValidationStatusEnum.java
View file @
60f4a48c
...
...
@@ -12,6 +12,8 @@ import java.util.NoSuchElementException;
public
enum
ValidationStatusEnum
{
OK
(
"OK"
),
ERROR
(
"ERROR"
),
DATA_INCOMPLETE
(
"DI"
),
FORMAT_INCORRECT
(
"FI"
),
INCOMPATIBLE_EXTENSION
(
"IE"
),
HEADER_ERROR
(
"HE"
),
CONTENT_ERROR
(
"CE"
);
...
...
src/main/java/com/bytesw/bytebot/model/Agent.java
View file @
60f4a48c
...
...
@@ -8,11 +8,13 @@ import com.bytesw.bytebot.model.enums.AgentTypeEnum;
import
com.bytesw.bytebot.model.enums.LanguageEnum
;
import
lombok.*
;
import
org.hibernate.annotations.Type
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.List
;
@Audited
@Entity
@Getter
@Setter
@EqualsAndHashCode
(
of
=
"id"
)
@NoArgsConstructor
...
...
src/main/java/com/bytesw/bytebot/model/AnnualCalendarException.java
View file @
60f4a48c
...
...
@@ -11,7 +11,7 @@ import javax.persistence.DiscriminatorValue;
import
javax.persistence.Entity
;
import
javax.persistence.NamedQuery
;
//
@Audited
@Audited
@Entity
@DiscriminatorValue
(
value
=
AnnualCalendarException
.
DISCRIMINATOR_VALUE
)
@NamedQuery
(
name
=
"AnnualCalendarException.findByPK"
,
query
=
"Select u from AnnualCalendarException u where u.id = ?1"
)
...
...
src/main/java/com/bytesw/bytebot/model/Calendar.java
View file @
60f4a48c
...
...
@@ -10,7 +10,7 @@ import javax.persistence.*;
import
java.io.Serializable
;
import
java.util.List
;
//
@Audited
@Audited
@Entity
@Table
(
name
=
"AVB_CALENDAR"
)
@NamedQuery
(
name
=
"Calendar.findByPK"
,
query
=
"Select u from Calendar u where u.id = ?1"
)
...
...
src/main/java/com/bytesw/bytebot/model/CalendarException.java
View file @
60f4a48c
...
...
@@ -13,7 +13,7 @@ import javax.persistence.*;
import
java.io.Serializable
;
import
java.math.BigInteger
;
//
@Audited
@Audited
@Entity
@Inheritance
(
strategy
=
InheritanceType
.
SINGLE_TABLE
...
...
src/main/java/com/bytesw/bytebot/model/CalendarExceptionFull.java
View file @
60f4a48c
...
...
@@ -13,7 +13,6 @@ import java.math.BigInteger;
import
java.time.LocalDate
;
import
java.time.OffsetDateTime
;
//@Audited
@Entity
@Inheritance
(
strategy
=
InheritanceType
.
SINGLE_TABLE
...
...
@@ -50,10 +49,6 @@ public class CalendarExceptionFull implements Serializable {
@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
;
...
...
src/main/java/com/bytesw/bytebot/model/Channel.java
View file @
60f4a48c
...
...
@@ -4,6 +4,7 @@ import lombok.EqualsAndHashCode;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
import
java.util.List
;
...
...
@@ -19,6 +20,7 @@ import java.util.List;
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Audited
@Entity
@Table
(
name
=
"AVB_CHANNEL"
)
@Getter
@Setter
@ToString
...
...
src/main/java/com/bytesw/bytebot/model/ChannelParam.java
View file @
60f4a48c
...
...
@@ -5,6 +5,7 @@ import lombok.EqualsAndHashCode;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
...
...
@@ -19,6 +20,7 @@ import javax.persistence.*;
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Audited
@Entity
@Table
(
name
=
"AVB_CHANNEL_PARAM"
)
@Getter
...
...
src/main/java/com/bytesw/bytebot/model/Country.java
View file @
60f4a48c
package
com
.
bytesw
.
bytebot
.
model
;
import
lombok.*
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
import
java.util.List
;
@Audited
@Entity
@Getter
@Setter
...
...
src/main/java/com/bytesw/bytebot/model/DeploymentChannel.java
View file @
60f4a48c
...
...
@@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
import
java.util.List
;
...
...
@@ -21,6 +22,7 @@ import java.util.List;
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Audited
@Entity
@Table
(
name
=
"AVB_DEPLOYMENT_CHANNEL"
)
@Getter
...
...
src/main/java/com/bytesw/bytebot/model/DeploymentChannelParamValue.java
View file @
60f4a48c
...
...
@@ -4,6 +4,7 @@ import lombok.EqualsAndHashCode;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
...
...
@@ -18,6 +19,7 @@ import javax.persistence.*;
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Audited
@Entity
@Table
(
name
=
"AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE"
)
@Getter
...
...
src/main/java/com/bytesw/bytebot/model/FrequentQuestion.java
View file @
60f4a48c
package
com
.
bytesw
.
bytebot
.
model
;
import
com.bytesw.bytebot.model.converters.FrequentQuestionStatusConverter
;
import
com.bytesw.bytebot.model.converters.StatusConverter
;
import
com.bytesw.bytebot.model.enums.FrequentQuestionStatusEnum
;
import
com.bytesw.bytebot.model.enums.StatusEnum
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
import
java.time.LocalDateTime
;
import
java.time.OffsetDateTime
;
/**
* @author Sebastian Chicoma Sandmann
...
...
@@ -24,12 +22,14 @@ import java.time.OffsetDateTime;
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Audited
@Entity
@Table
(
name
=
"AVB_FREQUENT_QUESTION"
)
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
{
"id"
},
callSuper
=
false
)
@EqualsAndHashCode
(
of
=
"id"
)
@NamedQuery
(
name
=
"FrequentQuestion.findByPK"
,
query
=
"Select u from FrequentQuestion u where u.id = ?1"
)
public
class
FrequentQuestion
{
@Id
@Column
(
name
=
"FQUE_ID"
)
...
...
src/main/java/com/bytesw/bytebot/model/ProcessETL.java
View file @
60f4a48c
...
...
@@ -9,7 +9,7 @@ import org.hibernate.envers.Audited;
import
javax.persistence.*
;
import
java.io.Serializable
;
//
@Audited
@Audited
@Entity
@Table
(
name
=
"avb_process_etl"
)
@NamedQuery
(
name
=
"ProcessETL.findByPK"
,
query
=
"Select u from ProcessETL u where u.id = ?1"
)
...
...
src/main/java/com/bytesw/bytebot/model/QuestionFile.java
View file @
60f4a48c
...
...
@@ -14,7 +14,9 @@ import lombok.NoArgsConstructor;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.hibernate.annotations.Type
;
import
org.hibernate.envers.Audited
;
@Audited
@Entity
@Getter
@Setter
...
...
src/main/java/com/bytesw/bytebot/model/RangeCalendarException.java
View file @
60f4a48c
...
...
@@ -12,7 +12,7 @@ import javax.persistence.Entity;
import
javax.persistence.NamedQuery
;
import
java.time.OffsetDateTime
;
//
@Audited
@Audited
@Entity
@DiscriminatorValue
(
value
=
RangeCalendarException
.
DISCRIMINATOR_VALUE
)
@NamedQuery
(
name
=
"RangeCalendarException.findByPK"
,
query
=
"Select u from RangeCalendarException u where u.id = ?1"
)
...
...
src/main/java/com/bytesw/bytebot/model/SchedulerTask.java
View file @
60f4a48c
...
...
@@ -13,7 +13,7 @@ import javax.persistence.*;
import
java.io.Serializable
;
import
java.math.BigInteger
;
//
@Audited
@Audited
@Entity
@Table
(
name
=
"AVB_SCHEDULER_TASK"
)
@NamedQuery
(
name
=
"SchedulerTask.findByPK"
,
query
=
"Select u from SchedulerTask u where u.id = ?1"
)
...
...
src/main/java/com/bytesw/bytebot/model/Timezone.java
View file @
60f4a48c
package
com
.
bytesw
.
bytebot
.
model
;
import
lombok.*
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
...
...
@@ -15,7 +16,7 @@ import javax.persistence.*;
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Audited
@Entity
@Getter
@Setter
@NoArgsConstructor
...
...
src/main/java/com/bytesw/bytebot/model/UniqueCalendarException.java
View file @
60f4a48c
...
...
@@ -12,7 +12,7 @@ import javax.persistence.Entity;
import
javax.persistence.NamedQuery
;
import
java.time.LocalDate
;
//
@Audited
@Audited
@Entity
@DiscriminatorValue
(
value
=
UniqueCalendarException
.
DISCRIMINATOR_VALUE
)
@NamedQuery
(
name
=
"UniqueCalendarException.findByPK"
,
query
=
"Select u from UniqueCalendarException u where u.id = ?1"
)
...
...
src/main/java/com/bytesw/bytebot/model/UniqueWeeklyCalendarException.java
View file @
60f4a48c
...
...
@@ -11,7 +11,7 @@ import javax.persistence.DiscriminatorValue;
import
javax.persistence.Entity
;
import
javax.persistence.NamedQuery
;
//
@Audited
@Audited
@Entity
@DiscriminatorValue
(
value
=
UniqueWeeklyCalendarException
.
DISCRIMINATOR_VALUE
)
@NamedQuery
(
name
=
"UniqueWeeklyCalendarException.findByPK"
,
query
=
"Select u from UniqueWeeklyCalendarException u where u.id = ?1"
)
...
...
src/main/java/com/bytesw/bytebot/model/WeekScheduler.java
View file @
60f4a48c
...
...
@@ -14,7 +14,7 @@ import java.math.BigInteger;
import
java.time.OffsetDateTime
;
import
java.time.OffsetTime
;
//
@Audited
@Audited
@Entity
@Table
(
name
=
"AVB_WEEK_SCHEDULER"
)
@NamedQuery
(
name
=
"WeekScheduler.findByPK"
,
query
=
"Select u from WeekScheduler u where u.id = ?1"
)
...
...
src/main/java/com/bytesw/bytebot/model/converters/FrequentQuestionStatusConverter.java
View file @
60f4a48c
package
com
.
bytesw
.
bytebot
.
model
.
converters
;
import
com.bytesw.bytebot.model.enums.AgentStatusEnum
;
import
com.bytesw.bytebot.model.enums.FrequentQuestionStatusEnum
;
import
org.apache.camel.Converter
;
...
...
@@ -22,6 +21,9 @@ public class FrequentQuestionStatusConverter implements AttributeConverter<Frequ
@Override
public
String
convertToDatabaseColumn
(
FrequentQuestionStatusEnum
value
)
{
if
(
value
==
null
)
{
return
null
;
}
return
value
.
getName
();
}
...
...
src/main/java/com/bytesw/bytebot/model/converters/StatusConverter.java
View file @
60f4a48c
...
...
@@ -21,6 +21,9 @@ public class StatusConverter implements AttributeConverter<StatusEnum, String> {
@Override
public
String
convertToDatabaseColumn
(
StatusEnum
value
)
{
if
(
value
==
null
)
{
return
null
;
}
return
value
.
getName
();
}
...
...
src/main/java/com/bytesw/bytebot/routes/SFTPRoute.java
View file @
60f4a48c
...
...
@@ -8,19 +8,19 @@ import org.springframework.stereotype.Component;
@Component
public
class
SFTPRoute
extends
RouteBuilder
{
@Value
(
"${application.
bytebot
-integration.ftp.username}"
)
@Value
(
"${application.
AVB
-integration.ftp.username}"
)
private
String
username
;
@Value
(
"${application.
bytebot
-integration.ftp.password}"
)
@Value
(
"${application.
AVB
-integration.ftp.password}"
)
private
String
password
;
@Value
(
"${application.
bytebot
-integration.ftp.directory:}"
)
@Value
(
"${application.
AVB
-integration.ftp.directory:}"
)
private
String
directory
;
@Value
(
"${application.
bytebot
-integration.ftp.host}"
)
@Value
(
"${application.
AVB
-integration.ftp.host}"
)
private
String
host
;
@Value
(
"${application.
bytebot
-integration.ftp.passiveMode:true}"
)
@Value
(
"${application.
AVB
-integration.ftp.passiveMode:true}"
)
private
boolean
passiveMode
;
@Value
(
"${application.services.multi-tenant:false}"
)
...
...
src/main/java/com/bytesw/bytebot/service/AgentService.java
View file @
60f4a48c
package
com
.
bytesw
.
bytebot
.
service
;
import
com.bytesw.bytebot.bean.*
;
import
com.bytesw.bytebot.etl.batch.service.ScheduleService
;
import
com.bytesw.bytebot.model.*
;
import
com.bytesw.bytebot.jdbc.AgentJDBCRepository
;
import
com.bytesw.bytebot.model.enums.*
;
...
...
@@ -60,6 +61,9 @@ public class AgentService extends CustomPaginationService<Agent> {
@Autowired
private
ProducerTemplate
producerTemplate
;
@Autowired
private
ScheduleService
scheduleService
;
public
List
<
DeploymentChannelParamValueBean
>
GetKeysFromAgents
(
AgentStatusEnum
status
){
List
<
DeploymentChannelParamValueBean
>
values
=
agentJDBCRepository
.
getCredentialsFromAgentStatus
(
status
.
getName
());
...
...
@@ -147,7 +151,6 @@ public class AgentService extends CustomPaginationService<Agent> {
if
(
agent
.
getCountryId
()
!=
null
)
{
Optional
<
Country
>
countryFound
=
countryRepository
.
findById
(
agent
.
getCountryId
());
if
(
countryFound
.
isPresent
())
{
agentBD
.
setCountry
(
countryFound
.
get
());
}
...
...
@@ -435,7 +438,7 @@ public class AgentService extends CustomPaginationService<Agent> {
if
(
agentFound
.
isPresent
())
{
Agent
agent
=
agentFound
.
get
();
agent
.
setStatus
(
AgentStatusEnum
.
DELETED
);
scheduleService
.
cancelTaskDelete
(
id
);
agentRepository
.
save
(
agent
);
}
}
...
...
src/main/java/com/bytesw/bytebot/service/BucketService.java
View file @
60f4a48c
...
...
@@ -7,7 +7,9 @@ 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.BusinessParameterConfiguration
;
import
com.bytesw.bytebot.model.QuestionFile
;
import
com.bytesw.bytebot.repository.BusinessParameterConfigurationRepository
;
import
com.bytesw.bytebot.repository.BusinessParameterRepository
;
import
com.bytesw.bytebot.repository.QuestionFileRepository
;
import
com.bytesw.xdf.exception.NotFoundException
;
...
...
@@ -23,6 +25,7 @@ import java.io.ByteArrayInputStream;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.time.OffsetDateTime
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -41,9 +44,19 @@ public class BucketService {
@Value
(
"${application.bucket.modelBucket}"
)
private
String
modelDir
;
@Value
(
"${application.bucket.version}"
)
private
String
version
;
@Value
(
"${application.bucket.parameter}"
)
private
String
parameter
;
@Autowired
private
QuestionFileRepository
questionFileRepository
;
@Autowired
private
BusinessParameterConfigurationRepository
businessParameterConfigurationRepository
;
@Autowired
private
BusinessParameterRepository
businessParameterRepository
;
...
...
@@ -54,21 +67,34 @@ public class BucketService {
}
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."
);
Optional
<
BusinessParameter
>
deployment
=
businessParameterRepository
.
findByKey
(
parameter
);
String
bucketName
=
new
String
();
if
(!
deployment
.
isPresent
())
{
response
.
setMessage
(
"NOT.FOUND.BUSINESS.PARAMETER"
);
throw
new
NotFoundException
();
}
String
bucketName
=
businessParameter
.
get
().
getDefaultValue
();
List
<
BusinessParameterConfiguration
>
deploy
=
businessParameterConfigurationRepository
.
findBusinessParameterConfigurationListByBusinessParameter
(
deployment
.
get
().
getId
());
if
(
deploy
.
isEmpty
())
{
response
.
setMessage
(
"NOT.FOUND.BUSINESS.PARAMETER"
);
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
;
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
());
String
newFile
=
String
.
format
(
"%s/%s/
%s/%s/%s"
,
tenant
,
response
.
getUuid
(),
version
,
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
);
String
modelFile
=
String
.
format
(
"%s/%s/
%s/%s"
,
tenant
,
response
.
getUuid
(),
version
,
modelDir
);
createFolder
(
bucketName
,
modelFile
,
amazonS3
);
mainFile
.
delete
();
result
=
true
;
...
...
@@ -88,20 +114,20 @@ public class BucketService {
}
public
void
delete
(
String
uuid
)
{
Optional
<
BusinessParameter
>
businessParameter
=
businessParameterRepository
.
findByKey
(
"Bucket"
);
Optional
<
BusinessParameter
>
businessParameter
=
businessParameterRepository
.
findByKey
(
parameter
);
if
(!
businessParameter
.
isPresent
())
{
throw
new
NotFoundException
(
"No existe el parametro de negocio del bucket."
);
throw
new
NotFoundException
();
}
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"
);
throw
new
NotFoundException
();
}
String
keyName
=
String
.
format
(
"%s/%s/
1.0/%s/%s"
,
tenant
,
uuid
,
fileDir
,
questionFile
.
get
().
getName
());
String
keyName
=
String
.
format
(
"%s/%s/
%s/%s/%s"
,
tenant
,
uuid
,
version
,
fileDir
,
questionFile
.
get
().
getName
());
s3Client
.
deleteObject
(
new
DeleteObjectRequest
(
bucketName
,
keyName
));
keyName
=
String
.
format
(
"%s/%s/
1.0/%s/"
,
tenant
,
uuid
,
modelDir
);
keyName
=
String
.
format
(
"%s/%s/
%s/%s/"
,
tenant
,
uuid
,
version
,
modelDir
);
s3Client
.
deleteObject
(
new
DeleteObjectRequest
(
bucketName
,
keyName
));
}
catch
(
AmazonServiceException
e
)
{
e
.
printStackTrace
();
...
...
src/main/java/com/bytesw/bytebot/service/FileManagementService.java
View file @
60f4a48c
...
...
@@ -5,7 +5,7 @@
*/
package
com
.
bytesw
.
bytebot
.
service
;
import
com.
bytesw.bytebot.etl.model.GoalForActions
;
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
;
...
...
@@ -13,8 +13,8 @@ import com.bytesw.bytebot.model.QuestionFile;
import
com.bytesw.bytebot.model.enums.FrequentQuestionStatusEnum
;
import
com.bytesw.bytebot.repository.QuestionFileRepository
;
import
com.bytesw.bytebot.utils.Utilities
;
import
java.io.ByteArrayInputStream
;
import
java.io.
IOException
;
import
java.io.
*
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
...
...
@@ -46,20 +46,17 @@ public class FileManagementService {
@Autowired
private
QuestionFileRepository
questionFileRepository
;
@Transactional
(
propagation
=
Propagation
.
REQUIRED
)
public
FileValidationResponse
validateAndSaveFile
(
String
uuid
,
MultipartFile
file
)
throws
IOException
{
public
FileValidationResponse
saveFile
(
String
uuid
,
MultipartFile
file
)
throws
IOException
{
FileValidationResponse
response
=
new
FileValidationResponse
();
FileValidationResult
result
=
new
FileValidationResult
();
//@Validaciones: Tipo de Extension
boolean
acceptedExtension
=
false
;
String
fileExtension
=
FilenameUtils
.
getExtension
(
file
.
getOriginalFilename
());
for
(
String
validExension
:
validExtensions
)
{
if
(
validExension
.
equalsIgnoreCase
(
fileExtension
.
trim
()))
{
acceptedExtension
=
true
;
continue
;
//Break?
break
;
}
}
...
...
@@ -69,6 +66,24 @@ public class FileManagementService {
response
.
setFileValidationResult
(
result
);
return
response
;
}
switch
(
fileExtension
)
{
case
"csv"
:
response
=
validateCsv
(
uuid
,
file
);
break
;
case
"xls"
:
case
"xlsx"
:
response
=
validateAndSaveFile
(
uuid
,
file
);
break
;
}
return
response
;
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
)
public
FileValidationResponse
validateAndSaveFile
(
String
uuid
,
MultipartFile
file
)
throws
IOException
{
FileValidationResponse
response
=
new
FileValidationResponse
();
FileValidationResult
result
=
new
FileValidationResult
();
//@Validaciones: De Estructura del Excel (Cabeceras)
byte
[]
fileData
=
file
.
getBytes
();
...
...
@@ -81,7 +96,19 @@ public class FileManagementService {
//@HU: Llenando los headers encontrados
Map
<
String
,
Integer
>
headersXPosition
=
new
HashMap
<>();
List
<
String
>
headersList
=
new
ArrayList
<>();
//Cabeceras vacias
if
(
headerRow
==
null
)
{
Map
<
String
,
String
>
headerErrorMap
=
new
HashMap
<>();
for
(
String
key
:
fileHeaders
)
{
headerErrorMap
.
put
(
key
,
"HEADER.NOT.FOUND.FIRST.ROW"
);
}
result
.
setHeadersErrorMap
(
headerErrorMap
);
result
.
setStatus
(
ValidationStatusEnum
.
HEADER_ERROR
);
response
.
setFileValidationResult
(
result
);
return
response
;
}
Iterator
<
Cell
>
cells
=
headerRow
.
cellIterator
();
int
position
=
0
;
while
(
cells
.
hasNext
())
{
...
...
@@ -103,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
();
...
...
@@ -165,7 +193,13 @@ public class FileManagementService {
Map
<
String
,
String
>
recordsErrorMap
=
validateRecordsXRow
(
recordsXRow
);
if
(!
recordsErrorMap
.
isEmpty
())
{
recordsRowErrorMap
.
put
(
rowNumber
+
1
,
recordsErrorMap
);
if
(
recordsErrorMap
.
size
()
!=
fileHeaders
.
length
){
recordsRowErrorMap
.
put
(
rowNumber
+
1
,
recordsErrorMap
);
}
else
{
Map
<
String
,
String
>
rowErrorResult
=
new
HashMap
<>();
rowErrorResult
.
put
(
"ROW.NULL"
,
"ROW.DATA.NULL"
);
recordsRowErrorMap
.
put
(
rowNumber
,
rowErrorResult
);
}
}
rowNumber
++;
...
...
@@ -210,10 +244,130 @@ public class FileManagementService {
return
null
;
}
public
FileValidationResponse
validateCsv
(
String
uuid
,
MultipartFile
file
)
throws
IOException
{
FileValidationResponse
response
=
new
FileValidationResponse
();
FileValidationResult
result
=
new
FileValidationResult
();
List
<
List
<
String
>>
rows
=
new
ArrayList
<>();
try
{
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
<=
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
))
{
headerErrorMap
.
put
(
"FORMAT.DATA"
,
"WRONG.DATA.INCORRECT"
);
}
row
.
add
(
dato
);
}
rowData
++;
rows
.
add
(
row
);
}
if
(!
headerErrorMap
.
isEmpty
())
{
result
.
setHeadersErrorMap
(
headerErrorMap
);
result
.
setStatus
(
ValidationStatusEnum
.
FORMAT_INCORRECT
);
response
.
setFileValidationResult
(
result
);
return
response
;
}
if
(!
recordsRowErrorMap
.
isEmpty
())
{
log
.
info
(
"Hay errores en el contenido del archivo: "
+
recordsRowErrorMap
);
result
.
setStatus
(
ValidationStatusEnum
.
DATA_INCOMPLETE
);
result
.
setRecordsErrorMap
(
recordsRowErrorMap
);
response
.
setFileValidationResult
(
result
);
return
response
;
}
List
<
String
>
headersList
=
new
ArrayList
<>();
for
(
String
header:
rows
.
get
(
0
))
{
headersList
.
add
(
header
.
replace
(
'"'
,
' '
));
}
headerErrorMap
=
validateHeaders
(
headersList
);
if
(!
headerErrorMap
.
isEmpty
())
{
result
.
setHeadersErrorMap
(
headerErrorMap
);
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
();
questionFileBD
.
setUuid
(
uuid
);
questionFileBD
.
setName
(
file
.
getOriginalFilename
());
questionFileBD
.
setSize
(
file
.
getSize
());
questionFileBD
.
setUploadDate
(
LocalDateTime
.
now
());
questionFileBD
.
setData
(
file
.
getBytes
());
questionFileBD
=
questionFileRepository
.
save
(
questionFileBD
);
response
.
setId
(
questionFileBD
.
getId
());
response
.
setUuid
(
questionFileBD
.
getUuid
());
response
.
setFileName
(
questionFileBD
.
getName
());
response
.
setStatus
(
FrequentQuestionStatusEnum
.
PENDING_SYNCHRONIZED
.
getName
());
response
.
setUploadDate
(
getUploadDate
(
questionFileBD
.
getUploadDate
()));
response
.
setFileValidationResult
(
result
);
return
response
;
}
private
boolean
validateData
(
String
data
)
{
if
(
data
.
charAt
(
0
)
==
'"'
&&
data
.
charAt
(
data
.
length
()-
1
)
==
'"'
)
{
return
false
;
}
return
true
;
}
private
Map
<
String
,
String
>
validateHeaders
(
List
<
String
>
headersList
)
{
Map
<
String
,
Integer
>
headerOcurrencesMap
=
new
HashMap
<>();
Map
<
String
,
String
>
headerErrorMap
=
new
HashMap
<>();
Map
<
String
,
Integer
>
headerOrganized
=
new
HashMap
<>();
int
index
=
0
;
for
(
String
fileHeader
:
fileHeaders
)
{
String
keyHeader
=
fileHeader
.
toUpperCase
().
trim
();
...
...
@@ -225,18 +379,29 @@ public class FileManagementService {
if
(
header
.
toUpperCase
().
trim
().
equals
(
keyHeader
))
{
int
ocurrences
=
headerOcurrencesMap
.
get
(
keyHeader
);
headerOcurrencesMap
.
put
(
keyHeader
,
ocurrences
+
1
);
headerOrganized
.
put
(
keyHeader
,
index
);
}
index
++;
}
index
=
0
;
}
for
(
String
keyHeader
:
headerOcurrencesMap
.
keySet
())
{
int
ocurrences
=
headerOcurrencesMap
.
get
(
keyHeader
);
if
(
ocurrences
==
0
)
{
headerErrorMap
.
put
(
keyHeader
,
"HEADER.NOT.FOUND"
);
}
else
if
(
ocurrences
>
1
)
{
headerErrorMap
.
put
(
keyHeader
,
"HEADER.REPETEAD"
);
}
else
if
(
ocurrences
>=
1
)
{
if
(
ocurrences
>
1
){
headerErrorMap
.
put
(
keyHeader
,
"HEADER.REPETEAD"
);
}
else
if
(!
keyHeader
.
equalsIgnoreCase
(
fileHeaders
[
headerOrganized
.
get
(
keyHeader
)]))
{
headerErrorMap
.
put
(
keyHeader
,
"HEADER.NOT.ORGANIZED"
);
}
}
index
++;
}
return
headerErrorMap
;
}
...
...
src/main/java/com/bytesw/bytebot/service/KnowledgeService.java
View file @
60f4a48c
...
...
@@ -2,12 +2,10 @@ 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
;
...
...
@@ -18,8 +16,6 @@ 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
...
...
@@ -31,10 +27,13 @@ public class KnowledgeService {
@Value
(
"${application.knowledge.url}"
)
private
String
url
;
@Value
(
"${application.bucket.version}"
)
private
String
version
;
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
));
HttpPost
httppost
=
new
HttpPost
(
String
.
format
(
"%s/clients/%s/versions/
%s"
,
url
,
tenant
,
version
));
String
json
=
String
.
format
(
"{\"filename_csv\": \"%s\", \"index_name\": \"%s\"}"
,
response
.
getFileName
(),
response
.
getUuid
());
StringEntity
entity
=
new
StringEntity
(
json
);
try
{
...
...
@@ -52,10 +51,11 @@ 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
;
}
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
return
result
;
...
...
@@ -64,8 +64,7 @@ public class KnowledgeService {
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
());
HttpDelete
httpDelete
=
new
HttpDelete
(
String
.
format
(
"%s/clients/%s/indexes/%s/versions/%s"
,
url
,
tenant
,
uuid
,
version
));
ResponseHandler
<
String
>
responseHandler
=
response
->
{
int
status
=
response
.
getStatusLine
().
getStatusCode
();
if
(
status
>=
200
&&
status
<
300
)
{
...
...
src/main/java/com/bytesw/bytebot/service/OrquestadorService.java
View file @
60f4a48c
...
...
@@ -4,19 +4,25 @@ 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.BusinessParameter
;
import
com.bytesw.bytebot.model.BusinessParameterConfiguration
;
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.BusinessParameterConfigurationRepository
;
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
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.time.OffsetDateTime
;
import
java.util.List
;
import
java.util.Optional
;
@Service
...
...
@@ -39,18 +45,46 @@ public class OrquestadorService {
@Autowired
private
KnowledgeService
knowledgeService
;
@Autowired
private
BusinessParameterRepository
businessParameterRepository
;
@Autowired
private
BusinessParameterConfigurationRepository
businessParameterConfigurationRepository
;
@Value
(
"${application.bucket.deployment}"
)
private
String
parameter
;
public
FileValidationResponse
executeGenerateBCD
(
String
uuid
,
MultipartFile
file
)
{
BdcControl
model
=
new
BdcControl
();
FileValidationResponse
response
=
new
FileValidationResponse
();
boolean
step
=
false
;
try
{
//Modo de despliegue
Optional
<
BusinessParameter
>
deployment
=
businessParameterRepository
.
findByKey
(
parameter
);
String
modeDeployment
=
new
String
();
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"
);
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
response
=
fileManagementService
.
validateAndSaveFile
(
uuid
,
file
);
response
=
fileManagementService
.
saveFile
(
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
());
...
...
@@ -58,46 +92,77 @@ public class OrquestadorService {
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."
);
if
(
modeDeployment
.
equalsIgnoreCase
(
"onCloud"
))
{
//Carga archivo a bucket
step
=
bucketService
.
generate
(
file
.
getBytes
(),
response
);
if
(!
step
)
{
response
.
setMessage
(
"NOT.FOUND.BUCKET"
);
throw
new
NotFoundException
();
}
step
=
false
;
model
.
setStatus
(
StatusBcdEnum
.
INDEXANDO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
}
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
.
setMessage
(
"NOT.FOUND.KNOWLEDGE"
);
throw
new
NotFoundException
();
}
response
.
setStatus
(
FrequentQuestionStatusEnum
.
CORRECTO
.
getName
());
model
.
setStatus
(
StatusBcdEnum
.
INDEXADO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
}
catch
(
Exception
e
)
{
if
(
response
.
getMessage
()
==
null
)
{
response
.
setMessage
(
"ERROR.UPLOAD"
);
}
response
.
setStatus
(
FrequentQuestionStatusEnum
.
ERROR
.
getName
());
}
return
response
;
}
public
FileValidationResponse
retry
(
String
uuid
)
{
Optional
<
BdcControl
>
modelBdc
=
bdcControlRepository
.
findByUuid
(
uuid
);
if
(!
modelBdc
.
isPresent
())
{
throw
new
NotFoundException
(
"N
o se subio archivo a la BD
"
);
throw
new
NotFoundException
(
"N
OT.FOUND.DATA.CONTROL
"
);
}
boolean
step
=
false
;
BdcControl
model
=
modelBdc
.
get
();
FileValidationResponse
response
=
modelToFileValidation
(
model
);
try
{
Optional
<
BusinessParameter
>
deployment
=
businessParameterRepository
.
findByKey
(
parameter
);
String
modeDeployment
=
new
String
();
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"
);
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
()))
{
Optional
<
QuestionFile
>
questionFile
=
questionFileRepository
.
findByUuid
(
uuid
);
if
(!
questionFile
.
isPresent
())
{
throw
new
NotFoundException
(
"No se encontro archivo en la BD"
);
response
.
setMessage
(
"NOT.FOUND.DATA"
);
throw
new
NotFoundException
();
}
step
=
bucketService
.
generate
(
questionFile
.
get
().
getData
(),
response
);
if
(!
step
)
{
throw
new
NotFoundException
(
"Error a cargar archivo."
);
if
(
modeDeployment
.
equalsIgnoreCase
(
"onCloud"
))
{
step
=
bucketService
.
generate
(
questionFile
.
get
().
getData
(),
response
);
if
(!
step
)
{
response
.
setMessage
(
"NOT.FOUND.BUCKET"
);
throw
new
NotFoundException
();
}
}
model
.
setStatus
(
StatusBcdEnum
.
INDEXANDO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
...
...
@@ -106,13 +171,17 @@ public class OrquestadorService {
if
(
model
.
getStatus
().
equals
(
StatusBcdEnum
.
INDEXANDO
.
getName
()))
{
step
=
knowledgeService
.
generate
(
response
);
if
(!
step
)
{
throw
new
NotFoundException
(
"Error a cargar knowledge."
);
response
.
setMessage
(
"NOT.FOUND.KNOWLEDGE"
);
throw
new
NotFoundException
();
}
}
model
.
setStatus
(
StatusBcdEnum
.
INDEXADO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
response
.
setStatus
(
FrequentQuestionStatusEnum
.
CORRECTO
.
getName
());
}
catch
(
IOException
e
)
{
}
catch
(
Exception
e
)
{
if
(
response
.
getMessage
()
==
null
)
{
response
.
setMessage
(
"ERROR.UPLOAD"
);
}
response
.
setStatus
(
FrequentQuestionStatusEnum
.
ERROR
.
getName
());
}
return
response
;
...
...
@@ -121,13 +190,13 @@ public class OrquestadorService {
public
void
deleteBcd
(
String
uuid
)
{
Optional
<
BdcControl
>
bdcControl
=
bdcControlRepository
.
findByUuid
(
uuid
);
if
(!
bdcControl
.
isPresent
())
{
throw
new
NotFoundException
(
"Control no encontrado."
);
throw
new
NotFoundException
();
}
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"
);
throw
new
NotFoundException
();
}
model
.
setStatus
(
StatusBcdEnum
.
INDEXANDO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
...
...
src/main/java/com/bytesw/bytebot/service/SchedulerTaskService.java
View file @
60f4a48c
...
...
@@ -2,10 +2,12 @@ package com.bytesw.bytebot.service;
import
com.bytesw.bytebot.bean.CalendarBean
;
import
com.bytesw.bytebot.bean.SchedulerTaskBean
;
import
com.bytesw.bytebot.etl.batch.service.ScheduleService
;
import
com.bytesw.bytebot.model.Calendar
;
import
com.bytesw.bytebot.model.SchedulerTask
;
import
com.bytesw.bytebot.repository.CalendarRepository
;
import
com.bytesw.bytebot.repository.SchedulerTaskRepository
;
import
com.bytesw.xdf.exception.AlreadyExistsException
;
import
com.bytesw.xdf.exception.NotFoundException
;
import
com.bytesw.xdf.service.XDFService
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -26,6 +28,12 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
@Autowired
private
CalendarRepository
calendarRepository
;
@Autowired
private
SchedulerTaskRepository
schedulerTaskRepository
;
@Autowired
private
ScheduleService
scheduleService
;
protected
SchedulerTaskService
(
SchedulerTaskRepository
repository
)
{
super
(
repository
);
}
...
...
@@ -73,4 +81,38 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
initialData
.
put
(
"calendarList"
,
calendarBeanList
);
return
initialData
;
}
@Override
public
SchedulerTaskBean
create
(
SchedulerTaskBean
schedulerTaskBean
)
{
SchedulerTask
schedulerTask
=
new
SchedulerTask
();
schedulerTask
=
toModel
(
schedulerTask
,
schedulerTaskBean
);
schedulerTask
=
schedulerTaskRepository
.
save
(
schedulerTask
);
scheduleService
.
restartTask
(
schedulerTask
);
System
.
out
.
println
(
schedulerTask
);
return
toBean
(
schedulerTask
);
}
@Override
public
SchedulerTaskBean
update
(
SchedulerTaskBean
bean
,
BigInteger
id
)
{
Optional
<
SchedulerTask
>
model
=
schedulerTaskRepository
.
findById
(
id
);
if
(!
model
.
isPresent
())
{
throw
new
NotFoundException
();
}
SchedulerTask
schedulerTask
=
new
SchedulerTask
();
schedulerTask
=
toModel
(
schedulerTask
,
bean
);
schedulerTask
=
schedulerTaskRepository
.
save
(
schedulerTask
);
scheduleService
.
restartTask
(
schedulerTask
);
return
toBean
(
schedulerTask
);
}
@Override
public
void
delete
(
BigInteger
id
)
{
Optional
<
SchedulerTask
>
model
=
schedulerTaskRepository
.
findById
(
id
);
if
(!
model
.
isPresent
())
{
throw
new
NotFoundException
();
}
scheduleService
.
cancelTask
(
model
.
get
());
schedulerTaskRepository
.
deleteById
(
id
);
}
}
src/main/resources/application.yml
View file @
60f4a48c
spring.autoconfigure.exclude
:
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration, org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration
server
:
servlet.context-path
:
${APPLICATION_PATH:/
bytebot
}
servlet.context-path
:
${APPLICATION_PATH:/
AVB
}
port
:
${APPLICATION_PORT:9077}
web
:
#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 /
static-content-location
:
file:/home/mgutierrez/Descargas/dist/bytebot-html/
security
:
...
...
@@ -28,7 +27,7 @@ application:
byte-bot
:
batch
:
chunk
:
10
cron
:
0
/50 *
* * * *
cron
:
0
0/1
* * * *
show-side-bar
:
false
test
:
ENC(OEchnTXpIZnCVdPNthgCZBfQjMt1AUS1)
name
:
xdf-example
...
...
@@ -56,7 +55,7 @@ application:
multi-tenant-conf
:
exclude-service
:
/
authorization-service.url
:
http://localhost:17580
security
:
none
#oauth2sso #
none, basic, oauth2sso
security
:
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
:
...
...
@@ -72,7 +71,7 @@ application:
messaging
:
queue-test
:
action_queue.fifo
topic-test
:
topic-test
bytebot
-integration
:
AVB
-integration
:
ftp
:
host
:
localhost
username
:
ftp
...
...
@@ -94,11 +93,17 @@ application:
host
:
localhost
port
:
8161
queue-name
:
task_queue
timezone
:
zone
:
TimeZone
default
:
America/Mexico_City
bucket
:
deployment
:
DeployMode
parameter
:
KnowledgeBaseBucket
tenant
:
T186A1
region
:
us-east-1
fileBucket
:
KB_Files
modelBucket
:
KB_Model
version
:
"
1.0"
knowledge
:
url
:
"
http://127.0.0.1:3000/byteknowledgebaseApi"
...
...
@@ -112,7 +117,7 @@ spring:
datasource
:
database-type
:
postgres
schemaName
:
avb
url
:
jdbc:postgresql://192.168.0.11
5:5432/bytebot?useSSL=false¤tSchema=avb
url
:
jdbc:postgresql://192.168.0.11
9:5432/bytebot?useSSL=false¤tSchema=avb_hdi
driverClassName
:
'
org.postgresql.Driver'
username
:
postgres
password
:
postgres
...
...
@@ -123,16 +128,16 @@ spring:
hikari.registerMbeans
:
true
security
:
basepath
:
http://localhost:9077/
bytebot
basepath
:
http://localhost:9077/
AVB
provider
:
byte
# oracle, amazon
oauth2-client
:
clientId
:
xdf-client
clientSecret
:
xdf-secret
accessTokenUri
:
http://192.168.0.11
5
:18080/oauth/token
userAuthorizationUri
:
http://192.168.0.11
5
:18080/oauth/authorize
accessTokenUri
:
http://192.168.0.11
9
:18080/oauth/token
userAuthorizationUri
:
http://192.168.0.11
9
:18080/oauth/authorize
oauth2-resource
:
userInfoUri
:
http://192.168.0.11
5
:18080/oauth/userinfo
logoutUri
:
http://192.168.0.11
5
:18080/oauth/userlogout
userInfoUri
:
http://192.168.0.11
9
:18080/oauth/userinfo
logoutUri
:
http://192.168.0.11
9
:18080/oauth/userlogout
tenants
:
-
id
:
T186A1
...
...
@@ -140,7 +145,7 @@ spring:
datasource
:
database-type
:
postgres
schemaName
:
avb
url
:
jdbc:postgresql://192.168.0.11
5:5432/bytebot?useSSL=false¤tSchema=avb
url
:
jdbc:postgresql://192.168.0.11
9:5432/bytebot?useSSL=false¤tSchema=avb_hdi
driverClassName
:
'
org.postgresql.Driver'
username
:
postgres
password
:
postgres
...
...
@@ -150,16 +155,16 @@ spring:
testWhileIdle
:
true
hikari.registerMbeans
:
true
security
:
basepath
:
http://localhost:9077/
bytebot
basepath
:
http://localhost:9077/
AVB
provider
:
byte
# oracle, amazon
oauth2-client
:
clientId
:
xdf-client
clientSecret
:
xdf-secret
accessTokenUri
:
http://192.168.0.11
5
:18080/oauth/token
userAuthorizationUri
:
http://192.168.0.11
5
:18080/oauth/authorize
accessTokenUri
:
http://192.168.0.11
9
:18080/oauth/token
userAuthorizationUri
:
http://192.168.0.11
9
:18080/oauth/authorize
oauth2-resource
:
userInfoUri
:
http://192.168.0.11
5
:18080/oauth/userinfo
logoutUri
:
http://192.168.0.11
5
:18080/oauth/userlogout
userInfoUri
:
http://192.168.0.11
9
:18080/oauth/userinfo
logoutUri
:
http://192.168.0.11
9
:18080/oauth/userlogout
jpa
:
...
...
@@ -182,8 +187,8 @@ batch:
datasource
:
jdbc-driver
:
'
org.postgresql.Driver'
username
:
postgres
password
:
postgres
jdbc-url
:
jdbc:postgresql://
localhost:5432/bytebot
?useSSL=false¤tSchema=avb
password
:
jdbc-url
:
jdbc:postgresql://
192.168.21.74:5432/avb
?useSSL=false¤tSchema=avb
query
:
'
select
*
from
events
WHERE
id
>
%d
order
by
id
asc'
logging.level.root
:
INFO
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment