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
45c1fa81
Commit
45c1fa81
authored
Jan 16, 2022
by
Roberto Loayza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update BusinessParameterService, ScheduleService, OrquestadorService
parent
6e1e5140
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
70 deletions
+76
-70
ScheduleService.java
...com/bytesw/bytebot/etl/batch/service/ScheduleService.java
+22
-9
DataSensibleJPAWriter.java
...ytesw/bytebot/etl/batch/writer/DataSensibleJPAWriter.java
+2
-0
BucketService.java
src/main/java/com/bytesw/bytebot/service/BucketService.java
+5
-21
BusinessParameterService.java
.../com/bytesw/bytebot/service/BusinessParameterService.java
+41
-0
OrquestadorService.java
...n/java/com/bytesw/bytebot/service/OrquestadorService.java
+6
-39
SchedulerTaskService.java
...java/com/bytesw/bytebot/service/SchedulerTaskService.java
+0
-1
No files found.
src/main/java/com/bytesw/bytebot/etl/batch/service/ScheduleService.java
View file @
45c1fa81
...
...
@@ -24,6 +24,7 @@ import com.bytesw.bytebot.model.enums.AgentStatusEnum;
import
com.bytesw.bytebot.model.enums.FrequencyType
;
import
com.bytesw.bytebot.model.enums.ProcessETLEnum
;
import
com.bytesw.bytebot.repository.*
;
import
com.bytesw.bytebot.service.BusinessParameterService
;
import
com.bytesw.xdf.multitenant.core.ThreadLocalStorage
;
import
com.google.gson.Gson
;
import
lombok.extern.log4j.Log4j2
;
...
...
@@ -147,7 +148,7 @@ public class ScheduleService implements SchedulingConfigurer {
private
CalendarExceptionFullRepository
calendarExceptionFullRepository
;
@Autowired
private
BusinessParameter
Repository
businessParameterRepository
;
private
BusinessParameter
Service
businessParameterService
;
private
boolean
schedulerFlag
=
false
;
...
...
@@ -196,9 +197,9 @@ public class ScheduleService implements SchedulingConfigurer {
private
void
configureTask
(
String
tenantIdentifier
,
String
identifier
,
ScheduledTaskRegistrar
taskRegistrar
)
{
tenant
=
tenantIdentifier
;
taskRegister
=
taskRegistrar
;
Optional
<
BusinessParameter
>
zone
=
businessParameterRepository
.
findBy
Key
(
parameter
);
if
(
zone
.
isPresent
()
)
{
timeZone
=
TimeZone
.
getTimeZone
(
zone
.
get
().
getDefaultValue
()
);
String
zone
=
businessParameterService
.
getBusinessParameterFor
Key
(
parameter
);
if
(
zone
!=
null
)
{
timeZone
=
TimeZone
.
getTimeZone
(
zone
);
}
else
{
timeZone
=
TimeZone
.
getTimeZone
(
zoneDefault
);
}
...
...
@@ -258,23 +259,29 @@ public class ScheduleService implements SchedulingConfigurer {
/*ETL eliminacion de data sensible*/
public
void
processDeleteData
(
String
tenantIdentifier
,
ScheduledTaskRegistrar
taskRegistrar
,
String
calendarId
)
{
Optional
<
BusinessParameter
>
zone
=
businessParameterRepository
.
findBy
Key
(
parameter
);
if
(
zone
.
isPresent
()
)
{
timeZone
=
TimeZone
.
getTimeZone
(
zone
.
get
().
getDefaultValue
()
);
String
zone
=
businessParameterService
.
getBusinessParameterFor
Key
(
parameter
);
if
(
zone
!=
null
)
{
timeZone
=
TimeZone
.
getTimeZone
(
zone
);
}
else
{
timeZone
=
TimeZone
.
getTimeZone
(
zoneDefault
);
}
Optional
<
List
<
WeekScheduler
>>
dates
=
weekSchedulerRepository
.
findByCalendarId
(
calendarId
);
OffsetTime
actual
=
OffsetTime
.
now
();
OffsetDateTime
now
=
OffsetDateTime
.
now
();
for
(
WeekScheduler
weekScheduler:
dates
.
get
())
{
int
day
=
now
.
getDayOfWeek
().
getValue
()
==
7
?
1
:
(
now
.
getDayOfWeek
().
getValue
()
+
1
);
if
(
day
!=
weekScheduler
.
getDayOfWeek
()){
schedulerFlag
=
false
;
continue
;
}
if
(
actual
.
isBefore
(
weekScheduler
.
getTo
())
&&
actual
.
isAfter
(
weekScheduler
.
getFrom
()))
{
Optional
<
List
<
CalendarExceptionFull
>>
calendarException
=
calendarExceptionFullRepository
.
findByCalendarId
(
calendarId
);
if
(
calendarException
.
isPresent
()){
schedulerFlag
=
validateException
(
calendarException
.
get
());
break
;
}
else
{
schedulerFlag
=
true
;
}
break
;
}
else
{
schedulerFlag
=
false
;
}
...
...
@@ -423,8 +430,14 @@ public class ScheduleService implements SchedulingConfigurer {
throw
new
RuntimeException
(
"Properties not found"
);
}
Optional
<
Agent
>
agent
=
agentRepository
.
findById
(
data
.
getAgenId
());
if
(!
agent
.
isPresent
())
{
throw
new
RuntimeException
(
"Agent not found"
);
}
DeleteDataSensControlBean
control
=
deleteDataSensJDBCRepository
.
getControl
(
data
.
getAgenId
());
OffsetDateTime
endDate
=
OffsetDateTime
.
now
();
int
periodAgent
=
agent
.
get
().
getPeriod
();
Long
id
=
0L
;
int
differenceTime
=
0
;
...
...
@@ -434,7 +447,7 @@ public class ScheduleService implements SchedulingConfigurer {
differenceTime
=
(
int
)
(
difference
.
getSeconds
()
/
60
);
if
(
differenceTime
<
data
.
getDeletePeriod
()
)
{
if
(
differenceTime
<
=
periodAgent
)
{
log
.
info
(
"Agente "
+
data
.
getValue
()
+
" aun no cumple con el periodo de espera."
);
id
=
null
;
}
else
{
...
...
src/main/java/com/bytesw/bytebot/etl/batch/writer/DataSensibleJPAWriter.java
View file @
45c1fa81
...
...
@@ -117,6 +117,8 @@ public class DataSensibleJPAWriter implements ItemWriter<DynaBean>, StepExecutio
}
}
}
}
else
{
update_control
=
true
;
}
DeleteDataSensibleControl
control
=
new
DeleteDataSensibleControl
();
Optional
<
DeleteDataSensibleControl
>
controlBd
=
deleteDataSensibleControlRepository
.
findEventIdByAgentId
(
agent
.
getAgenId
());
...
...
src/main/java/com/bytesw/bytebot/service/BucketService.java
View file @
45c1fa81
...
...
@@ -55,10 +55,7 @@ public class BucketService {
private
QuestionFileRepository
questionFileRepository
;
@Autowired
private
BusinessParameterConfigurationRepository
businessParameterConfigurationRepository
;
@Autowired
private
BusinessParameterRepository
businessParameterRepository
;
private
BusinessParameterService
businessParameterService
;
private
AmazonS3
getS3Client
()
{
return
AmazonS3ClientBuilder
.
standard
()
...
...
@@ -67,23 +64,11 @@ public class BucketService {
}
public
boolean
generate
(
byte
[]
file
,
FileValidationResponse
response
)
{
Optional
<
BusinessParameter
>
deployment
=
businessParameterRepository
.
findByKey
(
parameter
);
String
bucketName
=
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
())
{
String
bucketName
=
businessParameterService
.
getBusinessParameterForKey
(
parameter
);
if
(
bucketName
==
null
)
{
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
());
...
...
@@ -114,11 +99,10 @@ public class BucketService {
}
public
void
delete
(
String
uuid
)
{
Optional
<
BusinessParameter
>
businessParameter
=
businessParameterRepository
.
findBy
Key
(
parameter
);
if
(
!
businessParameter
.
isPresent
()
)
{
String
bucketName
=
businessParameterService
.
getBusinessParameterFor
Key
(
parameter
);
if
(
bucketName
==
null
)
{
throw
new
NotFoundException
();
}
String
bucketName
=
businessParameter
.
get
().
getDefaultValue
();
try
{
AmazonS3
s3Client
=
getS3Client
();
Optional
<
QuestionFile
>
questionFile
=
questionFileRepository
.
findByUuid
(
uuid
);
...
...
src/main/java/com/bytesw/bytebot/service/BusinessParameterService.java
View file @
45c1fa81
...
...
@@ -305,4 +305,45 @@ public class BusinessParameterService extends XDFService<BusinessParameter, Busi
}
return
beanList
;
}
public
String
getBusinessParameterForKey
(
String
parameter
)
{
Optional
<
BusinessParameter
>
businessParameter
=
businessParameterRepository
.
findByKey
(
parameter
);
if
(!
businessParameter
.
isPresent
())
{
return
null
;
}
String
parameterResult
=
null
;
if
(
businessParameter
.
get
().
getRequired
())
{
parameterResult
=
businessParameter
.
get
().
getDefaultValue
();
}
List
<
BusinessParameterConfiguration
>
parameterConfig
=
businessParameterConfigurationRepository
.
findBusinessParameterConfigurationListByBusinessParameter
(
businessParameter
.
get
().
getId
());
if
(
parameterConfig
.
isEmpty
())
{
return
parameterResult
;
}
OffsetDateTime
nowTime
=
OffsetDateTime
.
now
();
for
(
BusinessParameterConfiguration
config:
parameterConfig
)
{
if
(
config
.
getTo
()
==
null
)
{
if
(
nowTime
.
isAfter
(
config
.
getFrom
()))
{
parameterResult
=
config
.
getValue
();
break
;
}
}
else
{
if
(
config
.
getFrom
().
equals
(
config
.
getTo
()))
{
if
(
config
.
getFrom
().
isBefore
(
nowTime
))
{
parameterResult
=
config
.
getValue
();
break
;
}
}
if
(
config
.
getFrom
().
isBefore
(
config
.
getTo
())
&&
nowTime
.
isAfter
(
config
.
getFrom
()))
{
parameterResult
=
config
.
getValue
();
break
;
}
}
}
return
parameterResult
;
}
}
src/main/java/com/bytesw/bytebot/service/OrquestadorService.java
View file @
45c1fa81
...
...
@@ -4,14 +4,10 @@ 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
;
...
...
@@ -21,8 +17,6 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.time.OffsetDateTime
;
import
java.util.List
;
import
java.util.Optional
;
@Service
...
...
@@ -46,10 +40,7 @@ public class OrquestadorService {
private
KnowledgeService
knowledgeService
;
@Autowired
private
BusinessParameterRepository
businessParameterRepository
;
@Autowired
private
BusinessParameterConfigurationRepository
businessParameterConfigurationRepository
;
private
BusinessParameterService
businessParameterService
;
@Value
(
"${application.bucket.deployment}"
)
private
String
parameter
;
...
...
@@ -60,23 +51,12 @@ public class OrquestadorService {
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
())
{
String
modeDeployment
=
businessParameterService
.
getBusinessParameterForKey
(
parameter
);
if
(
modeDeployment
==
null
)
{
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
.
saveFile
(
uuid
,
file
);
if
(
response
.
getFileValidationResult
().
getStatus
().
getName
()
!=
ValidationStatusEnum
.
OK
.
getName
())
{
...
...
@@ -84,7 +64,6 @@ public class OrquestadorService {
return
response
;
}
model
.
setUuid
(
response
.
getUuid
());
model
.
setFileId
(
response
.
getId
());
model
.
setFileName
(
response
.
getFileName
());
...
...
@@ -133,23 +112,11 @@ public class OrquestadorService {
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
())
{
String
modeDeployment
=
businessParameterService
.
getBusinessParameterForKey
(
parameter
);
if
(
modeDeployment
==
null
)
{
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
);
...
...
src/main/java/com/bytesw/bytebot/service/SchedulerTaskService.java
View file @
45c1fa81
...
...
@@ -88,7 +88,6 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
schedulerTask
=
toModel
(
schedulerTask
,
schedulerTaskBean
);
schedulerTask
=
schedulerTaskRepository
.
save
(
schedulerTask
);
scheduleService
.
restartTask
(
schedulerTask
);
System
.
out
.
println
(
schedulerTask
);
return
toBean
(
schedulerTask
);
}
...
...
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