Commit 8ab9c3c7 authored by huriarte's avatar huriarte

Multitenant

parent 3ef875e5
...@@ -7,6 +7,7 @@ import com.bytesw.bytebot.http.FileValidationResponse; ...@@ -7,6 +7,7 @@ import com.bytesw.bytebot.http.FileValidationResponse;
import com.bytesw.bytebot.service.AgentService; import com.bytesw.bytebot.service.AgentService;
import com.bytesw.bytebot.service.FileManagementService; import com.bytesw.bytebot.service.FileManagementService;
import com.bytesw.xdf.annotation.ProgramSecurity; import com.bytesw.xdf.annotation.ProgramSecurity;
import com.bytesw.xdf.multitenant.core.ThreadLocalStorage;
import com.bytesw.xdf.sql.beans.Pagination; import com.bytesw.xdf.sql.beans.Pagination;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
...@@ -40,7 +41,7 @@ public class AgentController { ...@@ -40,7 +41,7 @@ public class AgentController {
@PostMapping(value = "/page") @PostMapping(value = "/page")
@PreAuthorize("hasPermission(this, 'view')") @PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> paginationCommercialEquivalence(@RequestBody Pagination<AgentBean> pagination) { public ResponseEntity<String> paginationConversationalAgent(@RequestBody Pagination<AgentBean> pagination) {
HttpStatus hs = HttpStatus.OK; HttpStatus hs = HttpStatus.OK;
try { try {
...@@ -56,7 +57,7 @@ public class AgentController { ...@@ -56,7 +57,7 @@ public class AgentController {
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@PreAuthorize("hasPermission(this, 'view')") @PreAuthorize("hasPermission(this, 'view')")
public ResponseEntity<String> getExternalSystemServiceById(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) { public ResponseEntity<String> getConversartionalAgentById(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) {
HttpStatus hs = HttpStatus.OK; HttpStatus hs = HttpStatus.OK;
try { try {
...@@ -71,7 +72,7 @@ public class AgentController { ...@@ -71,7 +72,7 @@ public class AgentController {
@PostMapping(value = "/") @PostMapping(value = "/")
@PreAuthorize("hasPermission(this, 'new')") @PreAuthorize("hasPermission(this, 'new')")
public ResponseEntity<String> createExternalSystem(@RequestBody AgentBean agentBean) { public ResponseEntity<String> createConversationalAgent(@RequestBody AgentBean agentBean) {
HttpStatus hs = HttpStatus.OK; HttpStatus hs = HttpStatus.OK;
...@@ -88,7 +89,7 @@ public class AgentController { ...@@ -88,7 +89,7 @@ public class AgentController {
@PostMapping(value = "/{id}") @PostMapping(value = "/{id}")
@PreAuthorize("hasPermission(this, 'edit')") @PreAuthorize("hasPermission(this, 'edit')")
public ResponseEntity<String> updateExternalSystem(@PathVariable("id") Long id, public ResponseEntity<String> updateConversationalAgent(@PathVariable("id") Long id,
@RequestBody AgentBean agentBean) { @RequestBody AgentBean agentBean) {
HttpStatus hs = HttpStatus.OK; HttpStatus hs = HttpStatus.OK;
...@@ -110,7 +111,7 @@ public class AgentController { ...@@ -110,7 +111,7 @@ public class AgentController {
@DeleteMapping(value = "/{id}") @DeleteMapping(value = "/{id}")
@PreAuthorize("hasPermission(this, 'delete')") @PreAuthorize("hasPermission(this, 'delete')")
public ResponseEntity<String> deleteExternalSystem(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) { public ResponseEntity<String> deleteConversationalAgent(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) {
HttpStatus hs = HttpStatus.OK; HttpStatus hs = HttpStatus.OK;
try { try {
......
...@@ -25,6 +25,7 @@ import java.time.format.DateTimeFormatter; ...@@ -25,6 +25,7 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@Service @Service
@Transactional
@Log4j2 @Log4j2
public class AgentService extends CustomPaginationService<Agent> { public class AgentService extends CustomPaginationService<Agent> {
...@@ -54,8 +55,7 @@ public class AgentService extends CustomPaginationService<Agent> { ...@@ -54,8 +55,7 @@ public class AgentService extends CustomPaginationService<Agent> {
@Autowired @Autowired
private ProducerTemplate producerTemplate; private ProducerTemplate producerTemplate;
@Transactional(transactionManager = "bytebotTransactionManager", readOnly = true, propagation = Propagation.NOT_SUPPORTED)
public void searchByPagination(Pagination<AgentBean> pagination) { public void searchByPagination(Pagination<AgentBean> pagination) {
if (pagination.getItemsPerPage() == 0) { if (pagination.getItemsPerPage() == 0) {
pagination.setItemsPerPage(10); pagination.setItemsPerPage(10);
...@@ -95,7 +95,7 @@ public class AgentService extends CustomPaginationService<Agent> { ...@@ -95,7 +95,7 @@ public class AgentService extends CustomPaginationService<Agent> {
pagination.setData(list); pagination.setData(list);
} }
@Transactional(transactionManager = "bytebotTransactionManager", propagation = Propagation.REQUIRED) @Transactional(propagation = Propagation.REQUIRED)
public void save(AgentBean agent) { public void save(AgentBean agent) {
boolean isModify = true; boolean isModify = true;
...@@ -314,7 +314,6 @@ public class AgentService extends CustomPaginationService<Agent> { ...@@ -314,7 +314,6 @@ public class AgentService extends CustomPaginationService<Agent> {
} }
@Transactional(transactionManager = "bytebotTransactionManager", propagation = Propagation.NOT_SUPPORTED)
public AgentBean getAgent(Long id) { public AgentBean getAgent(Long id) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
...@@ -399,7 +398,7 @@ public class AgentService extends CustomPaginationService<Agent> { ...@@ -399,7 +398,7 @@ public class AgentService extends CustomPaginationService<Agent> {
return bean; return bean;
} }
@Transactional(transactionManager = "bytebotTransactionManager", propagation = Propagation.REQUIRED) @Transactional(propagation = Propagation.REQUIRED)
public boolean delete(Long id) { public boolean delete(Long id) {
boolean isValid = true; boolean isValid = true;
...@@ -416,8 +415,7 @@ public class AgentService extends CustomPaginationService<Agent> { ...@@ -416,8 +415,7 @@ public class AgentService extends CustomPaginationService<Agent> {
return isValid; return isValid;
} }
@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
public List<CountryBean> getCountries() { public List<CountryBean> getCountries() {
List<CountryBean> countriesBean = new ArrayList<>(); List<CountryBean> countriesBean = new ArrayList<>();
List<Country> countries = (List<Country>) countryRepository.findAll(); List<Country> countries = (List<Country>) countryRepository.findAll();
...@@ -429,7 +427,6 @@ public class AgentService extends CustomPaginationService<Agent> { ...@@ -429,7 +427,6 @@ public class AgentService extends CustomPaginationService<Agent> {
return countriesBean; return countriesBean;
} }
@Transactional(transactionManager = "bytebotTransactionManager", propagation = Propagation.NOT_SUPPORTED, readOnly = true)
public List<ChannelBean> getChannels() { public List<ChannelBean> getChannels() {
List<ChannelBean> channelsBean = new ArrayList<>(); List<ChannelBean> channelsBean = new ArrayList<>();
List<Channel> channels = (List<Channel>) channelRepository.findAll(); List<Channel> channels = (List<Channel>) channelRepository.findAll();
...@@ -441,7 +438,7 @@ public class AgentService extends CustomPaginationService<Agent> { ...@@ -441,7 +438,7 @@ public class AgentService extends CustomPaginationService<Agent> {
return channelsBean; return channelsBean;
} }
@Transactional(transactionManager = "bytebotTransactionManager", propagation = Propagation.REQUIRED) @Transactional(propagation = Propagation.REQUIRED)
public void synchronizeFiles(Long id, String user) { public void synchronizeFiles(Long id, String user) {
List<FrequentQuestion> frequentQuestions = frequentQuestionRepository.findAllByAgentIdAndStatus(id, FrequentQuestionStatusEnum.PENDING_SYNCHRONIZED); List<FrequentQuestion> frequentQuestions = frequentQuestionRepository.findAllByAgentIdAndStatus(id, FrequentQuestionStatusEnum.PENDING_SYNCHRONIZED);
......
...@@ -38,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -38,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@Service @Service
@Transactional
@Log4j2 @Log4j2
public class FileManagementService { public class FileManagementService {
...@@ -47,7 +48,7 @@ public class FileManagementService { ...@@ -47,7 +48,7 @@ public class FileManagementService {
@Autowired @Autowired
private QuestionFileRepository questionFileRepository; private QuestionFileRepository questionFileRepository;
@Transactional(transactionManager = "bytebotTransactionManager", propagation = Propagation.REQUIRED) @Transactional(propagation = Propagation.REQUIRED)
public FileValidationResponse validateAndSaveFile(String uuid, MultipartFile file) throws IOException { public FileValidationResponse validateAndSaveFile(String uuid, MultipartFile file) throws IOException {
FileValidationResponse response = new FileValidationResponse(); FileValidationResponse response = new FileValidationResponse();
......
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<context:annotation-config /> <context:annotation-config />
<jpa:repositories base-package="com.bytesw" transaction-manager-ref="transactionManager" entity-manager-factory-ref="entityManagerFactory"/>
<jpa:repositories base-package="com.bytesw.xdf.dao" />
<jpa:repositories base-package="com.bytesw.xdf.security.dao" />
<jpa:repositories base-package="com.bytesw.bytebot.dao" />
<!-- <jpa:repositories base-package="com.bytesw.xdf.license.dao" />-->
<!-- <jpa:repositories base-package="com.bytesw.xdf.statistics.dao" />-->
<!--<context:component-scan base-package="com.bytesw.coreweb.seguridad.dao.jdbc" />-->
</beans> </beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment