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
589cb33c
Commit
589cb33c
authored
Jan 17, 2022
by
Roberto Loayza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update BusinessParameterService,ScheduleService, DataSensibleMapper
parent
45c1fa81
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
22 deletions
+46
-22
ScheduleService.java
...com/bytesw/bytebot/etl/batch/service/ScheduleService.java
+6
-11
DeleteDataSensJDBCRepository.java
...com/bytesw/bytebot/jdbc/DeleteDataSensJDBCRepository.java
+13
-0
BucketService.java
src/main/java/com/bytesw/bytebot/service/BucketService.java
+0
-9
BusinessParameterService.java
.../com/bytesw/bytebot/service/BusinessParameterService.java
+1
-2
DataSensibleMapper.xml
...resources/config/mappers/etl/mysql/DataSensibleMapper.xml
+13
-0
DataSensibleMapper.xml
...ources/config/mappers/etl/postgres/DataSensibleMapper.xml
+13
-0
No files found.
src/main/java/com/bytesw/bytebot/etl/batch/service/ScheduleService.java
View file @
589cb33c
...
...
@@ -292,7 +292,6 @@ public class ScheduleService implements SchedulingConfigurer {
.
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
.
getAgenId
());
if
(!
futureMap
.
containsKey
(
keyDataSens
))
{
...
...
@@ -354,8 +353,8 @@ public class ScheduleService implements SchedulingConfigurer {
@Scheduled
(
cron
=
"${application.byte-bot.batch.cron}"
)
@SchedulerLock
(
name
=
"Dashboard-ETL"
,
lockAtLeastFor
=
"PT40S"
,
lockAtMostFor
=
"PT50S"
)
protected
void
createJob
()
{
List
<
Agent
>
agentDeployed
=
agentRepository
.
findByStatus
(
AgentStatusEnum
.
DEPLOYED
);
log
.
info
(
"INICIADO"
);
if
(!
agentDeployed
.
isEmpty
())
{
ThreadLocalStorage
.
setTenantName
(
tenant
);
Job
job
=
jobBuilderFactory
.
get
(
"processJob"
)
...
...
@@ -397,6 +396,8 @@ public class ScheduleService implements SchedulingConfigurer {
/* Métodos ETL de data sensible */
private
Job
createJobDataSens
(
DeleteDataSensBean
data
)
{
log
.
info
(
"ETL de eliminacion"
);
data
=
deleteDataSensJDBCRepository
.
getAgentChannelByAgentID
(
AgentStatusEnum
.
DEPLOYED
.
getName
(),
AgentParameterEnum
.
ACCESS_TWILIO
.
getName
(),
data
.
getAgenId
());
ThreadLocalStorage
.
setTenantName
(
tenant
);
return
jobBuilderFactory
.
get
(
String
.
format
(
"processDataSensible-%d"
,
data
.
getAgenId
()))
.
incrementer
(
new
RunIdIncrementer
()).
listener
(
listener
)
...
...
@@ -430,24 +431,18 @@ 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
;
Long
differenceTime
=
0L
;
if
(
control
!=
null
)
{
OffsetDateTime
lastSessionDate
=
OffsetDateTime
.
ofInstant
(
control
.
getDateDelete
().
toInstant
(),
ZoneId
.
systemDefault
());
Duration
difference
=
Duration
.
between
(
lastSessionDate
,
endDate
);
differenceTime
=
(
int
)
(
difference
.
getSeconds
()
/
60
);
differenceTime
=
(
difference
.
getSeconds
()
/
60
);
if
(
differenceTime
<
=
periodAgent
)
{
if
(
differenceTime
<
data
.
getDeletePeriod
()
)
{
log
.
info
(
"Agente "
+
data
.
getValue
()
+
" aun no cumple con el periodo de espera."
);
id
=
null
;
}
else
{
...
...
src/main/java/com/bytesw/bytebot/jdbc/DeleteDataSensJDBCRepository.java
View file @
589cb33c
...
...
@@ -31,6 +31,19 @@ public class DeleteDataSensJDBCRepository {
}
}
public
DeleteDataSensBean
getAgentChannelByAgentID
(
String
status
,
String
channel
,
Long
id
){
SqlSession
session
=
sqlSessionFactory
.
openSession
();
try
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"status"
,
status
);
params
.
put
(
"channel"
,
channel
);
params
.
put
(
"agentId"
,
id
);
return
session
.
selectOne
(
"com.bytesw.bytebot.dao.jdbc.ETLDataSensibleMapper.getAgentChannelByAgentId"
,
params
);
}
finally
{
session
.
close
();
}
}
public
DeleteDataSensControlBean
getControl
(
Long
id
){
SqlSession
session
=
sqlSessionFactory
.
openSession
();
try
{
...
...
src/main/java/com/bytesw/bytebot/service/BucketService.java
View file @
589cb33c
...
...
@@ -120,13 +120,4 @@ public class BucketService {
}
}
public
void
list
()
{
AmazonS3
s3
=
getS3Client
();
List
<
Bucket
>
buckets
=
s3
.
listBuckets
();
System
.
out
.
println
(
"Your {S3} buckets are:"
);
for
(
Bucket
b
:
buckets
)
{
System
.
out
.
println
(
"* "
+
b
.
getName
());
}
}
}
src/main/java/com/bytesw/bytebot/service/BusinessParameterService.java
View file @
589cb33c
...
...
@@ -283,7 +283,6 @@ public class BusinessParameterService extends XDFService<BusinessParameter, Busi
public
boolean
validateKey
(
BusinessParameterBean
bean
)
{
Optional
<
BusinessParameter
>
businessParameterOptional
=
this
.
businessParameterRepository
.
findByKey
(
bean
.
getKey
());
System
.
out
.
println
(
businessParameterOptional
);
if
(
businessParameterOptional
.
isPresent
())
{
BusinessParameterBean
businessParameterBeanOptional
=
toBean
(
businessParameterOptional
.
get
());
if
(!
businessParameterBeanOptional
.
getId
().
equals
(
bean
.
getId
()))
{
...
...
@@ -337,7 +336,7 @@ public class BusinessParameterService extends XDFService<BusinessParameter, Busi
break
;
}
}
if
(
config
.
getFrom
().
isBefore
(
config
.
getTo
())
&&
nowTime
.
isAfter
(
config
.
getFrom
()))
{
if
(
config
.
getFrom
().
isBefore
(
config
.
getTo
())
&&
nowTime
.
isAfter
(
config
.
getFrom
())
&&
config
.
getTo
().
isAfter
(
nowTime
)
)
{
parameterResult
=
config
.
getValue
();
break
;
}
...
...
src/main/resources/config/mappers/etl/mysql/DataSensibleMapper.xml
View file @
589cb33c
...
...
@@ -17,6 +17,19 @@
WHERE agen_state=#{status} AND chpa_label=#{channel}
</select>
<select
id=
"getAgentChannelByAgentId"
resultType=
"ChannelByAgent"
flushCache=
"true"
>
SELECT chpv_id as id,
chpv_value as channelValue,
AG.agen_iden as value,
AG.agen_id as agenId,
AG.agen_delete_sensible_period as deletePeriod
FROM AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE ADCP
JOIN AVB_CHANNEL_PARAM ACP ON ACP.chpa_id=ADCP.chpa_id
JOIN avb_deployment_channel AD on AD.dcha_id=ADCP.dcha_id
JOIN avb_agent AG on AG.agen_id=AD.agen_id
WHERE agen_state=#{status} AND chpa_label=#{channel} and AG.agen_id = #{agentId}
</select>
<select
id=
"getControl"
resultType=
"DeleteControl"
flushCache=
"true"
>
SELECT dsmc_id as id,
agent_id as agentId,
...
...
src/main/resources/config/mappers/etl/postgres/DataSensibleMapper.xml
View file @
589cb33c
...
...
@@ -17,6 +17,19 @@
WHERE agen_state=#{status} AND chpa_label=#{channel}
</select>
<select
id=
"getAgentChannelByAgentId"
resultType=
"ChannelByAgent"
flushCache=
"true"
>
SELECT chpv_id as id,
chpv_value as channelValue,
AG.agen_iden as value,
AG.agen_id as agenId,
AG.agen_delete_sensible_period as deletePeriod
FROM AVB_DEPLOYMENT_CHANNEL_PARAM_VALUE ADCP
JOIN AVB_CHANNEL_PARAM ACP ON ACP.chpa_id=ADCP.chpa_id
JOIN avb_deployment_channel AD on AD.dcha_id=ADCP.dcha_id
JOIN avb_agent AG on AG.agen_id=AD.agen_id
WHERE agen_state=#{status} AND chpa_label=#{channel} and AG.agen_id = #{agentId}
</select>
<select
id=
"getControl"
resultType=
"DeleteControl"
flushCache=
"true"
>
SELECT dsmc_id as id,
agent_id as agentId,
...
...
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