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
00cbc136
Commit
00cbc136
authored
Sep 10, 2020
by
Sebastian Chicoma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lógica de negocio para el CRUD del wizard de agentes
parent
85a82694
Changes
27
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
1294 additions
and
107 deletions
+1294
-107
AgentBean.java
src/main/java/com/bytesw/bytebot/bean/AgentBean.java
+79
-0
DeploymentChannelBean.java
...n/java/com/bytesw/bytebot/bean/DeploymentChannelBean.java
+45
-0
DeploymentChannelParamValueBean.java
.../bytesw/bytebot/bean/DeploymentChannelParamValueBean.java
+33
-0
JPAConfig.java
src/main/java/com/bytesw/bytebot/config/JPAConfig.java
+81
-0
AgentController.java
...n/java/com/bytesw/bytebot/controller/AgentController.java
+131
-0
ResponseController.java
...om/bytesw/bytebot/controller/bean/ResponseController.java
+50
-0
Agent.java
src/main/java/com/bytesw/bytebot/model/Agent.java
+27
-17
Channel.java
src/main/java/com/bytesw/bytebot/model/Channel.java
+42
-0
ChannelParam.java
src/main/java/com/bytesw/bytebot/model/ChannelParam.java
+59
-0
Country.java
src/main/java/com/bytesw/bytebot/model/Country.java
+2
-2
DeploymentChannel.java
...main/java/com/bytesw/bytebot/model/DeploymentChannel.java
+55
-0
DeploymentChannelParamValue.java
...com/bytesw/bytebot/model/DeploymentChannelParamValue.java
+46
-0
FrequentQuestion.java
src/main/java/com/bytesw/bytebot/model/FrequentQuestion.java
+61
-0
AgentStatusConverter.java
...bytesw/bytebot/model/converters/AgentStatusConverter.java
+0
-20
BooleanToStringConverter.java
...sw/bytebot/model/converters/BooleanToStringConverter.java
+29
-0
StatusConverter.java
.../com/bytesw/bytebot/model/converters/StatusConverter.java
+31
-0
AgentStatusEnum.java
.../java/com/bytesw/bytebot/model/enums/AgentStatusEnum.java
+0
-34
LanguageEnum.java
...ain/java/com/bytesw/bytebot/model/enums/LanguageEnum.java
+0
-34
StatusEnum.java
src/main/java/com/bytesw/bytebot/model/enums/StatusEnum.java
+43
-0
AgentRepository.java
...n/java/com/bytesw/bytebot/repository/AgentRepository.java
+19
-0
ChannelParamRepository.java
...com/bytesw/bytebot/repository/ChannelParamRepository.java
+19
-0
ChannelRepository.java
...java/com/bytesw/bytebot/repository/ChannelRepository.java
+18
-0
CountryRepository.java
...java/com/bytesw/bytebot/repository/CountryRepository.java
+18
-0
DeploymentChannelParamValueRepository.java
...bot/repository/DeploymentChannelParamValueRepository.java
+18
-0
DeploymentChannelRepository.java
...ytesw/bytebot/repository/DeploymentChannelRepository.java
+18
-0
AgentService.java
src/main/java/com/bytesw/bytebot/service/AgentService.java
+325
-0
CustomPaginationService.java
...a/com/bytesw/bytebot/service/CustomPaginationService.java
+45
-0
No files found.
src/main/java/com/bytesw/bytebot/bean/AgentBean.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
bean
;
import
com.bytesw.bytebot.model.Agent
;
import
com.google.gson.annotations.Expose
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
java.util.List
;
/**
* @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
@Setter
@ToString
public
class
AgentBean
{
@Expose
private
Long
id
;
@Expose
private
String
name
;
@Expose
private
String
description
;
@Expose
private
String
version
;
@Expose
private
String
status
;
@Expose
private
Long
countryId
;
@Expose
private
String
countryName
;
@Expose
private
String
timezone
;
@Expose
private
String
avatar
;
@Expose
private
String
language
;
@Expose
private
String
type
;
@Expose
private
List
<
DeploymentChannelBean
>
deploymentChannels
;
public
static
AgentBean
miniClone
(
Agent
agent
)
{
AgentBean
bean
=
new
AgentBean
();
bean
.
setId
(
agent
.
getId
());
bean
.
setName
(
agent
.
getName
());
bean
.
setVersion
(
agent
.
getVersion
());
bean
.
setStatus
(
agent
.
getStatus
().
getName
());
bean
.
setTimezone
(
agent
.
getTimezone
());
//bean.setAvatar(agent.getAvatar());
if
(
agent
.
getCountry
()
!=
null
)
{
bean
.
setCountryName
(
agent
.
getCountry
().
getName
());
}
return
bean
;
}
}
src/main/java/com/bytesw/bytebot/bean/DeploymentChannelBean.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
bean
;
import
com.google.gson.annotations.Expose
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
java.util.List
;
/**
* @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
@Setter
@ToString
public
class
DeploymentChannelBean
{
@Expose
private
Long
id
;
@Expose
private
String
name
;
@Expose
private
String
status
;
@Expose
private
Long
channelId
;
@Expose
private
String
channelName
;
@Expose
private
List
<
DeploymentChannelParamValueBean
>
parameters
;
}
src/main/java/com/bytesw/bytebot/bean/DeploymentChannelParamValueBean.java
0 → 100644
View file @
00cbc136
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
*
* 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
@Setter
@ToString
public
class
DeploymentChannelParamValueBean
{
@Expose
private
Long
id
;
@Expose
private
Long
channelParamId
;
@Expose
private
String
value
;
}
src/main/java/com/bytesw/bytebot/config/JPAConfig.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
config
;
import
com.bytesw.xdf.multitenant.config.ByteDataSourceProperties
;
import
com.zaxxer.hikari.HikariDataSource
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScans
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.jpa.repository.config.EnableJpaRepositories
;
import
org.springframework.orm.jpa.JpaTransactionManager
;
import
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
;
import
org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
javax.persistence.EntityManagerFactory
;
import
javax.persistence.PersistenceContext
;
import
javax.sql.DataSource
;
import
java.util.Properties
;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories
(
basePackages
=
{
"com.bytesw.xdf.dao"
,
"com.bytesw.xdf.coreweb.repository"
,
"com.bytesw.bytebot.repository"
},
entityManagerFactoryRef
=
"bytebotEntityManagerFactory"
,
transactionManagerRef
=
"bytebotTransactionManager"
)
@ComponentScans
(
value
=
{
@ComponentScan
(
"com.bytesw.bytebot.service"
)
})
public
class
JPAConfig
{
@Value
(
"${spring.datasource.schemaName}"
)
private
String
schema
;
@Bean
(
"bytebotDataSource"
)
public
HikariDataSource
dataSource
(
@Qualifier
(
"dataSourceProperties"
)
ByteDataSourceProperties
dataSourceProperties
)
{
HikariDataSource
datasource
=
(
HikariDataSource
)
dataSourceProperties
.
initializeDataSourceBuilder
().
type
(
HikariDataSource
.
class
).
build
();
datasource
.
setRegisterMbeans
(
true
);
return
datasource
;
}
@PersistenceContext
(
unitName
=
"bytebotPU"
)
@Bean
(
name
=
"bytebotEntityManagerFactory"
)
public
LocalContainerEntityManagerFactoryBean
entityManagerFactory
(
@Qualifier
(
"bytebotDataSource"
)
DataSource
dataSource
)
{
LocalContainerEntityManagerFactoryBean
em
=
new
LocalContainerEntityManagerFactoryBean
();
em
.
setPersistenceUnitName
(
"bytebotPU"
);
em
.
setDataSource
(
dataSource
);
em
.
setPackagesToScan
(
new
String
[]{
"com.bytesw.xdf.model"
,
"com.bytesw.bytebot.model"
});
em
.
setJpaVendorAdapter
(
new
HibernateJpaVendorAdapter
());
em
.
setJpaProperties
(
additionalProperties
());
return
em
;
}
@Bean
(
name
=
"bytebotTransactionManager"
)
public
PlatformTransactionManager
transactionManager
(
@Qualifier
(
"bytebotEntityManagerFactory"
)
EntityManagerFactory
emf
)
{
final
JpaTransactionManager
transactionManager
=
new
JpaTransactionManager
();
transactionManager
.
setEntityManagerFactory
(
emf
);
return
transactionManager
;
}
private
Properties
additionalProperties
()
{
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"hibernate.default_schema"
,
schema
);
properties
.
setProperty
(
"hibernate.enable_lazy_load_no_trans"
,
"true"
);
return
properties
;
}
}
src/main/java/com/bytesw/bytebot/controller/AgentController.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
controller
;
import
com.bytesw.bytebot.bean.AgentBean
;
import
com.bytesw.bytebot.controller.bean.ResponseController
;
import
com.bytesw.bytebot.service.AgentService
;
import
com.bytesw.xdf.annotation.ProgramSecurity
;
import
com.bytesw.xdf.sql.beans.Pagination
;
import
com.google.gson.GsonBuilder
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiResponse
;
import
io.swagger.annotations.ApiResponses
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.commons.lang.exception.ExceptionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
@Log4j2
@RestController
@RequestMapping
(
"/service/agent"
)
@ProgramSecurity
(
"conversational_agent"
)
public
class
AgentController
{
@Autowired
private
AgentService
agentService
;
@Autowired
private
GsonBuilder
gsonBuilder
;
@PostMapping
(
value
=
"/page"
)
@PreAuthorize
(
"hasPermission(this, 'view')"
)
public
ResponseEntity
<
String
>
paginationCommercialEquivalence
(
@RequestBody
Pagination
<
AgentBean
>
pagination
)
{
HttpStatus
hs
=
HttpStatus
.
OK
;
try
{
agentService
.
searchByPagination
(
pagination
);
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
pagination
),
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
=
"/{id}"
)
@PreAuthorize
(
"hasPermission(this, 'view')"
)
public
ResponseEntity
<
String
>
getExternalSystemServiceById
(
@ApiParam
(
value
=
"id"
,
required
=
true
)
@PathVariable
(
"id"
)
Long
id
)
{
HttpStatus
hs
=
HttpStatus
.
OK
;
try
{
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
agentService
.
getAgent
(
id
)),
hs
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error detectado: "
,
e
);
hs
=
HttpStatus
.
INTERNAL_SERVER_ERROR
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
ExceptionUtils
.
getFullStackTrace
(
e
)),
hs
);
}
}
@PostMapping
(
value
=
"/"
)
@PreAuthorize
(
"hasPermission(this, 'new')"
)
public
ResponseEntity
<
String
>
createExternalSystem
(
@RequestBody
AgentBean
agentBean
)
{
HttpStatus
hs
=
HttpStatus
.
OK
;
try
{
agentService
.
save
(
agentBean
);
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
new
ResponseController
(
"agent.insert.success"
,
hs
.
value
())),
hs
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error detectado: "
,
e
);
hs
=
HttpStatus
.
INTERNAL_SERVER_ERROR
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
ExceptionUtils
.
getFullStackTrace
(
e
)),
hs
);
}
}
@PostMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"hasPermission(this, 'edit')"
)
public
ResponseEntity
<
String
>
updateExternalSystem
(
@PathVariable
(
"id"
)
Long
id
,
@RequestBody
AgentBean
agentBean
)
{
HttpStatus
hs
=
HttpStatus
.
OK
;
try
{
if
(
id
!=
null
)
{
agentService
.
save
(
agentBean
);
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
new
ResponseController
(
"agent.update.success"
,
hs
.
value
())),
hs
);
}
else
{
hs
=
HttpStatus
.
UNAUTHORIZED
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
new
ResponseController
(
"agent.update.error"
,
hs
.
value
())),
hs
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Error detectado: "
,
e
);
hs
=
HttpStatus
.
INTERNAL_SERVER_ERROR
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
ExceptionUtils
.
getFullStackTrace
(
e
)),
hs
);
}
}
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"hasPermission(this, 'delete')"
)
public
ResponseEntity
<
String
>
deleteExternalSystem
(
@ApiParam
(
value
=
"id"
,
required
=
true
)
@PathVariable
(
"id"
)
Long
id
)
{
HttpStatus
hs
=
HttpStatus
.
OK
;
try
{
if
(
id
!=
null
)
{
boolean
deleteValid
=
agentService
.
delete
(
id
);
if
(
deleteValid
)
{
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
new
ResponseController
(
"agent.delete.success"
,
hs
.
value
())),
hs
);
}
else
{
// hs = HttpStatus.FAILED_DEPENDENCY;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
new
ResponseController
(
"agent.delete.error.integrity"
,
hs
.
FAILED_DEPENDENCY
.
value
())),
hs
);
}
}
else
{
hs
=
HttpStatus
.
UNAUTHORIZED
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
new
ResponseController
(
"agent.delete.error.unauthtorized"
,
hs
.
value
())),
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/controller/bean/ResponseController.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
controller
.
bean
;
import
com.google.gson.annotations.Expose
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
java.io.Serializable
;
/**
* @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
@Setter
@ToString
public
class
ResponseController
implements
Serializable
{
@Expose
private
String
message
;
@Expose
private
int
statusCode
;
@Expose
private
Object
additionalData
;
public
ResponseController
()
{
}
public
ResponseController
(
String
message
,
int
statusCode
)
{
this
.
message
=
message
;
this
.
statusCode
=
statusCode
;
}
public
ResponseController
(
String
message
,
int
statusCode
,
Object
additionalData
)
{
this
.
message
=
message
;
this
.
statusCode
=
statusCode
;
this
.
additionalData
=
additionalData
;
}
}
src/main/java/com/bytesw/bytebot/model/Agent.java
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
model
;
import
com.bytesw.bytebot.model.converters.AgentStatusConverter
;
import
com.bytesw.bytebot.model.converters.AgentTypeConverter
;
import
com.bytesw.bytebot.model.
enums.AgentStatusEnum
;
import
com.bytesw.bytebot.model.
converters.StatusConverter
;
import
com.bytesw.bytebot.model.enums.AgentTypeEnum
;
import
com.bytesw.bytebot.model.enums.
Language
Enum
;
import
com.bytesw.bytebot.model.enums.
Status
Enum
;
import
lombok.*
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.List
;
@Entity
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
"id"
)
...
...
@@ -24,30 +24,40 @@ public class Agent implements Serializable {
@Column
(
name
=
"AGEN_ID"
)
private
Long
id
;
@Column
(
name
=
"AGEN_IDEN"
,
nullable
=
false
)
private
String
identifier
;
@Column
(
name
=
"AGEN_IDEN"
)
private
String
name
;
@Column
(
name
=
"AGEN_DESCR"
,
nullable
=
false
)
@Column
(
name
=
"AGEN_DESCR"
)
private
String
description
;
@Column
(
name
=
"AGEN_VERS"
,
nullable
=
false
)
@Column
(
name
=
"AGEN_VERS"
)
private
String
version
;
@Column
(
name
=
"AGEN_LANG"
,
nullable
=
false
)
@Convert
(
converter
=
AgentTypeConverter
.
class
)
private
LanguageEnum
language
;
@Column
(
name
=
"AGEN_LANG"
)
private
String
language
;
@Column
(
name
=
"AGEN_TZONE"
)
private
String
timezone
;
@Column
(
name
=
"AGEN_TZONE"
,
nullable
=
false
)
private
String
timeZone
;
@Lob
@Basic
(
fetch
=
FetchType
.
LAZY
)
@Column
(
name
=
"AGEN_AVAT"
)
private
String
avatar
;
@Column
(
name
=
"AGEN_TZONE"
,
nullable
=
false
)
@ManyToOne
@JoinColumn
(
name
=
"COUN_ID"
,
referencedColumnName
=
"COUN_ID"
)
private
Country
country
;
@Column
(
name
=
"AGEN_STATE"
,
nullable
=
false
)
@Convert
(
converter
=
Agent
StatusConverter
.
class
)
private
AgentStatusEnum
state
;
@Column
(
name
=
"AGEN_STATE"
)
@Convert
(
converter
=
StatusConverter
.
class
)
private
StatusEnum
status
;
@Column
(
name
=
"AGEN_TYPE"
,
nullable
=
false
)
@Column
(
name
=
"AGEN_TYPE"
)
@Convert
(
converter
=
AgentTypeConverter
.
class
)
private
AgentTypeEnum
type
;
@OneToMany
(
mappedBy
=
"agent"
)
private
List
<
DeploymentChannel
>
deploymentChannels
;
@OneToMany
(
mappedBy
=
"agent"
)
private
List
<
FrequentQuestion
>
frequentQuestions
;
}
src/main/java/com/bytesw/bytebot/model/Channel.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
model
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
javax.persistence.*
;
import
java.util.List
;
/**
* @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.
*/
@Entity
@Table
(
name
=
"BBOT_CHANNEL"
)
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
{
"id"
},
callSuper
=
false
)
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"
)
private
Long
id
;
@Column
(
name
=
"CHAN_IDEN"
)
private
String
name
;
@OneToMany
(
mappedBy
=
"channel"
)
private
List
<
ChannelParam
>
parameters
;
}
src/main/java/com/bytesw/bytebot/model/ChannelParam.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
model
;
import
com.bytesw.bytebot.model.converters.BooleanToStringConverter
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
javax.persistence.*
;
/**
* @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.
*/
@Entity
@Table
(
name
=
"BBOT_CHANNEL_PARAM"
)
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
{
"id"
},
callSuper
=
false
)
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"
)
private
Long
id
;
@Column
(
name
=
"CHPA_IDEN"
)
private
String
name
;
@ManyToOne
@JoinColumn
(
name
=
"CHAN_ID"
,
referencedColumnName
=
"CHAN_ID"
)
private
Channel
channel
;
@Column
(
name
=
"CHPA_ORDER"
)
private
Integer
order
;
@Column
(
name
=
"CHPA_REQU"
)
@Convert
(
converter
=
BooleanToStringConverter
.
class
)
private
boolean
required
;
@Column
(
name
=
"CHPA_LABEL"
)
private
String
label
;
@Column
(
name
=
"CHPA_TRADU"
)
private
String
traductions
;
@Column
(
name
=
"CHPA_MAXLE"
)
private
Integer
maxlength
;
}
src/main/java/com/bytesw/bytebot/model/Country.java
View file @
00cbc136
...
...
@@ -18,6 +18,6 @@ public class Country {
@Column
(
name
=
"COUN_ID"
)
private
Long
id
;
@Column
(
name
=
"COUN_
IDEN
"
,
nullable
=
false
)
private
String
identifier
;
@Column
(
name
=
"COUN_
NAME
"
,
nullable
=
false
)
private
String
name
;
}
src/main/java/com/bytesw/bytebot/model/DeploymentChannel.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
model
;
import
com.bytesw.bytebot.model.converters.StatusConverter
;
import
com.bytesw.bytebot.model.enums.StatusEnum
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
javax.persistence.*
;
import
java.util.List
;
/**
* @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.
*/
@Entity
@Table
(
name
=
"BBOT_DEPLOYMENT_CHANNEL"
)
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
{
"id"
},
callSuper
=
false
)
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"
)
private
Long
id
;
@Column
(
name
=
"DCHA_NAME"
)
private
String
name
;
@ManyToOne
@JoinColumn
(
name
=
"AGEN_ID"
,
referencedColumnName
=
"AGEN_ID"
)
private
Agent
agent
;
@Column
(
name
=
"DCHA_STATE"
)
@Convert
(
converter
=
StatusConverter
.
class
)
private
StatusEnum
status
;
@ManyToOne
@JoinColumn
(
name
=
"CHAN_ID"
,
referencedColumnName
=
"CHAN_ID"
)
private
Channel
channel
;
@OneToMany
(
mappedBy
=
"deploymentChannel"
)
private
List
<
DeploymentChannelParamValue
>
parameters
;
}
src/main/java/com/bytesw/bytebot/model/DeploymentChannelParamValue.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
model
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
javax.persistence.*
;
/**
* @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.
*/
@Entity
@Table
(
name
=
"BBOT_CHANNEL_PARAM_VALUE"
)
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
{
"id"
},
callSuper
=
false
)
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"
)
private
Long
id
;
@ManyToOne
@JoinColumn
(
name
=
"CHPA_ID"
,
referencedColumnName
=
"CHPA_ID"
)
private
ChannelParam
parameter
;
@ManyToOne
@JoinColumn
(
name
=
"DCHA_ID"
,
referencedColumnName
=
"DCHA_ID"
)
private
DeploymentChannel
deploymentChannel
;
@Column
(
name
=
"CHPA_VALUE"
)
private
String
value
;
}
src/main/java/com/bytesw/bytebot/model/FrequentQuestion.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
model
;
import
com.bytesw.bytebot.model.converters.StatusConverter
;
import
com.bytesw.bytebot.model.enums.StatusEnum
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
javax.persistence.*
;
import
java.time.LocalDateTime
;
import
java.time.OffsetDateTime
;
/**
* @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.
*/
@Entity
@Table
(
name
=
"BBOT_FREQUENT_QUESTION"
)
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
of
=
{
"id"
},
callSuper
=
false
)
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"
)
private
Long
id
;
@Column
(
name
=
"FQUE_PATH"
)
private
String
filePath
;
@Column
(
name
=
"FQUE_NAME"
)
private
String
filename
;
@Column
(
name
=
"FQUE_DESC"
)
private
String
description
;
@Column
(
name
=
"FQUE_STATE"
)
@Convert
(
converter
=
StatusConverter
.
class
)
private
StatusEnum
status
;
@ManyToOne
@JoinColumn
(
name
=
"AGEN_ID"
,
referencedColumnName
=
"AGEN_ID"
)
private
Agent
agent
;
@Column
(
name
=
"FQUE_USER"
)
private
String
user
;
@Column
(
name
=
"FQUE_LDATE"
,
columnDefinition
=
"TIMESTAMP"
)
private
LocalDateTime
uploadDate
;
}
src/main/java/com/bytesw/bytebot/model/converters/AgentStatusConverter.java
deleted
100644 → 0
View file @
85a82694
package
com
.
bytesw
.
bytebot
.
model
.
converters
;
import
com.bytesw.bytebot.model.enums.AgentStatusEnum
;
import
org.apache.camel.Converter
;
import
javax.persistence.AttributeConverter
;
@Converter
public
class
AgentStatusConverter
implements
AttributeConverter
<
AgentStatusEnum
,
String
>
{
@Override
public
String
convertToDatabaseColumn
(
AgentStatusEnum
agentStatusEnum
)
{
if
(
agentStatusEnum
==
null
)
return
null
;
return
agentStatusEnum
.
getName
();
}
@Override
public
AgentStatusEnum
convertToEntityAttribute
(
String
s
)
{
return
AgentStatusEnum
.
fromString
(
s
);
}
}
src/main/java/com/bytesw/bytebot/model/converters/BooleanToStringConverter.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
model
.
converters
;
import
javax.persistence.AttributeConverter
;
import
javax.persistence.Converter
;
/**
* @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
BooleanToStringConverter
implements
AttributeConverter
<
Boolean
,
String
>
{
public
BooleanToStringConverter
()
{
}
public
String
convertToDatabaseColumn
(
Boolean
value
)
{
return
value
!=
null
&&
value
?
"Y"
:
"N"
;
}
public
Boolean
convertToEntityAttribute
(
String
value
)
{
return
"Y"
.
equals
(
value
);
}
}
src/main/java/com/bytesw/bytebot/model/converters/StatusConverter.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
model
.
converters
;
import
com.bytesw.bytebot.model.enums.StatusEnum
;
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
StatusConverter
implements
AttributeConverter
<
StatusEnum
,
String
>
{
@Override
public
String
convertToDatabaseColumn
(
StatusEnum
value
)
{
return
value
.
getName
();
}
@Override
public
StatusEnum
convertToEntityAttribute
(
String
value
)
{
return
StatusEnum
.
fromString
(
value
);
}
}
\ No newline at end of file
src/main/java/com/bytesw/bytebot/model/enums/AgentStatusEnum.java
deleted
100644 → 0
View file @
85a82694
package
com
.
bytesw
.
bytebot
.
model
.
enums
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.NoSuchElementException
;
public
enum
AgentStatusEnum
{
CREATE
(
"C"
),
DEPLOYMENT
(
"I"
);
private
final
String
name
;
private
static
final
Map
<
String
,
AgentStatusEnum
>
map
=
new
HashMap
<>();
static
{
for
(
AgentStatusEnum
type
:
AgentStatusEnum
.
values
())
{
map
.
put
(
type
.
name
,
type
);
}
}
AgentStatusEnum
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
()
{
return
name
;
}
public
static
AgentStatusEnum
fromString
(
String
name
)
{
if
(
map
.
containsKey
(
name
))
{
return
map
.
get
(
name
);
}
throw
new
NoSuchElementException
(
name
+
" not found"
);
}
}
src/main/java/com/bytesw/bytebot/model/enums/LanguageEnum.java
deleted
100644 → 0
View file @
85a82694
package
com
.
bytesw
.
bytebot
.
model
.
enums
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.NoSuchElementException
;
public
enum
LanguageEnum
{
SPANISH
(
"S"
);
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/model/enums/StatusEnum.java
0 → 100644
View file @
00cbc136
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
StatusEnum
{
ACTIVE
(
"AC"
),
INACTIVE
(
"IN"
),
DELETED
(
"DE"
);
private
static
final
Map
<
String
,
StatusEnum
>
map
=
new
HashMap
<>();
private
String
name
;
StatusEnum
(
String
name
)
{
this
.
name
=
name
;
}
static
{
for
(
StatusEnum
type
:
StatusEnum
.
values
())
{
map
.
put
(
type
.
name
,
type
);
}
}
public
static
StatusEnum
fromString
(
String
name
)
{
return
map
.
get
(
name
);
}
}
src/main/java/com/bytesw/bytebot/repository/AgentRepository.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
repository
;
import
com.bytesw.bytebot.model.Agent
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
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
AgentRepository
extends
CrudRepository
<
Agent
,
Long
>,
JpaSpecificationExecutor
<
Agent
>
{
}
src/main/java/com/bytesw/bytebot/repository/ChannelParamRepository.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
repository
;
import
com.bytesw.bytebot.model.Channel
;
import
com.bytesw.bytebot.model.ChannelParam
;
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
ChannelParamRepository
extends
CrudRepository
<
ChannelParam
,
Long
>
{
}
src/main/java/com/bytesw/bytebot/repository/ChannelRepository.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
repository
;
import
com.bytesw.bytebot.model.Channel
;
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
ChannelRepository
extends
CrudRepository
<
Channel
,
Long
>
{
}
src/main/java/com/bytesw/bytebot/repository/CountryRepository.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
repository
;
import
com.bytesw.bytebot.model.Country
;
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
CountryRepository
extends
CrudRepository
<
Country
,
Long
>
{
}
src/main/java/com/bytesw/bytebot/repository/DeploymentChannelParamValueRepository.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
repository
;
import
com.bytesw.bytebot.model.DeploymentChannelParamValue
;
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
DeploymentChannelParamValueRepository
extends
CrudRepository
<
DeploymentChannelParamValue
,
Long
>
{
}
src/main/java/com/bytesw/bytebot/repository/DeploymentChannelRepository.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
repository
;
import
com.bytesw.bytebot.model.DeploymentChannel
;
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
DeploymentChannelRepository
extends
CrudRepository
<
DeploymentChannel
,
Long
>
{
}
src/main/java/com/bytesw/bytebot/service/AgentService.java
0 → 100644
View file @
00cbc136
This diff is collapsed.
Click to expand it.
src/main/java/com/bytesw/bytebot/service/CustomPaginationService.java
0 → 100644
View file @
00cbc136
package
com
.
bytesw
.
bytebot
.
service
;
import
com.bytesw.xdf.dao.rsql.CustomRsqlVisitor
;
import
com.bytesw.xdf.sql.beans.Pagination
;
import
com.bytesw.xdf.sql.beans.SortField
;
import
cz.jirutka.rsql.parser.RSQLParser
;
import
cz.jirutka.rsql.parser.ast.Node
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.jpa.domain.Specification
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author Sebastián Chicoma Sandmann
* @version 9-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.
*
*/
public
abstract
class
CustomPaginationService
<
T
>
{
public
Specification
<
T
>
createSpecification
(
final
String
filterExpression
)
{
Node
rootNode
=
new
RSQLParser
().
parse
(
filterExpression
);
return
rootNode
.
accept
(
new
CustomRsqlVisitor
<>());
}
public
Sort
createSort
(
Pagination
pagination
)
{
List
<
Sort
.
Order
>
orderList
=
new
ArrayList
<>();
for
(
SortField
sortField
:
pagination
.
getSortFields
())
{
if
(
"asc"
.
equalsIgnoreCase
(
sortField
.
getDirection
()))
{
orderList
.
add
(
Sort
.
Order
.
asc
(
sortField
.
getField
()));
}
else
{
orderList
.
add
(
Sort
.
Order
.
desc
(
sortField
.
getField
()));
}
}
return
Sort
.
by
(
orderList
);
}
}
\ No newline at end of file
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