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
5b6d9a95
Commit
5b6d9a95
authored
Dec 23, 2021
by
Roberto Loayza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proceso de eliminación y generación BDC
parent
e74bdaf7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
19 deletions
+28
-19
BucketService.java
src/main/java/com/bytesw/bytebot/service/BucketService.java
+1
-1
KnowledgeService.java
...ain/java/com/bytesw/bytebot/service/KnowledgeService.java
+7
-6
OrquestadorService.java
...n/java/com/bytesw/bytebot/service/OrquestadorService.java
+20
-12
No files found.
src/main/java/com/bytesw/bytebot/service/BucketService.java
View file @
5b6d9a95
...
...
@@ -97,7 +97,7 @@ public class BucketService {
AmazonS3
s3Client
=
getS3Client
();
Optional
<
QuestionFile
>
questionFile
=
questionFileRepository
.
findByUuid
(
uuid
);
if
(!
questionFile
.
isPresent
())
{
log
.
error
(
"El uuid no se encuentra enlazado con un file"
);
throw
new
NotFoundException
(
"El uuid no se encuentra enlazado con un file"
);
}
String
keyName
=
String
.
format
(
"%s/%s/1.0/%s/%s"
,
tenant
,
uuid
,
fileDir
,
questionFile
.
get
().
getName
());
s3Client
.
deleteObject
(
new
DeleteObjectRequest
(
bucketName
,
keyName
));
...
...
src/main/java/com/bytesw/bytebot/service/KnowledgeService.java
View file @
5b6d9a95
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
;
...
...
@@ -50,8 +51,8 @@ public class KnowledgeService {
}
};
String
res
=
httpclient
.
execute
(
httppost
,
responseHandler
);
Map
<
String
,
Object
>
mapJsonResult
=
new
ObjectMapper
().
readValue
(
res
,
HashMap
.
class
);
if
(
mapJsonResult
.
get
(
"status"
)
.
equals
(
"success"
)){
String
status
=
(
String
)
JsonUtils
.
getFieldFromJson
(
res
,
"$.message.status"
);
if
(
status
.
equals
(
"success"
)){
result
=
true
;
}
}
catch
(
IOException
e
)
{
...
...
@@ -75,12 +76,12 @@ public class KnowledgeService {
}
};
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
String
responseBody
=
httpclient
.
execute
(
httpDelete
,
responseHandler
);
Map
<
String
,
Object
>
mapJsonResult
=
new
ObjectMapper
().
readValue
(
String
.
valueOf
(
responseBody
),
HashMap
.
class
);
if
(
mapJsonResult
.
get
(
"status"
).
equals
(
"success"
)){
String
res
=
httpclient
.
execute
(
httpDelete
,
responseHandler
);
httpclient
.
close
();
String
status
=
(
String
)
JsonUtils
.
getFieldFromJson
(
res
,
"$.message.status"
);
if
(
status
.
equals
(
"success"
)){
result
=
true
;
}
httpclient
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
src/main/java/com/bytesw/bytebot/service/OrquestadorService.java
View file @
5b6d9a95
...
...
@@ -63,12 +63,15 @@ public class OrquestadorService {
if
(!
step
)
{
throw
new
NotFoundException
(
"Error a cargar archivo."
);
}
step
=
false
;
model
.
setStatus
(
StatusBcdEnum
.
INDEXANDO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
//Generacion del modelo
//Actualizar
knowledgeService
.
generate
(
response
);
step
=
knowledgeService
.
generate
(
response
);
if
(!
step
)
{
throw
new
NotFoundException
(
"Error a cargar archivo."
);
}
response
.
setStatus
(
FrequentQuestionStatusEnum
.
CORRECTO
.
getName
());
model
.
setStatus
(
StatusBcdEnum
.
INDEXADO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
...
...
@@ -120,20 +123,25 @@ public class OrquestadorService {
if
(!
bdcControl
.
isPresent
())
{
throw
new
NotFoundException
(
"Control no encontrado."
);
}
Optional
<
QuestionFile
>
questionFile
=
questionFileRepository
.
findByUuid
(
uuid
);
if
(
questionFile
.
isPresent
())
{
questionFileRepository
.
deleteById
(
bdcControl
.
get
().
getId
());
bdcControl
.
get
().
setStatus
(
StatusBcdEnum
.
INDEXANDO
.
getName
());
BdcControl
model
=
bdcControl
.
get
();
if
(
model
.
getStatus
().
equals
(
StatusBcdEnum
.
INDEXADO
.
getName
()))
{
boolean
step
=
knowledgeService
.
delete
(
uuid
);
if
(!
step
)
{
throw
new
NotFoundException
(
"Error a eliminar modelo del bucket"
);
}
model
.
setStatus
(
StatusBcdEnum
.
INDEXANDO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
}
if
(
bdcControl
.
get
().
getStatus
().
equals
(
StatusBcdEnum
.
INDEXANDO
.
getName
()))
{
if
(
model
.
getStatus
().
equals
(
StatusBcdEnum
.
INDEXANDO
.
getName
()))
{
bucketService
.
delete
(
uuid
);
bdcControl
.
get
().
setStatus
(
StatusBcdEnum
.
INDEXADO
.
getName
());
model
.
setStatus
(
StatusBcdEnum
.
CARGADO
.
getName
());
model
=
bdcControlRepository
.
save
(
model
);
}
if
(
bdcControl
.
get
().
getStatus
().
equals
(
StatusBcdEnum
.
INDEXADO
.
getName
()))
{
knowledgeService
.
delete
(
uuid
);
Optional
<
QuestionFile
>
questionFile
=
questionFileRepository
.
findByUuid
(
uuid
);
if
(
questionFile
.
isPresent
())
{
questionFileRepository
.
deleteById
(
bdcControl
.
get
().
getFileId
());
}
bdcControlRepository
.
delete
ById
(
bdcControl
.
get
().
getId
()
);
bdcControlRepository
.
delete
(
model
);
}
private
FileValidationResponse
modelToFileValidation
(
BdcControl
model
){
...
...
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