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
cf6d3f18
Commit
cf6d3f18
authored
Sep 11, 2020
by
Sebastian Chicoma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cambios y correcciones para lógica de negocio
parent
b5f98f8b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
27 deletions
+51
-27
AgentBean.java
src/main/java/com/bytesw/bytebot/bean/AgentBean.java
+1
-1
FrequentQuestion.java
src/main/java/com/bytesw/bytebot/model/FrequentQuestion.java
+2
-2
FrequentQuestionStatusEnum.java
...ytesw/bytebot/model/enums/FrequentQuestionStatusEnum.java
+2
-2
ChannelParamRepository.java
...com/bytesw/bytebot/repository/ChannelParamRepository.java
+1
-1
AgentService.java
src/main/java/com/bytesw/bytebot/service/AgentService.java
+45
-21
No files found.
src/main/java/com/bytesw/bytebot/bean/AgentBean.java
View file @
cf6d3f18
...
...
@@ -60,7 +60,7 @@ public class AgentBean {
private
List
<
DeploymentChannelBean
>
deploymentChannels
;
@Expose
private
List
<
FrequentQuestionBean
>
frequentQuestion
;
private
List
<
FrequentQuestionBean
>
frequentQuestion
s
;
public
static
AgentBean
miniClone
(
Agent
agent
)
{
AgentBean
bean
=
new
AgentBean
();
...
...
src/main/java/com/bytesw/bytebot/model/FrequentQuestion.java
View file @
cf6d3f18
...
...
@@ -44,8 +44,8 @@ public class FrequentQuestion {
@Column
(
name
=
"FQUE_NAME"
)
private
String
filename
;
//
@Column(name = "FQUE_DESC")
//
private String description;
@Column
(
name
=
"FQUE_DESC"
)
private
String
description
;
@Column
(
name
=
"FQUE_STATE"
)
@Convert
(
converter
=
FrequentQuestionStatusConverter
.
class
)
...
...
src/main/java/com/bytesw/bytebot/model/enums/FrequentQuestionStatusEnum.java
View file @
cf6d3f18
...
...
@@ -19,8 +19,8 @@ import java.util.Map;
@Getter
public
enum
FrequentQuestionStatusEnum
{
ACTIVE
(
"AC
"
),
UPLOADED
(
"
UP
"
),
PENDING_SYNCHRONIZED
(
"PS
"
),
UPLOADED
(
"
LO
"
),
DELETED
(
"DE"
);
private
static
final
Map
<
String
,
FrequentQuestionStatusEnum
>
map
=
new
HashMap
<>();
...
...
src/main/java/com/bytesw/bytebot/repository/ChannelParamRepository.java
View file @
cf6d3f18
...
...
@@ -19,6 +19,6 @@ import java.util.Optional;
*/
public
interface
ChannelParamRepository
extends
CrudRepository
<
ChannelParam
,
Long
>
{
Optional
<
ChannelParam
>
findByName
(
String
name
);
Optional
<
ChannelParam
>
findByName
AndChannelId
(
String
name
,
Long
id
);
}
src/main/java/com/bytesw/bytebot/service/AgentService.java
View file @
cf6d3f18
...
...
@@ -16,7 +16,6 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
...
...
@@ -48,7 +47,7 @@ public class AgentService extends CustomPaginationService<Agent> {
@Autowired
private
FrequentQuestionRepository
frequentQuestionRepository
;
@Transactional
(
readOnly
=
true
,
propagation
=
Propagation
.
NOT_SUPPORTED
)
@Transactional
(
transactionManager
=
"bytebotTransactionManager"
,
readOnly
=
true
,
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
searchByPagination
(
Pagination
<
AgentBean
>
pagination
)
{
if
(
pagination
.
getItemsPerPage
()
==
0
)
{
pagination
.
setItemsPerPage
(
10
);
...
...
@@ -88,7 +87,7 @@ public class AgentService extends CustomPaginationService<Agent> {
pagination
.
setData
(
list
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
)
@Transactional
(
transactionManager
=
"bytebotTransactionManager"
,
propagation
=
Propagation
.
REQUIRED
)
public
void
save
(
AgentBean
agent
)
{
boolean
isModify
=
true
;
...
...
@@ -103,11 +102,13 @@ public class AgentService extends CustomPaginationService<Agent> {
}
}
if
(
agent
==
null
)
{
if
(
agent
BD
==
null
)
{
agentBD
=
new
Agent
();
agentBD
.
setStatus
(
AgentStatusEnum
.
CREATED
);
isModify
=
false
;
}
else
{
agentBD
.
setStatus
(
AgentStatusEnum
.
fromString
(
agent
.
getStatus
()));
}
// General Information
...
...
@@ -130,16 +131,18 @@ public class AgentService extends CustomPaginationService<Agent> {
agentBD
.
setCountry
(
null
);
}
agentBD
=
agentRepository
.
save
(
agentBD
);
// Frequent questions
if
(
agent
.
getFrequentQuestion
()
==
null
)
{
agent
.
setFrequentQuestion
(
new
ArrayList
<>());
if
(
agent
.
getFrequentQuestion
s
()
==
null
)
{
agent
.
setFrequentQuestion
s
(
new
ArrayList
<>());
}
if
(
agentBD
.
getFrequentQuestions
()
!=
null
)
{
for
(
FrequentQuestion
frequentQuestionBD
:
agentBD
.
getFrequentQuestions
())
{
boolean
found
=
false
;
for
(
FrequentQuestionBean
frequentQuestionBean
:
agent
.
getFrequentQuestion
())
{
for
(
FrequentQuestionBean
frequentQuestionBean
:
agent
.
getFrequentQuestion
s
())
{
if
(
frequentQuestionBean
.
getId
()
!=
null
&&
frequentQuestionBD
.
getId
().
compareTo
(
frequentQuestionBean
.
getId
())
==
0
)
{
found
=
true
;
break
;
...
...
@@ -152,7 +155,7 @@ public class AgentService extends CustomPaginationService<Agent> {
}
}
for
(
FrequentQuestionBean
frequentQuestionBean
:
agent
.
getFrequentQuestion
())
{
for
(
FrequentQuestionBean
frequentQuestionBean
:
agent
.
getFrequentQuestion
s
())
{
FrequentQuestion
frequentQuestionBD
=
null
;
if
(
frequentQuestionBean
.
getId
()
!=
null
)
{
...
...
@@ -165,15 +168,16 @@ public class AgentService extends CustomPaginationService<Agent> {
if
(
frequentQuestionBD
==
null
)
{
frequentQuestionBD
=
new
FrequentQuestion
();
frequentQuestionBD
.
setStatus
(
FrequentQuestionStatusEnum
.
ACTIVE
);
frequentQuestionBD
.
setStatus
(
FrequentQuestionStatusEnum
.
PENDING_SYNCHRONIZED
);
frequentQuestionBD
.
setUploadDate
(
LocalDateTime
.
now
());
}
else
{
frequentQuestionBD
.
setAgent
(
agentBD
);
frequentQuestionBD
.
setFilename
(
frequentQuestionBean
.
getFilename
());
frequentQuestionBD
.
setStatus
(
FrequentQuestionStatusEnum
.
fromString
(
frequentQuestionBean
.
getStatus
()));
frequentQuestionBD
.
setUser
(
frequentQuestionBean
.
getUser
());
}
frequentQuestionBD
.
setAgent
(
agentBD
);
frequentQuestionBD
.
setDescription
(
frequentQuestionBean
.
getDescription
());
frequentQuestionBD
.
setFilename
(
frequentQuestionBean
.
getFilename
());
frequentQuestionBD
.
setStatus
(
FrequentQuestionStatusEnum
.
fromString
(
frequentQuestionBean
.
getStatus
()));
frequentQuestionBD
.
setUser
(
frequentQuestionBean
.
getUser
());
frequentQuestionRepository
.
save
(
frequentQuestionBD
);
}
...
...
@@ -276,15 +280,16 @@ public class AgentService extends CustomPaginationService<Agent> {
deploymentChannelParamValue
.
setValue
(
deploymentChannelParamValueBean
.
getValue
());
if
(
deploymentChannelParamValueBean
.
getChannelParamName
()
!=
null
)
{
Optional
<
ChannelParam
>
channelParamFound
=
channelParamRepository
.
findByName
(
deploymentChannelParamValueBean
.
getChannelParamName
());
Optional
<
ChannelParam
>
channelParamFound
=
channelParamRepository
.
findByNameAndChannelId
(
deploymentChannelParamValueBean
.
getChannelParamName
(),
deploymentChannelBean
.
getChannelId
());
if
(
channelParamFound
.
isPresent
())
{
deploymentChannelParamValue
.
setParameter
(
channelParamFound
.
get
());
}
}
else
{
deploymentChannelParamValue
.
setParameter
(
null
);
}
deploymentChannelParamValue
.
setParameter
(
null
);
deploymentChannelParamValueRepository
.
save
(
deploymentChannelParamValue
);
}
...
...
@@ -292,8 +297,11 @@ public class AgentService extends CustomPaginationService<Agent> {
}
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
@Transactional
(
transactionManager
=
"bytebotTransactionManager"
,
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
AgentBean
getAgent
(
Long
id
)
{
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"dd/MM/yyyy"
);
AgentBean
bean
=
null
;
Optional
<
Agent
>
agentFound
=
agentRepository
.
findById
(
id
);
...
...
@@ -318,10 +326,26 @@ public class AgentService extends CustomPaginationService<Agent> {
bean
.
setCountryId
(
agent
.
getCountry
().
getId
());
}
bean
.
setDeploymentChannels
(
new
ArrayList
<>());
// Deployment channel
bean
.
setFrequentQuestions
(
new
ArrayList
<>());
for
(
FrequentQuestion
frequentQuestion
:
agent
.
getFrequentQuestions
())
{
FrequentQuestionBean
frequentQuestionBean
=
new
FrequentQuestionBean
();
frequentQuestionBean
.
setId
(
frequentQuestion
.
getId
());
frequentQuestionBean
.
setDescription
(
frequentQuestion
.
getDescription
());
frequentQuestionBean
.
setUser
(
frequentQuestion
.
getUser
());
frequentQuestionBean
.
setFilename
(
frequentQuestion
.
getFilename
());
frequentQuestionBean
.
setUploadDate
(
frequentQuestion
.
getUploadDate
().
format
(
formatter
));
frequentQuestionBean
.
setStatus
(
frequentQuestion
.
getStatus
().
getName
());
bean
.
getFrequentQuestions
().
add
(
frequentQuestionBean
);
}
// Deployment channel
bean
.
setDeploymentChannels
(
new
ArrayList
<>());
for
(
DeploymentChannel
deploymentChannel
:
agent
.
getDeploymentChannels
())
{
DeploymentChannelBean
deploymentChannelBean
=
new
DeploymentChannelBean
();
deploymentChannelBean
.
setId
(
deploymentChannel
.
getId
());
...
...
@@ -355,7 +379,7 @@ public class AgentService extends CustomPaginationService<Agent> {
return
bean
;
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
)
@Transactional
(
transactionManager
=
"bytebotTransactionManager"
,
propagation
=
Propagation
.
REQUIRED
)
public
boolean
delete
(
Long
id
)
{
boolean
isValid
=
true
;
...
...
@@ -385,7 +409,7 @@ public class AgentService extends CustomPaginationService<Agent> {
return
countriesBean
;
}
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
,
readOnly
=
true
)
@Transactional
(
transactionManager
=
"bytebotTransactionManager"
,
propagation
=
Propagation
.
NOT_SUPPORTED
,
readOnly
=
true
)
public
List
<
ChannelBean
>
getChannels
()
{
List
<
ChannelBean
>
channelsBean
=
new
ArrayList
<>();
List
<
Channel
>
channels
=
(
List
<
Channel
>)
channelRepository
.
findAll
();
...
...
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