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
b5f98f8b
Commit
b5f98f8b
authored
Sep 10, 2020
by
Sebastian Chicoma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nuevos cambios para soportar el envio a la web de: canales, parámetros y países
parent
34c3a4ef
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
668 additions
and
46 deletions
+668
-46
AgentBean.java
src/main/java/com/bytesw/bytebot/bean/AgentBean.java
+3
-0
ChannelBean.java
src/main/java/com/bytesw/bytebot/bean/ChannelBean.java
+62
-0
ChannelParamBean.java
src/main/java/com/bytesw/bytebot/bean/ChannelParamBean.java
+59
-0
CountryBean.java
src/main/java/com/bytesw/bytebot/bean/CountryBean.java
+53
-0
DeploymentChannelParamValueBean.java
.../bytesw/bytebot/bean/DeploymentChannelParamValueBean.java
+1
-1
FrequentQuestionBean.java
...in/java/com/bytesw/bytebot/bean/FrequentQuestionBean.java
+42
-0
AgentController.java
...n/java/com/bytesw/bytebot/controller/AgentController.java
+28
-1
Agent.java
src/main/java/com/bytesw/bytebot/model/Agent.java
+12
-6
Channel.java
src/main/java/com/bytesw/bytebot/model/Channel.java
+6
-2
ChannelParam.java
src/main/java/com/bytesw/bytebot/model/ChannelParam.java
+6
-2
Country.java
src/main/java/com/bytesw/bytebot/model/Country.java
+11
-4
DeploymentChannel.java
...main/java/com/bytesw/bytebot/model/DeploymentChannel.java
+3
-2
DeploymentChannelParamValue.java
...com/bytesw/bytebot/model/DeploymentChannelParamValue.java
+6
-5
FrequentQuestion.java
src/main/java/com/bytesw/bytebot/model/FrequentQuestion.java
+11
-8
Timezone.java
src/main/java/com/bytesw/bytebot/model/Timezone.java
+38
-0
AgentStatusConverter.java
...bytesw/bytebot/model/converters/AgentStatusConverter.java
+31
-0
FrequentQuestionStatusConverter.java
...bot/model/converters/FrequentQuestionStatusConverter.java
+32
-0
LanguageConverter.java
...om/bytesw/bytebot/model/converters/LanguageConverter.java
+31
-0
AgentStatusEnum.java
.../java/com/bytesw/bytebot/model/enums/AgentStatusEnum.java
+43
-0
AgentTypeEnum.java
...in/java/com/bytesw/bytebot/model/enums/AgentTypeEnum.java
+1
-1
FrequentQuestionStatusEnum.java
...ytesw/bytebot/model/enums/FrequentQuestionStatusEnum.java
+43
-0
LanguageEnum.java
...ain/java/com/bytesw/bytebot/model/enums/LanguageEnum.java
+34
-0
ChannelParamRepository.java
...com/bytesw/bytebot/repository/ChannelParamRepository.java
+5
-0
FrequentQuestionRepository.java
...bytesw/bytebot/repository/FrequentQuestionRepository.java
+19
-0
AgentService.java
src/main/java/com/bytesw/bytebot/service/AgentService.java
+88
-14
No files found.
src/main/java/com/bytesw/bytebot/bean/AgentBean.java
View file @
b5f98f8b
...
...
@@ -59,6 +59,9 @@ public class AgentBean {
@Expose
private
List
<
DeploymentChannelBean
>
deploymentChannels
;
@Expose
private
List
<
FrequentQuestionBean
>
frequentQuestion
;
public
static
AgentBean
miniClone
(
Agent
agent
)
{
AgentBean
bean
=
new
AgentBean
();
...
...
src/main/java/com/bytesw/bytebot/bean/ChannelBean.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
bean
;
import
com.bytesw.bytebot.model.Channel
;
import
com.bytesw.bytebot.model.ChannelParam
;
import
com.google.gson.annotations.Expose
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
/**
* @author Sebastian Chicoma Sandmann
* @version 10-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public
class
ChannelBean
{
@Expose
private
Long
id
;
@Expose
private
String
name
;
@Expose
private
String
image
;
@Expose
private
List
<
ChannelParamBean
>
parameters
;
public
static
ChannelBean
clone
(
Channel
channel
)
{
ChannelBean
bean
=
new
ChannelBean
();
bean
.
setId
(
channel
.
getId
());
bean
.
setName
(
channel
.
getName
());
bean
.
setImage
(
channel
.
getImage
());
bean
.
setParameters
(
new
ArrayList
<>());
if
(
channel
.
getParameters
()
!=
null
)
{
Collections
.
sort
(
channel
.
getParameters
(),
(
o1
,
o2
)
->
o1
.
getOrder
()
-
o2
.
getOrder
());
for
(
ChannelParam
param
:
channel
.
getParameters
())
{
bean
.
getParameters
().
add
(
ChannelParamBean
.
clone
(
param
));
}
}
return
bean
;
}
}
src/main/java/com/bytesw/bytebot/bean/ChannelParamBean.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
bean
;
import
com.bytesw.bytebot.model.ChannelParam
;
import
com.google.gson.annotations.Expose
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
* @author Sebastian Chicoma Sandmann
* @version 10-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public
class
ChannelParamBean
{
@Expose
private
String
name
;
@Expose
private
String
label
;
@Expose
private
Integer
maxlength
;
@Expose
private
String
type
;
@Expose
private
Boolean
required
;
@Expose
private
Integer
order
;
@Expose
private
String
traductions
;
public
static
ChannelParamBean
clone
(
ChannelParam
channelParam
)
{
ChannelParamBean
bean
=
new
ChannelParamBean
();
bean
.
setName
(
channelParam
.
getName
());
bean
.
setLabel
(
channelParam
.
getLabel
());
bean
.
setMaxlength
(
channelParam
.
getMaxlength
());
bean
.
setRequired
(
channelParam
.
isRequired
());
bean
.
setType
(
channelParam
.
getType
());
bean
.
setOrder
(
channelParam
.
getOrder
());
bean
.
setTraductions
(
channelParam
.
getTraductions
());
return
bean
;
}
}
src/main/java/com/bytesw/bytebot/bean/CountryBean.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
bean
;
import
com.bytesw.bytebot.model.Country
;
import
com.bytesw.bytebot.model.Timezone
;
import
com.google.gson.annotations.Expose
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author Sebastian Chicoma Sandmann
* @version 10-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public
class
CountryBean
{
@Expose
private
Long
id
;
@Expose
private
String
name
;
@Expose
private
List
<
String
>
timezones
;
public
static
CountryBean
clone
(
Country
country
)
{
CountryBean
bean
=
new
CountryBean
();
bean
.
setId
(
country
.
getId
());
bean
.
setName
(
country
.
getName
());
bean
.
setTimezones
(
new
ArrayList
<>());
if
(
country
.
getTimezones
()
!=
null
)
{
for
(
Timezone
timezone
:
country
.
getTimezones
())
{
bean
.
getTimezones
().
add
(
timezone
.
getTimezone
());
}
}
return
bean
;
}
}
src/main/java/com/bytesw/bytebot/bean/DeploymentChannelParamValueBean.java
View file @
b5f98f8b
...
...
@@ -26,7 +26,7 @@ public class DeploymentChannelParamValueBean {
private
Long
id
;
@Expose
private
Long
channelParamId
;
private
String
channelParamName
;
@Expose
private
String
value
;
...
...
src/main/java/com/bytesw/bytebot/bean/FrequentQuestionBean.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
bean
;
import
com.google.gson.annotations.Expose
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
@Setter
@ToString
public
class
FrequentQuestionBean
{
@Expose
private
Long
id
;
@Expose
private
String
filename
;
@Expose
private
String
description
;
@Expose
private
String
status
;
@Expose
private
String
user
;
@Expose
private
String
uploadDate
;
}
src/main/java/com/bytesw/bytebot/controller/AgentController.java
View file @
b5f98f8b
...
...
@@ -47,7 +47,6 @@ public class AgentController {
}
}
@GetMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"hasPermission(this, 'view')"
)
public
ResponseEntity
<
String
>
getExternalSystemServiceById
(
@ApiParam
(
value
=
"id"
,
required
=
true
)
@PathVariable
(
"id"
)
Long
id
)
{
...
...
@@ -128,4 +127,32 @@ public class AgentController {
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
ExceptionUtils
.
getFullStackTrace
(
e
)),
hs
);
}
}
@GetMapping
(
value
=
"/countries"
)
public
ResponseEntity
<
String
>
getCountries
()
{
HttpStatus
hs
=
HttpStatus
.
OK
;
try
{
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
agentService
.
getCountries
()),
hs
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error detectado: "
,
e
);
hs
=
HttpStatus
.
INTERNAL_SERVER_ERROR
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
ExceptionUtils
.
getFullStackTrace
(
e
)),
hs
);
}
}
@GetMapping
(
value
=
"/channels"
)
public
ResponseEntity
<
String
>
getChannels
()
{
HttpStatus
hs
=
HttpStatus
.
OK
;
try
{
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
agentService
.
getChannels
()),
hs
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error detectado: "
,
e
);
hs
=
HttpStatus
.
INTERNAL_SERVER_ERROR
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
ExceptionUtils
.
getFullStackTrace
(
e
)),
hs
);
}
}
}
src/main/java/com/bytesw/bytebot/model/Agent.java
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
model
;
import
com.bytesw.bytebot.model.converters.AgentStatusConverter
;
import
com.bytesw.bytebot.model.converters.AgentTypeConverter
;
import
com.bytesw.bytebot.model.converters.LanguageConverter
;
import
com.bytesw.bytebot.model.converters.StatusConverter
;
import
com.bytesw.bytebot.model.enums.AgentStatusEnum
;
import
com.bytesw.bytebot.model.enums.AgentTypeEnum
;
import
com.bytesw.bytebot.model.enums.LanguageEnum
;
import
com.bytesw.bytebot.model.enums.StatusEnum
;
import
lombok.*
;
...
...
@@ -18,10 +22,10 @@ import java.util.List;
public
class
Agent
implements
Serializable
{
@Id
@TableGenerator
(
name
=
"BBOT_AGENT_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_AGENT_SEQ"
,
allocationSize
=
1
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_AGENT_GENERATOR"
)
@Column
(
name
=
"AGEN_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_AGENT_GENERATOR"
)
@TableGenerator
(
name
=
"BBOT_AGENT_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_AGENT_SEQ"
)
private
Long
id
;
@Column
(
name
=
"AGEN_IDEN"
)
...
...
@@ -34,7 +38,8 @@ public class Agent implements Serializable {
private
String
version
;
@Column
(
name
=
"AGEN_LANG"
)
private
String
language
;
@Convert
(
converter
=
LanguageConverter
.
class
)
private
LanguageEnum
language
;
@Column
(
name
=
"AGEN_TZONE"
)
private
String
timezone
;
...
...
@@ -49,12 +54,13 @@ public class Agent implements Serializable {
private
Country
country
;
@Column
(
name
=
"AGEN_STATE"
)
@Convert
(
converter
=
StatusConverter
.
class
)
private
StatusEnum
status
;
@Convert
(
converter
=
Agent
StatusConverter
.
class
)
private
Agent
StatusEnum
status
;
@Column
(
name
=
"AGEN_TYPE"
)
@Convert
(
converter
=
AgentTypeConverter
.
class
)
private
AgentTypeEnum
type
;
@OneToMany
(
mappedBy
=
"agent"
)
private
List
<
DeploymentChannel
>
deploymentChannels
;
...
...
src/main/java/com/bytesw/bytebot/model/Channel.java
View file @
b5f98f8b
...
...
@@ -29,13 +29,17 @@ public class Channel {
@Id
@Column
(
name
=
"CHAN_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_CHANNEL_SEQ"
)
@TableGenerator
(
name
=
"BBOT_CHANNEL_SEQ"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_VALUE"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_CHANNEL_GENERATOR"
)
@TableGenerator
(
name
=
"BBOT_CHANNEL_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_CHANNEL_SEQ"
)
private
Long
id
;
@Column
(
name
=
"CHAN_IDEN"
)
private
String
name
;
@Column
(
name
=
"CHAN_IMAG"
)
private
String
image
;
@OneToMany
(
mappedBy
=
"channel"
)
private
List
<
ChannelParam
>
parameters
;
...
...
src/main/java/com/bytesw/bytebot/model/ChannelParam.java
View file @
b5f98f8b
...
...
@@ -29,8 +29,9 @@ public class ChannelParam {
@Id
@Column
(
name
=
"CHPA_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_CHANNEL_PARAM_SEQ"
)
@TableGenerator
(
name
=
"BBOT_CHANNEL_PARAM_SEQ"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_VALUE"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_CHANNEL_PARAM_GENERATOR"
)
@TableGenerator
(
name
=
"BBOT_CHANNEL_PARAM_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_CHANNEL_PARAM_SEQ"
)
private
Long
id
;
@Column
(
name
=
"CHPA_IDEN"
)
...
...
@@ -53,6 +54,9 @@ public class ChannelParam {
@Column
(
name
=
"CHPA_TRADU"
)
private
String
traductions
;
@Column
(
name
=
"CHPA_TYPE"
)
private
String
type
;
@Column
(
name
=
"CHPA_MAXLE"
)
private
Integer
maxlength
;
...
...
src/main/java/com/bytesw/bytebot/model/Country.java
View file @
b5f98f8b
...
...
@@ -3,21 +3,28 @@ package com.bytesw.bytebot.model;
import
lombok.*
;
import
javax.persistence.*
;
import
java.util.List
;
@Entity
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
"id"
)
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
"id"
)
@NoArgsConstructor
@Table
(
name
=
"BBOT_COUNTRY"
)
@NamedQuery
(
name
=
"Country.findByPK"
,
query
=
"Select u from Country u where u.id = ?1"
)
public
class
Country
{
@Id
@TableGenerator
(
name
=
"BBOT_COUNTRY_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_COUNTRY_SEQ"
,
allocationSize
=
1
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_COUNTRY_GENERATOR"
)
@Column
(
name
=
"COUN_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_COUNTRY_GENERATOR"
)
@TableGenerator
(
name
=
"BBOT_COUNTRY_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_COUNTRY_SEQ"
)
private
Long
id
;
@Column
(
name
=
"COUN_NAME"
,
nullable
=
false
)
private
String
name
;
@OneToMany
(
mappedBy
=
"country"
)
private
List
<
Timezone
>
timezones
;
}
src/main/java/com/bytesw/bytebot/model/DeploymentChannel.java
View file @
b5f98f8b
...
...
@@ -31,8 +31,9 @@ public class DeploymentChannel {
@Id
@Column
(
name
=
"DCHA_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_DEPLOYMENT_CHANNEL_SEQ"
)
@TableGenerator
(
name
=
"BBOT_DEPLOYMENT_CHANNEL_SEQ"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_VALUE"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_DEPLOYMENT_CHANNEL_GENERATOR"
)
@TableGenerator
(
name
=
"BBOT_DEPLOYMENT_CHANNEL_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_DEPLOYMENT_CHANNEL_SEQ"
)
private
Long
id
;
@Column
(
name
=
"DCHA_NAME"
)
...
...
src/main/java/com/bytesw/bytebot/model/DeploymentChannelParamValue.java
View file @
b5f98f8b
...
...
@@ -19,7 +19,7 @@ import javax.persistence.*;
* licencia de uso que firmó con Byte.
*/
@Entity
@Table
(
name
=
"BBOT_CHANNEL_PARAM_VALUE"
)
@Table
(
name
=
"BBOT_
DEPLOYMENT_
CHANNEL_PARAM_VALUE"
)
@Getter
@Setter
@ToString
...
...
@@ -27,9 +27,10 @@ import javax.persistence.*;
public
class
DeploymentChannelParamValue
{
@Id
@Column
(
name
=
"CPVA_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_CHANNEL_PARAM_VALUE_SEQ"
)
@TableGenerator
(
name
=
"BBOT_CHANNEL_PARAM_VALUE_SEQ"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_VALUE"
)
@Column
(
name
=
"CHPV_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_DEPLOYMENT_CHANNEL_PARAM_VALUE_GENERATOR"
)
@TableGenerator
(
name
=
"BBOT_DEPLOYMENT_CHANNEL_PARAM_VALUE_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_DEPLOYMENT_CHANNEL_PARAM_VALUE_SEQ"
)
private
Long
id
;
@ManyToOne
...
...
@@ -40,7 +41,7 @@ public class DeploymentChannelParamValue {
@JoinColumn
(
name
=
"DCHA_ID"
,
referencedColumnName
=
"DCHA_ID"
)
private
DeploymentChannel
deploymentChannel
;
@Column
(
name
=
"CHP
A
_VALUE"
)
@Column
(
name
=
"CHP
V
_VALUE"
)
private
String
value
;
}
src/main/java/com/bytesw/bytebot/model/FrequentQuestion.java
View file @
b5f98f8b
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
;
...
...
@@ -31,22 +33,23 @@ import java.time.OffsetDateTime;
public
class
FrequentQuestion
{
@Id
@Column
(
name
=
"FQUE_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_FREQUENT_QUESTION_SEQ"
)
@TableGenerator
(
name
=
"BBOT_FREQUENT_QUESTION_SEQ"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_VALUE"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_FREQUENT_QUESTION_GENERATOR"
)
@TableGenerator
(
name
=
"BBOT_FREQUENT_QUESTION_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_FREQUENT_QUESTION_SEQ"
)
private
Long
id
;
@Column
(
name
=
"FQUE_PATH"
)
private
String
filePath
;
//
@Column(name = "FQUE_PATH")
//
private String filePath;
@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
=
StatusConverter
.
class
)
private
StatusEnum
status
;
@Convert
(
converter
=
FrequentQuestion
StatusConverter
.
class
)
private
FrequentQuestion
StatusEnum
status
;
@ManyToOne
@JoinColumn
(
name
=
"AGEN_ID"
,
referencedColumnName
=
"AGEN_ID"
)
...
...
src/main/java/com/bytesw/bytebot/model/Timezone.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
model
;
import
lombok.*
;
import
javax.persistence.*
;
/**
* @author Sebastian Chicoma Sandmann
* @version 10-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Entity
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
"id"
)
@NoArgsConstructor
@Table
(
name
=
"BBOT_TIMEZONE"
)
public
class
Timezone
{
@Id
@Column
(
name
=
"TZON_ID"
)
@GeneratedValue
(
strategy
=
GenerationType
.
TABLE
,
generator
=
"BBOT_TIMEZONE_GENERATOR"
)
@TableGenerator
(
name
=
"BBOT_TIMEZONE_GENERATOR"
,
table
=
"SEQUENCE_TABLE"
,
pkColumnName
=
"SEQ_NAME"
,
valueColumnName
=
"SEQ_COUNT"
,
pkColumnValue
=
"BBOT_TIMEZONE_SEQ"
)
private
Long
id
;
@Column
(
name
=
"TZON_ZONE"
,
nullable
=
false
)
private
String
timezone
;
@ManyToOne
@JoinColumn
(
name
=
"COUN_ID"
,
referencedColumnName
=
"COUN_ID"
)
private
Country
country
;
}
src/main/java/com/bytesw/bytebot/model/converters/AgentStatusConverter.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
model
.
converters
;
import
com.bytesw.bytebot.model.enums.AgentStatusEnum
;
import
org.apache.camel.Converter
;
import
javax.persistence.AttributeConverter
;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Converter
public
class
AgentStatusConverter
implements
AttributeConverter
<
AgentStatusEnum
,
String
>
{
@Override
public
String
convertToDatabaseColumn
(
AgentStatusEnum
value
)
{
return
value
.
getName
();
}
@Override
public
AgentStatusEnum
convertToEntityAttribute
(
String
value
)
{
return
AgentStatusEnum
.
fromString
(
value
);
}
}
\ No newline at end of file
src/main/java/com/bytesw/bytebot/model/converters/FrequentQuestionStatusConverter.java
0 → 100644
View file @
b5f98f8b
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
;
import
javax.persistence.AttributeConverter
;
/**
* @author Sebastian Chicoma Sandmann
* @version 10-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Converter
public
class
FrequentQuestionStatusConverter
implements
AttributeConverter
<
FrequentQuestionStatusEnum
,
String
>
{
@Override
public
String
convertToDatabaseColumn
(
FrequentQuestionStatusEnum
value
)
{
return
value
.
getName
();
}
@Override
public
FrequentQuestionStatusEnum
convertToEntityAttribute
(
String
value
)
{
return
FrequentQuestionStatusEnum
.
fromString
(
value
);
}
}
\ No newline at end of file
src/main/java/com/bytesw/bytebot/model/converters/LanguageConverter.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
model
.
converters
;
import
com.bytesw.bytebot.model.enums.LanguageEnum
;
import
org.apache.camel.Converter
;
import
javax.persistence.AttributeConverter
;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Converter
public
class
LanguageConverter
implements
AttributeConverter
<
LanguageEnum
,
String
>
{
@Override
public
String
convertToDatabaseColumn
(
LanguageEnum
value
)
{
return
value
.
getName
();
}
@Override
public
LanguageEnum
convertToEntityAttribute
(
String
value
)
{
return
LanguageEnum
.
fromString
(
value
);
}
}
\ No newline at end of file
src/main/java/com/bytesw/bytebot/model/enums/AgentStatusEnum.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
model
.
enums
;
import
lombok.Getter
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
public
enum
AgentStatusEnum
{
CREATED
(
"CR"
),
DEPLOYED
(
"DP"
),
DELETED
(
"DE"
);
private
static
final
Map
<
String
,
AgentStatusEnum
>
map
=
new
HashMap
<>();
private
String
name
;
AgentStatusEnum
(
String
name
)
{
this
.
name
=
name
;
}
static
{
for
(
AgentStatusEnum
type
:
AgentStatusEnum
.
values
())
{
map
.
put
(
type
.
name
,
type
);
}
}
public
static
AgentStatusEnum
fromString
(
String
name
)
{
return
map
.
get
(
name
);
}
}
src/main/java/com/bytesw/bytebot/model/enums/AgentTypeEnum.java
View file @
b5f98f8b
...
...
@@ -5,7 +5,7 @@ import java.util.Map;
import
java.util.NoSuchElementException
;
public
enum
AgentTypeEnum
{
FREQUENT_QUESTION
(
"F"
);
FREQUENT_QUESTION
(
"F
Q
"
);
private
final
String
name
;
...
...
src/main/java/com/bytesw/bytebot/model/enums/FrequentQuestionStatusEnum.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
model
.
enums
;
import
lombok.Getter
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author Sebastian Chicoma Sandmann
* @version 09-sep-2020
*
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
*
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
@Getter
public
enum
FrequentQuestionStatusEnum
{
ACTIVE
(
"AC"
),
UPLOADED
(
"UP"
),
DELETED
(
"DE"
);
private
static
final
Map
<
String
,
FrequentQuestionStatusEnum
>
map
=
new
HashMap
<>();
private
String
name
;
FrequentQuestionStatusEnum
(
String
name
)
{
this
.
name
=
name
;
}
static
{
for
(
FrequentQuestionStatusEnum
type
:
FrequentQuestionStatusEnum
.
values
())
{
map
.
put
(
type
.
name
,
type
);
}
}
public
static
FrequentQuestionStatusEnum
fromString
(
String
name
)
{
return
map
.
get
(
name
);
}
}
src/main/java/com/bytesw/bytebot/model/enums/LanguageEnum.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
model
.
enums
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.NoSuchElementException
;
public
enum
LanguageEnum
{
SPANISH
(
"ES"
);
private
final
String
name
;
private
static
final
Map
<
String
,
LanguageEnum
>
map
=
new
HashMap
<>();
static
{
for
(
LanguageEnum
type
:
LanguageEnum
.
values
())
{
map
.
put
(
type
.
name
,
type
);
}
}
LanguageEnum
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
()
{
return
name
;
}
public
static
LanguageEnum
fromString
(
String
name
)
{
if
(
map
.
containsKey
(
name
))
{
return
map
.
get
(
name
);
}
throw
new
NoSuchElementException
(
name
+
" not found"
);
}
}
src/main/java/com/bytesw/bytebot/repository/ChannelParamRepository.java
View file @
b5f98f8b
...
...
@@ -4,6 +4,8 @@ import com.bytesw.bytebot.model.Channel;
import
com.bytesw.bytebot.model.ChannelParam
;
import
org.springframework.data.repository.CrudRepository
;
import
java.util.Optional
;
/**
* @author Sebastián Chicoma Sandmann.
* @version 9-sep-2020
...
...
@@ -16,4 +18,7 @@ import org.springframework.data.repository.CrudRepository;
* licencia de uso que firmó con Byte.
*/
public
interface
ChannelParamRepository
extends
CrudRepository
<
ChannelParam
,
Long
>
{
Optional
<
ChannelParam
>
findByName
(
String
name
);
}
src/main/java/com/bytesw/bytebot/repository/FrequentQuestionRepository.java
0 → 100644
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
repository
;
import
com.bytesw.bytebot.model.DeploymentChannel
;
import
com.bytesw.bytebot.model.FrequentQuestion
;
import
org.springframework.data.repository.CrudRepository
;
/**
* @author Sebastián Chicoma Sandmann.
* @version 9-sep-2020
* <p>
* Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
* <p>
* Este software constituye información confidencial y propietaria de Byte, S.A.
* ("Información Confidencial"). Usted no debe develar dicha Información
* Confidencial y debe usarla de acuerdo con los términos de aceptación de
* licencia de uso que firmó con Byte.
*/
public
interface
FrequentQuestionRepository
extends
CrudRepository
<
FrequentQuestion
,
Long
>
{
}
src/main/java/com/bytesw/bytebot/service/AgentService.java
View file @
b5f98f8b
package
com
.
bytesw
.
bytebot
.
service
;
import
com.bytesw.bytebot.bean.AgentBean
;
import
com.bytesw.bytebot.bean.DeploymentChannelBean
;
import
com.bytesw.bytebot.bean.DeploymentChannelParamValueBean
;
import
com.bytesw.bytebot.bean.*
;
import
com.bytesw.bytebot.model.*
;
import
com.bytesw.bytebot.model.enums.AgentTypeEnum
;
import
com.bytesw.bytebot.model.enums.StatusEnum
;
import
com.bytesw.bytebot.model.enums.*
;
import
com.bytesw.bytebot.repository.*
;
import
com.bytesw.xdf.sql.beans.Pagination
;
import
lombok.extern.log4j.Log4j2
;
...
...
@@ -19,7 +16,9 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.swing.text.html.Option
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -46,6 +45,9 @@ public class AgentService extends CustomPaginationService<Agent> {
@Autowired
private
ChannelParamRepository
channelParamRepository
;
@Autowired
private
FrequentQuestionRepository
frequentQuestionRepository
;
@Transactional
(
readOnly
=
true
,
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
searchByPagination
(
Pagination
<
AgentBean
>
pagination
)
{
if
(
pagination
.
getItemsPerPage
()
==
0
)
{
...
...
@@ -65,7 +67,7 @@ public class AgentService extends CustomPaginationService<Agent> {
}
Specification
<
Agent
>
specification
=
(
Specification
<
Agent
>)
(
root
,
query
,
criteriaBuilder
)
->
criteriaBuilder
.
notEqual
(
root
.
get
(
"status"
),
StatusEnum
.
DELETED
);
->
criteriaBuilder
.
notEqual
(
root
.
get
(
"status"
),
Agent
StatusEnum
.
DELETED
);
if
(
pagination
.
getFilterExpression
()
!=
null
&&
pagination
.
getFilterExpression
().
length
()
>
0
)
{
specification
=
createSpecification
(
pagination
.
getFilterExpression
()).
and
(
specification
);
...
...
@@ -103,7 +105,7 @@ public class AgentService extends CustomPaginationService<Agent> {
if
(
agent
==
null
)
{
agentBD
=
new
Agent
();
agentBD
.
setStatus
(
StatusEnum
.
ACTIVE
);
agentBD
.
setStatus
(
AgentStatusEnum
.
CREATED
);
isModify
=
false
;
}
...
...
@@ -112,7 +114,7 @@ public class AgentService extends CustomPaginationService<Agent> {
agentBD
.
setName
(
agent
.
getName
());
agentBD
.
setDescription
(
agent
.
getDescription
());
agentBD
.
setLanguage
(
agent
.
getLanguage
(
));
agentBD
.
setLanguage
(
LanguageEnum
.
fromString
(
agent
.
getLanguage
()
));
agentBD
.
setTimezone
(
agent
.
getTimezone
());
agentBD
.
setVersion
(
agent
.
getVersion
());
agentBD
.
setType
(
AgentTypeEnum
.
fromString
(
agent
.
getType
()));
...
...
@@ -129,7 +131,52 @@ public class AgentService extends CustomPaginationService<Agent> {
}
// Frequent questions
if
(
agent
.
getFrequentQuestion
()
==
null
)
{
agent
.
setFrequentQuestion
(
new
ArrayList
<>());
}
if
(
agentBD
.
getFrequentQuestions
()
!=
null
)
{
for
(
FrequentQuestion
frequentQuestionBD
:
agentBD
.
getFrequentQuestions
())
{
boolean
found
=
false
;
for
(
FrequentQuestionBean
frequentQuestionBean
:
agent
.
getFrequentQuestion
())
{
if
(
frequentQuestionBean
.
getId
()
!=
null
&&
frequentQuestionBD
.
getId
().
compareTo
(
frequentQuestionBean
.
getId
())
==
0
)
{
found
=
true
;
break
;
}
}
if
(!
found
)
{
frequentQuestionRepository
.
delete
(
frequentQuestionBD
);
}
}
}
for
(
FrequentQuestionBean
frequentQuestionBean
:
agent
.
getFrequentQuestion
())
{
FrequentQuestion
frequentQuestionBD
=
null
;
if
(
frequentQuestionBean
.
getId
()
!=
null
)
{
Optional
<
FrequentQuestion
>
frequentQuestionFound
=
frequentQuestionRepository
.
findById
(
frequentQuestionBean
.
getId
());
if
(
frequentQuestionFound
.
isPresent
())
{
frequentQuestionBD
=
frequentQuestionFound
.
get
();
}
}
if
(
frequentQuestionBD
==
null
)
{
frequentQuestionBD
=
new
FrequentQuestion
();
frequentQuestionBD
.
setStatus
(
FrequentQuestionStatusEnum
.
ACTIVE
);
frequentQuestionBD
.
setUploadDate
(
LocalDateTime
.
now
());
}
else
{
frequentQuestionBD
.
setAgent
(
agentBD
);
frequentQuestionBD
.
setFilename
(
frequentQuestionBean
.
getFilename
());
frequentQuestionBD
.
setStatus
(
FrequentQuestionStatusEnum
.
fromString
(
frequentQuestionBean
.
getStatus
()));
frequentQuestionBD
.
setUser
(
frequentQuestionBean
.
getUser
());
}
frequentQuestionRepository
.
save
(
frequentQuestionBD
);
}
// Deployment channels
if
(
agent
.
getDeploymentChannels
()
==
null
)
{
...
...
@@ -183,6 +230,8 @@ public class AgentService extends CustomPaginationService<Agent> {
deploymentChannelBD
.
setChannel
(
null
);
}
deploymentChannelRepository
.
save
(
deploymentChannelBD
);
// Deployment Channel parameters
if
(
deploymentChannelBean
.
getParameters
()
==
null
)
{
...
...
@@ -226,8 +275,8 @@ public class AgentService extends CustomPaginationService<Agent> {
deploymentChannelParamValue
.
setDeploymentChannel
(
deploymentChannelBD
);
deploymentChannelParamValue
.
setValue
(
deploymentChannelParamValueBean
.
getValue
());
if
(
deploymentChannelParamValueBean
.
getChannelParam
Id
()
!=
null
)
{
Optional
<
ChannelParam
>
channelParamFound
=
channelParamRepository
.
findBy
Id
(
deploymentChannelParamValueBean
.
getChannelParamId
());
if
(
deploymentChannelParamValueBean
.
getChannelParam
Name
()
!=
null
)
{
Optional
<
ChannelParam
>
channelParamFound
=
channelParamRepository
.
findBy
Name
(
deploymentChannelParamValueBean
.
getChannelParamName
());
if
(
channelParamFound
.
isPresent
())
{
deploymentChannelParamValue
.
setParameter
(
channelParamFound
.
get
());
...
...
@@ -235,6 +284,8 @@ public class AgentService extends CustomPaginationService<Agent> {
}
deploymentChannelParamValue
.
setParameter
(
null
);
deploymentChannelParamValueRepository
.
save
(
deploymentChannelParamValue
);
}
}
...
...
@@ -256,7 +307,7 @@ public class AgentService extends CustomPaginationService<Agent> {
bean
.
setName
(
agent
.
getName
());
bean
.
setDescription
(
agent
.
getDescription
());
bean
.
setVersion
(
agent
.
getVersion
());
bean
.
setLanguage
(
agent
.
getLanguage
());
bean
.
setLanguage
(
agent
.
getLanguage
()
.
getName
()
);
bean
.
setTimezone
(
agent
.
getTimezone
());
bean
.
setType
(
agent
.
getType
().
getName
());
bean
.
setStatus
(
agent
.
getStatus
().
getName
());
...
...
@@ -291,7 +342,7 @@ public class AgentService extends CustomPaginationService<Agent> {
parameterBean
.
setValue
(
parameter
.
getValue
());
if
(
parameter
.
getParameter
()
!=
null
)
{
parameterBean
.
setChannelParam
Id
(
parameter
.
getParameter
().
getId
());
parameterBean
.
setChannelParam
Name
(
parameter
.
getParameter
().
getName
());
}
deploymentChannelBean
.
getParameters
().
add
(
parameterBean
);
...
...
@@ -313,7 +364,7 @@ public class AgentService extends CustomPaginationService<Agent> {
if
(
agentFound
.
isPresent
())
{
Agent
agent
=
agentFound
.
get
();
agent
.
setStatus
(
StatusEnum
.
DELETED
);
agent
.
setStatus
(
Agent
StatusEnum
.
DELETED
);
agentRepository
.
save
(
agent
);
}
...
...
@@ -322,4 +373,27 @@ public class AgentService extends CustomPaginationService<Agent> {
return
isValid
;
}
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
,
readOnly
=
true
)
public
List
<
CountryBean
>
getCountries
()
{
List
<
CountryBean
>
countriesBean
=
new
ArrayList
<>();
List
<
Country
>
countries
=
(
List
<
Country
>)
countryRepository
.
findAll
();
for
(
Country
country
:
countries
)
{
countriesBean
.
add
(
CountryBean
.
clone
(
country
));
}
return
countriesBean
;
}
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
,
readOnly
=
true
)
public
List
<
ChannelBean
>
getChannels
()
{
List
<
ChannelBean
>
channelsBean
=
new
ArrayList
<>();
List
<
Channel
>
channels
=
(
List
<
Channel
>)
channelRepository
.
findAll
();
for
(
Channel
channel
:
channels
)
{
channelsBean
.
add
(
ChannelBean
.
clone
(
channel
));
}
return
channelsBean
;
}
}
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