Commit initial

parents
Pipeline #4235 failed with stages
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
This diff is collapsed.
# Auto detect text files and perform LF normalization
* text=auto
/target/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>macro-ofertador</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=target\\generated-sources\\annotations
org.eclipse.jdt.apt.genTestSrcDir=target\\generated-test-sources\\test-annotations
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=17
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
boot.validation.initialized=true
eclipse.preferences.version=1
pipeline {
agent any
stages {
stage('Parando Docker') {
steps {
dir("/opt/camunda/macro-ofertador/docker") {
sh 'docker-compose -p macro-ofertador -f docker-compose.yml down'
}
}
}
stage('Unit Tests') {
steps {
sh 'mvn clean install test'
sh 'mvn package spring-boot:repackage -DskipTests'
}
}
stage('SonarQube analysis') {
steps {
withSonarQubeEnv('SonarQube') {
sh 'mvn verify sonar:sonar -Pcoverage -Dsonar.java.coveragePlugin=jacoco -Dsonar.projectKey=macro-ofertador -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml -Dsonar.host.url=http://192.168.0.49:9000 -Dsonar.login=admin -Dsonar.password=camunda'
}
}
}
stage('Copiando Arquivos') {
steps {
sh 'cp -Rf /var/lib/jenkins/workspace/macro-ofertador/* /opt/camunda/macro-ofertador/'
sh 'rm -Rf /var/lib/jenkins/workspace/macro-ofertador/*'
sh 'docker image rm -f macro-ofertador_macro-ofertador'
}
}
stage('Iniciando Docker') {
steps {
dir("/opt/camunda/macro-ofertador/docker") {
sh 'docker-compose -p macro-ofertador -f docker-compose.yml up -d'
}
}
}
}
}
\ No newline at end of file
# macro-ofertador
Archivo que describe los pasos para el manejo del proyecto Ofertador (desacople Macro)
Tecnologías Utilizadas
- [JDK 17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
- [Maven 3.8.6](https://maven.apache.org)
- Springboot 2.6.4
## Run docker compose up inside docker folder to start camunda postgres database
## Compilación
```shell
mvn -DskipTests=true clean compile
```
## Construcción
```shell
mvn -DskipTests=true clean package
```
## Ejecución ambiente desarrollo
```shell
mvn spring-boot:run -D spring-boot.run.profiles=dev
```
## Unit Test
Los test unitarios se corren cuando se genera la compilación o la construcción, sin embargo se han deshabilitado hasta contar con credenciales
de acceso a BD
```shell
mvn clean test
```
se pueden volver a correr los tests
## Swagger
http://localhost:8080/swagger-ui.html
## Architecture
![](doc/Macro-layers.drawio.png)
## Running the application locally
```shell
mvn spring-boot:run
```
\ No newline at end of file
FROM openjdk:17-alpine AS run
ARG JAR_FILE=*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
FROM openjdk:17-alpine AS run
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
version: '3.5'
services:
macro-ofertador:
container_name: macro-ofertador
# Configuration for building the docker image for the backend service
build:
context: /opt/camunda/macro-ofertador # Use an image built from the specified dockerfile
dockerfile: /opt/camunda/macro-ofertador/docker/DockerFileNT
ports:
- "8282:8080" # Forward the exposed port 8080 on the container to port 8080 on the host machine
restart: unless-stopped
environment: # Pass environment variables to the service
SPRING_DATASOURCE_URL: jdbc:postgresql://192.168.0.49:5433/macro_ofertador
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: sa
\ No newline at end of file
This diff is collapsed.
environment:
env.AWS_EKS= "07F8F1BE644834F5DFECAD98EA5A9251.gr7.us-east-1.eks.amazonaws.com"
env.ECR_REGISTRY= "294532563337.dkr.ecr.us-east-1.amazonaws.com"
ECR_REPOSITORY= "macro-ofertador"
env.CLUSTER_NAME= "cam-dev"
env.ENV_NAME= "DEV"
env.PATH_DEPLOY= "dev"
SERVICE_CREDS= ('JEN-AWS-EKS-CAM-DEV')
\ No newline at end of file
environment:
env.AWS_EKS= "7380D475D8F242320E94B7042CEC1ED5.gr7.us-east-1.eks.amazonaws.com"
env.ECR_REGISTRY= "171220174642.dkr.ecr.us-east-1.amazonaws.com"
env.ECR_REPOSITORY= "macro-ofertador"
env.CLUSTER_NAME= "cam-test"
env.ENV_NAME= "TEST"
env.PATH_DEPLOY= "test"
SERVICE_CREDS= ('JEN-AWS-EKS-CAM-TEST')
\ No newline at end of file
apiVersion: v1
kind: ConfigMap
metadata:
name: macro-ofertador-configmap
namespace: camunda-ns
data:
SPRING_PROFILES_ACTIVE: dev
CONN_SHOWSQL: "true"
PORT: "8080"
URL: "https://esbtest.macro.com.ar"
NAME: "esb-client"
NAME_TOKEN: "esb-client-token"
\ No newline at end of file
apiVersion: apps/v1
kind: Deployment
metadata:
name: macro-ofertador
namespace: camunda-ns
spec:
replicas: 1
selector:
matchLabels:
app: macro-ofertador
template:
metadata:
labels:
app: macro-ofertador
spec:
containers:
- name: macro-ofertador
image: 294532563337.dkr.ecr.us-east-1.amazonaws.com/macro-ofertador/macro-ofertador:latest
imagePullPolicy: Always
envFrom:
- configMapRef:
name: macro-ofertador-configmap
resources:
limits:
memory: "600Mi"
cpu: "500m"
ports:
- containerPort: 8080
\ No newline at end of file
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: macro-bpm-ingress
namespace: camunda-ns
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internal
alb.ingress.kubernetes.io/backend-protocol: HTTP
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80},{"HTTPS": 443}]'
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-east-1:294532563337:certificate/272763b9-b73e-488f-9ca8-203e4e85e5bd
alb.ingress.kubernetes.io/target-type: instance
alb.ingress.kubernetes.io/healthcheck-protocol: HTTPS
alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
alb.ingress.kubernetes.io/ssl-redirect: '443'
labels:
app: macro-ofertador
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: macro-ofertador
port:
number: 8080
\ No newline at end of file
apiVersion: v1
kind: Secret
metadata:
annotations: {}
name: macro-ofertador-secret
namespace: camunda-ns
stringData:
CONN_DBNAME: macro-ofertador
CONN_HOST: localhost
CONN_PORT: '5432'
CONN_PWD: sa
CONN_USR: postgres
data:
CONN_DBNAME: <ADICIONAR EM BASE64>
CONN_HOST: <ADICIONAR EM BASE64>
CONN_PORT: <ADICIONAR EM BASE64>
CONN_PWD: <ADICIONAR EM BASE64>
CONN_USR: <ADICIONAR EM BASE64>
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
labels:
app: macro-ofertador
name: macro-ofertador
namespace: camunda-ns
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: macro-ofertador
sessionAffinity: None
type: NodePort
\ No newline at end of file
apiVersion: v1
kind: ConfigMap
metadata:
name: macro-ofertador-configmap
namespace: camunda-ns
data:
SPRING_PROFILES_ACTIVE: dev
CONN_SHOWSQL: "true"
PORT: "8080"
URL: "https://esbtest.macro.com.ar"
NAME: "esb-client"
NAME_TOKEN: "esb-client-token"
\ No newline at end of file
apiVersion: apps/v1
kind: Deployment
metadata:
name: macro-ofertador
namespace: camunda-ns
spec:
replicas: 1
selector:
matchLabels:
app: macro-ofertador
template:
metadata:
labels:
app: macro-ofertador
spec:
containers:
- name: macro-ofertador
image: 171220174642.dkr.ecr.us-east-1.amazonaws.com/macro-ofertador/macro-ofertador:latest
imagePullPolicy: Always
envFrom:
- configMapRef:
name: macro-ofertador-configmap
resources:
limits:
memory: "600Mi"
cpu: "500m"
ports:
- containerPort: 8080
\ No newline at end of file
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: macro-bpm-ingress
namespace: camunda-ns
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internal
alb.ingress.kubernetes.io/backend-protocol: HTTP
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80},{"HTTPS": 443}]'
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-east-1:220362816140:certificate/14459f1d-fe5f-4802-adcd-d7f91e5becb8
alb.ingress.kubernetes.io/target-type: instance
alb.ingress.kubernetes.io/healthcheck-protocol: HTTPS
alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
alb.ingress.kubernetes.io/ssl-redirect: '443'
labels:
app: macro-ofertador
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: macro-ofertador
port:
number: 8080
\ No newline at end of file
apiVersion: v1
kind: Secret
metadata:
annotations: {}
name: macro-ofertador-secret
namespace: camunda-ns
stringData:
CONN_DBNAME: macro-ofertador
CONN_HOST: localhost
CONN_PORT: '5432'
CONN_PWD: sa
CONN_USR: postgres
data:
CONN_DBNAME: <ADICIONAR EM BASE64>
CONN_HOST: <ADICIONAR EM BASE64>
CONN_PORT: <ADICIONAR EM BASE64>
CONN_PWD: <ADICIONAR EM BASE64>
CONN_USR: <ADICIONAR EM BASE64>
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
labels:
app: macro-ofertador
name: macro-ofertador
namespace: camunda-ns
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: macro-ofertador
sessionAffinity: None
type: NodePort
\ No newline at end of file
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
\ No newline at end of file
This diff is collapsed.
sonar.organization=macro
sonar.projectKey=macro-ofertador
sonar.projectName=macro-ofertador
#sonar.issuesReport.html.enable=false
#sonar.report.export.path=sonar-report.json
sonar.java.binaries=target/classes
sonar.sources=src/main
sonar.sourceEncoding=UTF-8
sonar.language=java
sonar.dynamicAnalysis=reuseReports
sonar.tests=src/test
sonar.junit.reportsPath=target/surefire-reports
sonar.surefire.reportsPath=target/surefire-reports
sonar.jacoco.reportPath=target/jacoco.exec
sonar.binaries=target/classes
sonar.java.coveragePlugin=jacoco
sonar.verbose=true
#sonar.analysis.mode=preview
#sonar.issuesReport.html.enable=true
#sonar.report.export.path=report.json
# Change the host.url to point to the
# sonarqube server (default localhost)
#sonar.host.url=https://code.perennialsys.com/sonar
# Exclude our examples from the duplication detection.
# Examples are expected to be somehow repetitive
#sonar.exclusions=examples/**,teshsuite/**
# Disable some rules on some files
#sonar.issue.ignore.multicriteria=j1,j2
# The Object.finalize() method should not be overridden
# But we need to clean the native memory with JNI
#sonar.issue.ignore.multicriteria.j1.ruleKey=java:S1113
#sonar.issue.ignore.multicriteria.j1.resourceKey=**/*.java
# Throwable.printStackTrace(...) should not be called
# But we don't have no better mechanism, and our Java apps are not rocket science
#sonar.issue.ignore.multicriteria.j2.ruleKey=java:S1148
#sonar.issue.ignore.multicriteria.j2.resourceKey=**/*.java
# Exclude some files from the analysis:
# - our unit tests
# - the tests that we borrowed elsewhere (MPICH and MBI)
# - Flex-generated files
# - Collectives that we borrowed elsewhere (mpich, openMPI and other implems)
# - the NAS, that are included in our examples
# - The Catch2 library, that is included in our unit tests
# - The xxHash library, used by the MC
# - MSG along with its examples and teshsuite
#sonar.exclusions=src/include/catch.hpp,src/include/xxhash.hpp,src/*_unit.c*,teshsuite/smpi/mpich3-test/**,**/*_dtd.c,**/*_dtd.h,**/*yy.c,src/xbt/automaton/parserPromela.tab.*,src/smpi/colls/**/*,examples/smpi/NAS/*,examples/smpi/gemm/gemm.c,src/msg/**,include/msg/**,examples/deprecated/**,teshsuite/msg/**
sonar.exclusions=**/enums/**/*, **/scope/**/*, **/infraestructure/**/*, **/MacroOfertadorApplication.java
\ No newline at end of file
This diff is collapsed.
Manifest-Version: 1.0
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: ar.com.macro.MacroBpmApplication
package ar.com.macro;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
@SpringBootApplication
@EnableProcessApplication
@EnableFeignClients
@Slf4j
@OpenAPIDefinition
public class MacroOfertadorApplication {
private static final String ACCESS_URLS_MESSAGE_LOG = "Access URLs: External: http://{}:{} Profiles: {}----------------------------------------------------------";
public static void main(String[] args) {
try {
java.security.Security.setProperty("networkaddress.cache.ttl", "60");
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication app = new SpringApplication(MacroOfertadorApplication.class);
Environment env = app.run(args).getEnvironment();
log.info(ACCESS_URLS_MESSAGE_LOG, InetAddress.getLocalHost().getHostAddress(),
env.getProperty("server.port"), env.getActiveProfiles());
} catch (Exception e) {
log.error("Error starting the application", e);
}
}
}
\ No newline at end of file
package ar.com.macro.adapter.aws.secrets;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@RequiredArgsConstructor
@AllArgsConstructor
public class AwsDbSecret {
private String username;
private String password;
private String host;
private int port;
private String name;
}
package ar.com.macro.adapter.aws.secrets;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@RequiredArgsConstructor
@AllArgsConstructor
public class AwsEsbSecret {
private String username;
private String password;
private String applicationId;
}
package ar.com.macro.adapter.controllers;
import javax.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ar.com.macro.adapter.services.AltaAcuerdoCtaCteService;
import ar.com.macro.adapter.services.ProcesoService;
import ar.com.macro.adapter.services.TycsService;
import ar.com.macro.bpm.scope.AltaAcuerdoCtaCteScopeHelper;
import ar.com.macro.core.application.incoming.request.AltaAcuerdoCtaCteRequest;
import ar.com.macro.core.application.incoming.request.CancelacionRequest;
import ar.com.macro.core.application.incoming.request.FirmaRequest;
import ar.com.macro.core.application.incoming.response.AltaAcuerdoCtaCteResponse;
import ar.com.macro.core.application.incoming.response.CancelacionResponse;
import ar.com.macro.core.application.incoming.response.CondicionesResponse;
import ar.com.macro.core.application.incoming.response.ConsultaTycsResponse;
import lombok.RequiredArgsConstructor;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/altaAcuerdoCtaCte")
public class AltaAcuerdoCtaCteController {
private final AltaAcuerdoCtaCteService altaAcuerdoCtaCteService;
private final TycsService tycsService;
private final ProcesoService procesoService;
@PostMapping("/iniciar")
public ResponseEntity<AltaAcuerdoCtaCteResponse> iniciar(@Valid @RequestBody AltaAcuerdoCtaCteRequest altaAcuerdoEnCtaRequest) {
String processInstanceId = altaAcuerdoCtaCteService.iniciar(altaAcuerdoEnCtaRequest);
AltaAcuerdoCtaCteResponse altaAcuerdoCtaCteResponse = AltaAcuerdoCtaCteResponse
.builder()
.resultado(HttpStatus.OK.name())
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.idSolicitud(processInstanceId)
.estadoDelProceso(procesoService.getEstadoDelProceso(processInstanceId))
.build();
return ResponseEntity.ok().body(altaAcuerdoCtaCteResponse);
}
@PostMapping("/firmaRealizada")
public ResponseEntity<AltaAcuerdoCtaCteResponse> validarFirma(@Valid @RequestBody FirmaRequest fimarRequest) {
String idSolicitud = altaAcuerdoCtaCteService.recibirFirma(fimarRequest, new AltaAcuerdoCtaCteScopeHelper(null));
AltaAcuerdoCtaCteResponse altaAcuerdoCtaCteResponse = AltaAcuerdoCtaCteResponse
.builder()
.resultado(HttpStatus.OK.name())
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.idSolicitud(idSolicitud)
.estadoDelProceso(procesoService.getEstadoDelProceso(fimarRequest.getIdSolicitud()))
.build();
return ResponseEntity.ok(altaAcuerdoCtaCteResponse);
}
@GetMapping("/consultaTycs/idSolicitud/{idSolicitud}")
public ResponseEntity<ConsultaTycsResponse> consultaTycs(@PathVariable String idSolicitud) {
ConsultaTycsResponse consultaTycsResponse = ConsultaTycsResponse
.builder()
.resultado(HttpStatus.OK.name())
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.idSolicitud(idSolicitud)
.listaIdsTycs(tycsService.getTycsPorIdSolicitud(idSolicitud))
.build();
return ResponseEntity.ok(consultaTycsResponse);
}
//TODO[EDPC-99-juliano] não temos ainda serviço no ESB, será endpoint ou delegate?
@GetMapping("/condicionesAcuerdoCC/{canal}/{idProducto}")
public ResponseEntity<CondicionesResponse> condicionesAcuerdoCC(@PathVariable String canal, @PathVariable String idProducto) {
return ResponseEntity.ok().body(altaAcuerdoCtaCteService.buscarParametros(canal, idProducto));
}
@PostMapping("/cancelacion")
public ResponseEntity<CancelacionResponse> cancelacion(@Valid @RequestBody CancelacionRequest cancelacionRequest) {
altaAcuerdoCtaCteService.cancelacion(cancelacionRequest, new AltaAcuerdoCtaCteScopeHelper(null));
CancelacionResponse cancelacion = CancelacionResponse
.builder()
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.build();
return ResponseEntity.ok(cancelacion);
}
}
package ar.com.macro.adapter.controllers;
import java.util.List;
import javax.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ar.com.macro.adapter.services.AltaComercioService;
import ar.com.macro.adapter.services.ProcesoService;
import ar.com.macro.adapter.services.TycsService;
import ar.com.macro.bpm.scope.AltaComercioScopeHelper;
import ar.com.macro.core.application.incoming.request.AltaComercioRequest;
import ar.com.macro.core.application.incoming.request.CancelacionRequest;
import ar.com.macro.core.application.incoming.request.FirmaRequest;
import ar.com.macro.core.application.incoming.response.AltaComercioResponse;
import ar.com.macro.core.application.incoming.response.CancelacionResponse;
import ar.com.macro.core.application.incoming.response.ConsultaEstadoSolicitudResponse;
import ar.com.macro.core.application.incoming.response.ConsultaTycsResponse;
import lombok.RequiredArgsConstructor;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/altaComercio")
public class AltaComercioController {
private final AltaComercioService altaComercioService;
private final TycsService tycsService;
private final ProcesoService procesoService;
@PostMapping("/iniciar")
public ResponseEntity<AltaComercioResponse> iniciar(@Valid @RequestBody AltaComercioRequest altaComercioRequest) {
String processInstanceId = altaComercioService.iniciar(altaComercioRequest);
AltaComercioResponse altaComercioResponse = AltaComercioResponse
.builder()
.resultado(HttpStatus.OK.name())
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.idSolicitud(processInstanceId)
.estadoDelProceso(procesoService.getEstadoDelProceso(processInstanceId))
.build();
return ResponseEntity.ok().body(altaComercioResponse);
}
@PostMapping("/firmaRealizada")
public ResponseEntity<AltaComercioResponse> validarFirma(@Valid @RequestBody FirmaRequest fimarRequest) {
String idSolicitud = altaComercioService.recibirFirma(fimarRequest, new AltaComercioScopeHelper(null));
AltaComercioResponse altaComercioResponse = AltaComercioResponse
.builder()
.resultado(HttpStatus.OK.name())
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.idSolicitud(idSolicitud)
.estadoDelProceso(procesoService.getEstadoDelProceso(fimarRequest.getIdSolicitud()))
.build();
return ResponseEntity.ok(altaComercioResponse);
}
//TODO[EDPC-108-felipe] não temos ainda serviço no ESB
@GetMapping("/consultaEstadoSolicitud")
public ResponseEntity<List<ConsultaEstadoSolicitudResponse>> consultaEstadoSolicitud(
@RequestParam String canal,
@RequestParam String tipoDoc,
@RequestParam Long nroTributario,
@RequestParam(required = false) String idSolicitud,
@RequestParam(required = false) String idSolSMO){
return ResponseEntity.ok(altaComercioService.consultarEstado(canal, tipoDoc, nroTributario, idSolicitud, idSolSMO));
}
@GetMapping("/consultaTycs/idSolicitud/{idSolicitud}")
public ResponseEntity<ConsultaTycsResponse> consultaTycs(@PathVariable String idSolicitud) {
ConsultaTycsResponse consultaTycsResponse = ConsultaTycsResponse
.builder()
.resultado(HttpStatus.OK.name())
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.idSolicitud(idSolicitud)
.listaIdsTycs(this.tycsService.getTycsPorIdSolicitud(idSolicitud))
.build();
return ResponseEntity.ok(consultaTycsResponse);
}
@PostMapping("/cancelacion")
public ResponseEntity<CancelacionResponse> cancelacion(@Valid @RequestBody CancelacionRequest cancelacionRequest) {
altaComercioService.cancelacion(cancelacionRequest, new AltaComercioScopeHelper(null));
CancelacionResponse cancelacion = CancelacionResponse
.builder()
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.build();
return ResponseEntity.ok(cancelacion);
}
}
package ar.com.macro.adapter.controllers;
import ar.com.macro.adapter.services.DesbordePrestamoService;
import ar.com.macro.adapter.services.ProcesoService;
import ar.com.macro.core.application.incoming.request.DesbordePrestamoActualizarRequest;
import ar.com.macro.core.application.incoming.request.DesbordePrestamoIniciarRequest;
import ar.com.macro.core.application.incoming.response.DesbordePrestamoDetalleResponse;
import ar.com.macro.core.application.incoming.response.DesbordePrestamoResponse;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@RequestMapping("api/desbordePrestamo")
public class DesbordePrestamoController {
private final DesbordePrestamoService desbordePrestamoService;
private final ProcesoService procesoService;
@PostMapping("/iniciar")
public ResponseEntity<DesbordePrestamoResponse> iniciar(
@Valid @RequestBody DesbordePrestamoIniciarRequest desbordePrestamoIniciarRequest) {
String processInstanceId = desbordePrestamoService.iniciar(desbordePrestamoIniciarRequest);
DesbordePrestamoResponse desbordePrestamoIniciarResponse = DesbordePrestamoResponse
.builder()
.resultado(HttpStatus.OK.name())
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.idSolicitud(processInstanceId)
.estadoDelProceso(procesoService.getEstadoDelProceso(processInstanceId))
.build();
return ResponseEntity.ok().body(desbordePrestamoIniciarResponse);
}
@PostMapping("/actualizarEstadoLead")
public ResponseEntity<HttpEntity> actualizarEstadoLead(
@Valid @RequestBody DesbordePrestamoActualizarRequest desbordePrestamoActualizarRequest) {
desbordePrestamoService.actualizarEstadoLead(desbordePrestamoActualizarRequest);
return ResponseEntity.status(201).build();
}
@GetMapping("/consultaDetalle")
@ResponseStatus(code = HttpStatus.OK)
public DesbordePrestamoDetalleResponse consultaDetalle(@RequestParam String idCanal, @RequestParam String idSolicitud) {
return desbordePrestamoService.consultaDetalle(idSolicitud);
}
}
package ar.com.macro.adapter.controllers;
import java.util.List;
import javax.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ar.com.macro.adapter.services.OfertadorService;
import ar.com.macro.adapter.services.ProcesoService;
import ar.com.macro.adapter.services.TycsService;
import ar.com.macro.core.application.incoming.request.OfertadorRequest;
import ar.com.macro.core.application.incoming.response.OfertadorResponse;
import lombok.RequiredArgsConstructor;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/Ofertador")
public class OfertadorController {
//private final AltaComercioService altaComercioService;
private final OfertadorService ofertadorService;
private final TycsService tycsService;
private final ProcesoService procesoService;
@PostMapping("/iniciar")
public ResponseEntity<OfertadorResponse> iniciar(@Valid @RequestBody OfertadorRequest ofertadorRequest) {
//String processInstanceId = altaComercioService.iniciar(altaComercioRequest);
String processInstanceId = ofertadorService.iniciar(ofertadorRequest);
List<String> productosOfrecidos = (List<String>) procesoService.getVariable(processInstanceId, "productosDisponibles") ;
OfertadorResponse ofertadorResponse = OfertadorResponse
.builder()
.resultado(HttpStatus.OK.name())
.codResultado(HttpStatus.OK.value())
.descripcion(HttpStatus.OK.series().name())
.idSolicitud(processInstanceId)
.banca(procesoService.getVariable(processInstanceId, "Banca").toString())
.segmento(procesoService.getVariable(processInstanceId, "Segmento").toString())
.subsegmento(procesoService.getVariable(processInstanceId, "Subsegmento").toString())
.nombre((procesoService.getVariable(processInstanceId, "FirmNombre").toString()))
.productosOfrecidos(productosOfrecidos)
.build();
return ResponseEntity.ok().body(ofertadorResponse);
}
}
package ar.com.macro.adapter.services;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import ar.com.macro.bpm.scope.AltaAcuerdoCtaCteScopeHelper;
import ar.com.macro.bpm.scope.ScopeHelper;
import ar.com.macro.core.application.incoming.request.AltaAcuerdoCtaCteRequest;
import ar.com.macro.core.application.incoming.response.CondicionesResponse;
@Service
public class AltaAcuerdoCtaCteService extends CommonsService {
private static final String VENTANA_HORARIA = "Lunes-viernes 8-20";
public AltaAcuerdoCtaCteService(ProcesoService procesoService) {
super(procesoService);
}
public String iniciar(AltaAcuerdoCtaCteRequest altaAcuerdoCtaCteRequest) {
Map<String, Object> variables = new HashMap<>();
variables.put(ScopeHelper.CANAL, altaAcuerdoCtaCteRequest.getCanal());
variables.put(ScopeHelper.ID_COBIS, altaAcuerdoCtaCteRequest.getIdCobis());
variables.put(AltaAcuerdoCtaCteScopeHelper.TIPO_PERSONA, altaAcuerdoCtaCteRequest.getTipoPersona());
variables.put(AltaAcuerdoCtaCteScopeHelper.TIPO_DOCUMENTO, altaAcuerdoCtaCteRequest.getTipoDocumento());
variables.put(AltaAcuerdoCtaCteScopeHelper.NRO_DOC, altaAcuerdoCtaCteRequest.getNroDoc());
variables.put(AltaAcuerdoCtaCteScopeHelper.NRO_CUENTA, altaAcuerdoCtaCteRequest.getNroCuenta());
variables.put(AltaAcuerdoCtaCteScopeHelper.OPERACION, altaAcuerdoCtaCteRequest.getOperacion());
variables.put(AltaAcuerdoCtaCteScopeHelper.PLAZO, altaAcuerdoCtaCteRequest.getPlazo());
variables.put(AltaAcuerdoCtaCteScopeHelper.RENOVACION, altaAcuerdoCtaCteRequest.isRenovacion());
variables.put(AltaAcuerdoCtaCteScopeHelper.PERIODOS, altaAcuerdoCtaCteRequest.getPeriodos());
variables.put(AltaAcuerdoCtaCteScopeHelper.MONTO, altaAcuerdoCtaCteRequest.getMonto());
variables.put(AltaAcuerdoCtaCteScopeHelper.PORCEN_DISMINUC, altaAcuerdoCtaCteRequest.getPorcenDisminuc());
variables.put(AltaAcuerdoCtaCteScopeHelper.LINEA_CREDITO, altaAcuerdoCtaCteRequest.getLineaCredito());
variables.put(AltaAcuerdoCtaCteScopeHelper.TIPO_LIQUIDACION, altaAcuerdoCtaCteRequest.getTipoLiquidacion());
variables.put(AltaAcuerdoCtaCteScopeHelper.DESVIO_TASA, altaAcuerdoCtaCteRequest.getDesvioTasa());
variables.put(AltaAcuerdoCtaCteScopeHelper.TIPO_DESVIO, altaAcuerdoCtaCteRequest.getTipoDesvio());
variables.put(AltaAcuerdoCtaCteScopeHelper.SOL_TIPO_DOC, altaAcuerdoCtaCteRequest.getSolTipoDoc());
variables.put(AltaAcuerdoCtaCteScopeHelper.SOL_NUM_DOC, altaAcuerdoCtaCteRequest.getSolNumDoc());
variables.put(AltaAcuerdoCtaCteScopeHelper.SOL_CARACTER_INVOCADO, altaAcuerdoCtaCteRequest.getSolCaracterInvocado());
variables.put(AltaAcuerdoCtaCteScopeHelper.SOL_PARTICIPACION_SEG, altaAcuerdoCtaCteRequest.getSolParticipacionSeg());
return procesoService.ejecutar(AltaAcuerdoCtaCteScopeHelper.PROCESS_KEY, variables);
}
public CondicionesResponse buscarParametros(String canal, String idProducto) {
// TODO[EDPC-99-juliano] descomentar quando serviço estiver disponivel
// TODO[EDPC-99-juliano] CondicionesResponse parametrosCondiciones = this.esbClient.getCondicionesESB(canal,idProducto);
CondicionesResponse parametrosCondiciones = new CondicionesResponse();
List<Integer> plazosRenovacion = new ArrayList<>();
plazosRenovacion.add(30);
parametrosCondiciones.setPlazosRenovacion(plazosRenovacion);
parametrosCondiciones.setTopeCanal(BigDecimal.valueOf(100000));
parametrosCondiciones.setTopePFseguro(BigDecimal.valueOf(80000));
parametrosCondiciones.setTopePJGarantia(BigDecimal.valueOf(90000));
parametrosCondiciones.setTasaFija30Dias(BigDecimal.valueOf(10.5));
parametrosCondiciones.setTasasVariables(BigDecimal.valueOf(5.5));
parametrosCondiciones.setTasaPerfilAcopiadorSoja(BigDecimal.valueOf(3.5));
parametrosCondiciones.setTasaPerfilMiPyme(BigDecimal.valueOf(5.5));
parametrosCondiciones.setVentanaHoraria(VENTANA_HORARIA);
return parametrosCondiciones;
}
}
package ar.com.macro.adapter.services;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.stereotype.Service;
import ar.com.macro.bpm.scope.AltaComercioScopeHelper;
import ar.com.macro.bpm.scope.ScopeHelper;
import ar.com.macro.core.application.incoming.request.AltaComercioRequest;
import ar.com.macro.core.application.incoming.response.ConsultaEstadoSolicitudResponse;
import ar.com.macro.core.application.incoming.response.SmoAltaComercioResponse;
import ar.com.macro.infraestructure.exception.NotFoundException;
@Service
public class AltaComercioService extends CommonsService {
public AltaComercioService(ProcesoService procesoService) {
super(procesoService);
}
public String iniciar(AltaComercioRequest altaComercioRequest) {
Map<String, Object> variables = new HashMap<>();
variables.put(ScopeHelper.CANAL, altaComercioRequest.getCanal());
variables.put(ScopeHelper.ID_COBIS, altaComercioRequest.getIdCobis());
variables.put(AltaComercioScopeHelper.CUIT, altaComercioRequest.getCuit());
variables.put(AltaComercioScopeHelper.SUCURSAL, altaComercioRequest.getSucursal());
variables.put(AltaComercioScopeHelper.FORMA_DE_PAGO, altaComercioRequest.getFormaDePago());
variables.put(AltaComercioScopeHelper.CUENTA_ACREDITACION, altaComercioRequest.getCuentaAcreditacion());
variables.put(AltaComercioScopeHelper.TIPOIIBB, altaComercioRequest.getTipoiibb());
variables.put(AltaComercioScopeHelper.NROIIBB, altaComercioRequest.getNroiibb());
variables.put(AltaComercioScopeHelper.MAIL_CONTACTO, altaComercioRequest.getMailContacto());
variables.put(AltaComercioScopeHelper.TIPO_TELEFONO, altaComercioRequest.getTipoTelefono());
variables.put(AltaComercioScopeHelper.CODIGO_AREA, altaComercioRequest.getCodigoArea());
variables.put(AltaComercioScopeHelper.TEL_CONTACTO, altaComercioRequest.getTelContacto());
variables.put(AltaComercioScopeHelper.NOMBRE_FANTASIA, altaComercioRequest.getNombreFantasia());
variables.put(AltaComercioScopeHelper.MODALIDAD_VENTA, altaComercioRequest.getModalidadVenta());
variables.put(AltaComercioScopeHelper.TIPO_PERSONA, altaComercioRequest.getTipoPersona());
variables.put(AltaComercioScopeHelper.PROVINCIA, altaComercioRequest.getProvincia());
variables.put(AltaComercioScopeHelper.LOCALIDAD, altaComercioRequest.getLocalidad());
variables.put(AltaComercioScopeHelper.CALLE, altaComercioRequest.getCalle());
variables.put(AltaComercioScopeHelper.NRO_CALLE, altaComercioRequest.getNroCalle());
variables.put(AltaComercioScopeHelper.PISO, altaComercioRequest.getPiso());
variables.put(AltaComercioScopeHelper.DEPARTAMENTO, altaComercioRequest.getDepartamento());
variables.put(AltaComercioScopeHelper.CP, altaComercioRequest.getCp());
variables.put(AltaComercioScopeHelper.MARCA, altaComercioRequest.getMarca());
variables.put(AltaComercioScopeHelper.PRODUCTO_DISPO, altaComercioRequest.getProductoDispo());
variables.put(AltaComercioScopeHelper.ACTIVIDAD_AFIP, altaComercioRequest.getActividadAfip());
variables.put(AltaComercioScopeHelper.CANT_TERMINALES, altaComercioRequest.getCantTerminales());
variables.put(AltaComercioScopeHelper.TIPO_TERMINAL, altaComercioRequest.getTipoTerminal());
variables.put(AltaComercioScopeHelper.CUOTAS, altaComercioRequest.getCuotas());
variables.put(AltaComercioScopeHelper.PLAN, altaComercioRequest.getPlan());
variables.put(AltaComercioScopeHelper.GATEWAY, altaComercioRequest.getGateway());
variables.put(AltaComercioScopeHelper.COD_ADMINISTRADORA, altaComercioRequest.getCodAdministradora());
variables.put(AltaComercioScopeHelper.RESP_NOMBRE, altaComercioRequest.getRespNombre());
variables.put(AltaComercioScopeHelper.RESP_APELLIDO, altaComercioRequest.getRespApellido());
variables.put(AltaComercioScopeHelper.RESP_NACIONALIDAD, altaComercioRequest.getRespNacionalidad());
variables.put(AltaComercioScopeHelper.RESP_LUGAR_NAC, altaComercioRequest.getRespLugarNac());
variables.put(AltaComercioScopeHelper.RESP_PAIS_RESI, altaComercioRequest.getRespPaisResi());
variables.put(AltaComercioScopeHelper.RESP_PARTICIPACION, altaComercioRequest.getRespParticipacion());
variables.put(AltaComercioScopeHelper.RESP_TIPO_DOC, altaComercioRequest.getRespTipoDoc());
variables.put(AltaComercioScopeHelper.RESP_NUM_DOC, altaComercioRequest.getRespNumDoc());
variables.put(AltaComercioScopeHelper.RESP_CUIT, altaComercioRequest.getRespCuit());
variables.put(AltaComercioScopeHelper.RESP_PROFESION, altaComercioRequest.getRespProfesion());
variables.put(AltaComercioScopeHelper.RESP_PEP, altaComercioRequest.getRespPep());
variables.put(AltaComercioScopeHelper.RESP_TIPO_PEP, altaComercioRequest.getRespTipoPep());
variables.put(AltaComercioScopeHelper.FECHA_CONTRATO_CONSTITUTIVO, altaComercioRequest.getFechaContratoConstitutivo());
variables.put(AltaComercioScopeHelper.NUMERO_INSCRIPTION_REGISTRAL, altaComercioRequest.getNumeroInscriptionRegistral());
variables.put(AltaComercioScopeHelper.FECHA_INSCRIPTION_REGISTAL, altaComercioRequest.getFechaInstrictionRegistral());
return procesoService.ejecutar(AltaComercioScopeHelper.PROCESS_KEY, variables);
}
//TODO[EDPC-108-felipe] não temos ainda serviço no ESB
public List<ConsultaEstadoSolicitudResponse> consultarEstado(String canal, String tipoDoc, Long nroTributario, String idSolicitud, String idSolSMO) {
List<ConsultaEstadoSolicitudResponse> consultaEstadoSolicitudResponse = new ArrayList<>();
Optional.of(this.procesoService.buscaProcessos(canal, tipoDoc, nroTributario, idSolicitud, idSolSMO)).ifPresent(instance ->
instance.forEach(p -> {
SmoAltaComercioResponse response = new SmoAltaComercioResponse().mockResponse(p.getId());
if (response != null) {
consultaEstadoSolicitudResponse.add(ConsultaEstadoSolicitudResponse.builder()
.estado(response.getEncabezado().getEstado())
.numeroComercio(response.getEncabezado().getNumeroComercio())
.modoEntrada(response.getEncabezado().getModoEntrada())
.tipoSolicitud(response.getEncabezado().getTipoSolicitud())
.idSolicitud(response.getEncabezado().getIdSolicitud()).build());
}
})
);
if (consultaEstadoSolicitudResponse.isEmpty()) {
// TODO[] properties
throw new NotFoundException("Ninguna solicitud encontrada");
}
return consultaEstadoSolicitudResponse;
}
}
package ar.com.macro.adapter.services;
import org.springframework.stereotype.Service;
import ar.com.macro.core.application.outcoming.EsbClient;
import ar.com.macro.core.application.outcoming.response.ElementsClientesConsultaCuentasResponse;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class ClientesConsultaCuentasService {
private final EsbClient esbClient;
public ElementsClientesConsultaCuentasResponse getClientesConsultaDeCuentas(Long idCobis) {
return esbClient.getClientesConsultaDeCuentas(idCobis);
}
}
package ar.com.macro.adapter.services;
import java.util.Collections;
import java.util.Optional;
import org.springframework.stereotype.Service;
import ar.com.macro.core.application.outcoming.EsbClient;
import ar.com.macro.core.application.outcoming.response.ClientesConsultaGeneralResponse;
import ar.com.macro.core.application.outcoming.response.ElementsClientesConsultaGeneralResponse;
import ar.com.macro.infraestructure.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class ClientesConsultaGeneralService {
private final EsbClient esbClient;
public ClientesConsultaGeneralResponse getClientesConsultaGeneral(String tipoDocumento, String numeroIdentificacion) {
ElementsClientesConsultaGeneralResponse response;
////if (idCobis !=null)
// response = Optional.ofNullable(esbClient.getClientesConsultaGeneral(idCobis)).orElse(ElementsClientesConsultaGeneralResponse.builder().elements(Collections.emptyList()).build());
//else
response = Optional.ofNullable(esbClient.getClientesConsultaGeneralPorCuit(numeroIdentificacion, tipoDocumento)).orElse(ElementsClientesConsultaGeneralResponse.builder().elements(Collections.emptyList()).build());
return response.getElements().stream().findFirst()
// TODO[] properties
.orElseThrow(() -> new NotFoundException("not_found"));
}
}
package ar.com.macro.adapter.services;
import java.util.HashMap;
import java.util.Map;
import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
import org.springframework.stereotype.Service;
import ar.com.macro.bpm.scope.ScopeHelper;
import ar.com.macro.core.application.incoming.request.CancelacionRequest;
import ar.com.macro.core.application.incoming.request.FirmaRequest;
import ar.com.macro.infraestructure.exception.BusinessException;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
abstract class CommonsService {
protected final ProcesoService procesoService;
public String recibirFirma(FirmaRequest firmaRequest, ScopeHelper scopeHelper) {
Map<String, Object> variables = new HashMap<>();
variables.put(ScopeHelper.CANAL, firmaRequest.getCanal());
variables.put(ScopeHelper.ID_SOLICITUD, firmaRequest.getIdSolicitud());
variables.put(ScopeHelper.ID_COBIS, firmaRequest.getIdCobis());
variables.put(ScopeHelper.FIRM_NOMBRE, firmaRequest.getFirmNombre());
variables.put(ScopeHelper.FIRM_APELLI, firmaRequest.getFirmApelli());
variables.put(ScopeHelper.FIRM_FECHA_NAC, firmaRequest.getFirmFechaNac());
variables.put(ScopeHelper.FIRM_NACIONALIDAD, firmaRequest.getFirmNacionalidad());
variables.put(ScopeHelper.FIRM_LUGAR_NAC, firmaRequest.getFirmLugarNac());
variables.put(ScopeHelper.FIRM_SEXO, firmaRequest.getFirmSexo());
variables.put(ScopeHelper.FIRM_EST_CIVIL, firmaRequest.getFirmEstCivil());
variables.put(ScopeHelper.FIRM_TIPO_DOC, firmaRequest.getFirmTipoDoc());
variables.put(ScopeHelper.FIRM_NUM_DOC, firmaRequest.getFirmNumDoc());
variables.put(ScopeHelper.FIRM_CUIT, firmaRequest.getFirmCuit());
variables.put(ScopeHelper.FIRM_PROV, firmaRequest.getFirmProv());
variables.put(ScopeHelper.FIRM_LOCALIDAD, firmaRequest.getFirmLocalidad());
variables.put(ScopeHelper.FIRM_CALLE, firmaRequest.getFirmCalle());
variables.put(ScopeHelper.FIRM_NRO_CALLE, firmaRequest.getFirmNroCalle());
variables.put(ScopeHelper.FIRM_CP, firmaRequest.getFirmCp());
variables.put(ScopeHelper.FIRM_PEP, firmaRequest.getFirmPep());
variables.put(ScopeHelper.FIRM_TIPO_PEP, firmaRequest.getFirmTipoPep());
variables.put(ScopeHelper.LISTA_TYCS, firmaRequest.getIdTYC());
MessageCorrelationBuilder correlation = this.procesoService.createMessageCorrelation(scopeHelper.getMessageKeyFirmaRealizada());
correlation.processInstanceId(firmaRequest.getIdSolicitud());
correlation.setVariables(variables);
correlation.correlate();
return firmaRequest.getIdSolicitud();
}
public void cancelacion(CancelacionRequest cancelacionRequest, ScopeHelper scopeHelper) {
Map<String, Object> variables = new HashMap<>();
variables.put(ScopeHelper.CANAL, cancelacionRequest.getIdCanal());
variables.put(ScopeHelper.MOTIVO_CANCELACION, cancelacionRequest.getMotivoCancelacion());
variables.put(ScopeHelper.CUIT_FIRMANTE, cancelacionRequest.getCuitFirmante());
MessageCorrelationBuilder correlation = this.procesoService.createMessageCorrelation(scopeHelper.getMessageKeyCancelacionSolicitada());
correlation.processInstanceId(cancelacionRequest.getIdSolicitud());
correlation.setVariables(variables);
correlation.correlate();
if (procesoService.isActivityInstance(cancelacionRequest.getIdSolicitud())) {
String resposta = String.valueOf(procesoService.getVariable(cancelacionRequest.getIdSolicitud(), ScopeHelper.MOTIVO_CANCELACION));
throw new BusinessException(resposta);
}
}
}
package ar.com.macro.adapter.services;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.stereotype.Service;
import ar.com.macro.bpm.scope.AltaComercioScopeHelper;
import ar.com.macro.bpm.scope.OfertadorScopeHelper;
import ar.com.macro.bpm.scope.ScopeHelper;
import ar.com.macro.core.application.incoming.request.AltaComercioRequest;
import ar.com.macro.core.application.incoming.request.OfertadorRequest;
import ar.com.macro.core.application.incoming.response.ConsultaEstadoSolicitudResponse;
import ar.com.macro.core.application.incoming.response.SmoAltaComercioResponse;
import ar.com.macro.infraestructure.exception.NotFoundException;
@Service
public class OfertadorService extends CommonsService {
public OfertadorService(ProcesoService procesoService) {
super(procesoService);
}
public String iniciar(OfertadorRequest ofertadorRequest) {
Map<String, Object> variables = new HashMap<>();
variables.put(OfertadorScopeHelper.NUMERO_IDENTIFICACION, ofertadorRequest.getNumeroIdentificacion());
variables.put(OfertadorScopeHelper.TIPO_DOCUMENTO, ofertadorRequest.getTipoDocumento());
return procesoService.ejecutar(OfertadorScopeHelper.PROCESS_KEY, variables);
}
}
package ar.com.macro.adapter.services;
import ar.com.macro.core.application.outcoming.EsbClient;
import ar.com.macro.core.application.outcoming.response.ElementsConsultaDetalleResponse;
import ar.com.macro.core.application.outcoming.response.PasivasConsultaDetalleCuentaResponse;
import ar.com.macro.infraestructure.exception.IntegrationException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.Optional;
@Service
@RequiredArgsConstructor
public class PasivasConsultaDetalleCuentaService {
private final EsbClient esbClient;
public PasivasConsultaDetalleCuentaResponse consulta(String tipoCuenta, Long numeroCuenta, String codigoMoneda) {
ElementsConsultaDetalleResponse response = Optional.ofNullable(this.esbClient
.getClientesConsultaDetalleCuentas(tipoCuenta, numeroCuenta, codigoMoneda))
.orElse(ElementsConsultaDetalleResponse.builder().elements(Collections.emptyList()).build());
//TODO[] properties and notfound
return response.getElements().stream().findFirst().orElseThrow(() -> new IntegrationException("Ocurrió un error" +
" al intentar recuperar los detalles de la cuenta"));
}
}
package ar.com.macro.adapter.services;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotBlank;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.history.HistoricProcessInstance;
import org.camunda.bpm.engine.history.HistoricVariableInstance;
import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.variable.Variables;
import org.springframework.stereotype.Service;
import ar.com.macro.bpm.scope.AltaComercioScopeHelper;
import ar.com.macro.bpm.scope.DesbordePrestamoScopeHelper;
import ar.com.macro.bpm.scope.ScopeHelper;
import ar.com.macro.core.application.incoming.request.DesbordePrestamoActualizarRequest;
import ar.com.macro.infraestructure.exception.BusinessException;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class ProcesoService {
private final RuntimeService runtimeService;
private final ProcessEngine processEngine;
public MessageCorrelationBuilder createMessageCorrelation(@NotBlank String nombre) {
return runtimeService.createMessageCorrelation(nombre);
}
public boolean isActivityInstance(String idSolicitud) {
return runtimeService.getActivityInstance(idSolicitud) != null;
}
public Object getVariable(String idSolicitud, String variable) {
return runtimeService.getVariable(idSolicitud, variable);
}
public String getEstadoDelProceso(String idSolicitud){
return String.valueOf(runtimeService.getVariable(idSolicitud, ScopeHelper.ESTADO_DEL_PROCESO));
}
public String ejecutar(@NotBlank String nombre, Map<String, Object> variables) {
if (this.procesoPermitidoEjecutar(nombre)) {
return runtimeService.startProcessInstanceByKey(nombre, variables).getProcessInstanceId();
} else {
// TODO[] properties
String error = String.format("El proceso %s no se encuentra en horario habilitado para su ejecución", nombre);
throw new BusinessException(error);
}
}
public List<HistoricProcessInstance> buscaProcessos(String canal, String tipoDoc, Long nroTributario, String idSolicitud, String idSolSMO) {
if (idSolicitud == null) {
return processEngine.getHistoryService()
.createHistoricProcessInstanceQuery()
.processDefinitionKey(AltaComercioScopeHelper.PROCESS_KEY)
.variableValueEquals(AltaComercioScopeHelper.RESP_NUM_DOC, nroTributario)
.variableValueEquals(ScopeHelper.CANAL, canal)
.variableValueEquals(AltaComercioScopeHelper.RESP_TIPO_DOC, tipoDoc)
.unlimitedList();
} else {
return processEngine.getHistoryService()
.createHistoricProcessInstanceQuery()
.processDefinitionKey(AltaComercioScopeHelper.PROCESS_KEY)
.variableValueEquals(AltaComercioScopeHelper.RESP_NUM_DOC, nroTributario)
.variableValueEquals(ScopeHelper.CANAL, canal)
.variableValueEquals(AltaComercioScopeHelper.RESP_TIPO_DOC, tipoDoc)
.processInstanceId(idSolicitud)
.unlimitedList();
}
}
private boolean procesoPermitidoEjecutar(@NotBlank String nombre) {
ProcessInstance pi = this.runtimeService.startProcessInstanceByKey("HorariosDisponibilidadProcesos",
Variables.createVariables().putValue("procesoKey", nombre));
List<HistoricVariableInstance> variables = this.processEngine.getHistoryService()
.createHistoricVariableInstanceQuery().processInstanceId(pi.getId()).list();
return variables.stream().filter(v -> v.getName().equalsIgnoreCase("habilitado")).findFirst()
.map(h -> Boolean.parseBoolean(h.getValue().toString())).orElse(false);
}
public void actualizarDesbordePrestamoPorId(DesbordePrestamoActualizarRequest desbordePrestamoActualizarRequest) {
runtimeService.setVariable(desbordePrestamoActualizarRequest.getIdSolicitud(), DesbordePrestamoScopeHelper.ID_USUARIO, desbordePrestamoActualizarRequest.getIdUsuario());
runtimeService.setVariable(desbordePrestamoActualizarRequest.getIdSolicitud(), ScopeHelper.CANAL, desbordePrestamoActualizarRequest.getIdCanal());
runtimeService.setVariable(desbordePrestamoActualizarRequest.getIdSolicitud(), DesbordePrestamoScopeHelper.DESC_USUARIO, desbordePrestamoActualizarRequest.getDescUsuario());
runtimeService.setVariable(desbordePrestamoActualizarRequest.getIdSolicitud(), DesbordePrestamoScopeHelper.ESTADO_LEAD, desbordePrestamoActualizarRequest.getEstadoLead());
if(desbordePrestamoActualizarRequest.getObservaciones() != null){
runtimeService.setVariable(desbordePrestamoActualizarRequest.getIdSolicitud(), DesbordePrestamoScopeHelper.OBSERVACIONES, desbordePrestamoActualizarRequest.getObservaciones());
}
}
}
package ar.com.macro.adapter.services;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.ListObjectsV2Result;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotBlank;
import java.io.File;
import java.util.List;
import java.util.Optional;
@Slf4j
@Service
@RequiredArgsConstructor
public class S3Service {
private final AmazonS3 amazonS3Client;
@Setter
@Value("${aws.bucket.name}")
private String bucketName;
public List<Bucket> listarBuckets() {
List<Bucket> buckets = amazonS3Client.listBuckets();
buckets.forEach(bucket -> log.info("Bucket {} created at {}", bucket.getName(), bucket.getCreationDate()));
return buckets;
}
public List<S3ObjectSummary> listarArchivosPorBucket(String bucketNombre) {
String bucket = Optional.ofNullable(bucketNombre).orElse(bucketName);
ListObjectsV2Result result = amazonS3Client.listObjectsV2(bucket);
List<S3ObjectSummary> objectSummaries = result.getObjectSummaries();
objectSummaries.forEach(os -> log.info("* {}", os.getKey()));
return objectSummaries;
}
public void subirArchivo(@NotBlank String fileKey, @NotBlank File file) {
log.info("Subiendo el archivo {} para el bucket {}", fileKey, bucketName);
amazonS3Client.putObject(bucketName, fileKey, file);
}
public void suprimirArchivo(@NotBlank String fileKey) {
log.info("Suprimiendo el archivo {} para del bucket {}", fileKey, bucketName);
amazonS3Client.deleteObject(bucketName, fileKey);
}
}
package ar.com.macro.adapter.services;
import ar.com.macro.adapter.aws.secrets.AwsEsbSecret;
import ar.com.macro.core.application.entities.Token;
import ar.com.macro.core.application.outcoming.TokenEsbClient;
import ar.com.macro.core.application.repository.TokenRepository;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service
@RequiredArgsConstructor
public class TokenInterceptorService implements RequestInterceptor {
private final TokenEsbClient tokenEsbClient;
private final TokenRepository tokenRepository;
private final AwsEsbSecret awsEsbSecret;
public String getToken() {
List<Token> actualList = new ArrayList<>();
Objects.requireNonNull(tokenRepository.findAll()).iterator().forEachRemaining(actualList::add);
if (!actualList.isEmpty() && !isExpired(actualList.get(0))) {
return actualList.get(0).getValue();
}
return renewToken().getValue();
}
private Map<String, String> generateHeaders() {
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "*/*");
headers.put("AcceptEncoding", "gzip,deflate, br");
String encoding = Base64.getEncoder().encodeToString((this.awsEsbSecret.getUsername() + ":" +
this.awsEsbSecret.getPassword()).getBytes());
headers.put(HttpHeaders.AUTHORIZATION, "Basic " + encoding);
return headers;
}
public Token renewToken() {
String auth = String.valueOf(tokenEsbClient.getToken(this.generateHeaders()).headers().get("X-Authorization-token"));
Token newToken = new Token();
newToken.setValue(auth);
newToken.setDate(new Date());
tokenRepository.save(newToken);
return newToken;
}
public boolean isExpired(Token token) {
Instant inicio = token.getDate().toInstant();
Instant fim = inicio.plus(25, ChronoUnit.MINUTES);
return Instant.now().isAfter(fim);
}
@Override
public void apply(RequestTemplate requestTemplate) {
requestTemplate.header("Content-Type", "*/*");
requestTemplate.header("Host", "camunda");
requestTemplate.header("Accept", "application/json");
requestTemplate.header("X-Authorization-impersonationLevel", "service");
requestTemplate.header("X-Application-identity", this.awsEsbSecret.getApplicationId());
requestTemplate.header("X-Authorization-token", getToken());
}
}
package ar.com.macro.adapter.services;
import java.util.List;
import org.springframework.stereotype.Service;
import ar.com.macro.bpm.scope.ScopeHelper;
import ar.com.macro.core.application.outcoming.DocClient;
import ar.com.macro.core.application.outcoming.response.TycResponse;
import ar.com.macro.infraestructure.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class TycsService {
private final DocClient docClient;
private final ProcesoService procesoService;
public List<TycResponse> getTycsPorProcesoNombre(String keyProcesso) {
return docClient.getTycsPorProcesoNombre(keyProcesso);
}
@SuppressWarnings("unchecked")
public List<Integer> getTycsPorIdSolicitud(String idSolicitud) {
if (!procesoService.isActivityInstance(idSolicitud)) {
// TODO[] properties
throw new NotFoundException("IdSolicitud notfound");
}
return (List<Integer>) procesoService.getVariable(idSolicitud, ScopeHelper.LISTA_TYCS);
}
}
package ar.com.macro.bpm.scope;
import java.math.BigDecimal;
import java.util.List;
import org.camunda.bpm.engine.delegate.DelegateExecution;
public class AltaAcuerdoCtaCteScopeHelper extends ScopeHelper {
public static final String PROCESS_KEY = "AltaAcuerdoCtaCte";
public static final String MESSAGE_KEY_CANCELACION_SOLICITADA = "AltaAcuerdoCtaCteCancelacionSolicitada";
public static final String MESSAGE_KEY_FIRMA_REALIZADA = "AltaAcuerdoCtaCteFirmaRealizada";
public static final String TIPO_PERSONA = "TipoPersona";
public static final String TIPO_DOCUMENTO = "TipoDocumento";
public static final String NRO_DOC = "NroDoc";
public static final String NRO_CUENTA = "NroCuenta";
public static final String OPERACION = "Operacion";
public static final String PLAZO = "Plazo";
public static final String RENOVACION = "Renovacion";
public static final String PERIODOS = "Periodos";
public static final String MONTO = "Monto";
public static final String PORCEN_DISMINUC = "PorcenDisminuc";
public static final String LINEA_CREDITO = "LineaCredito";
public static final String TIPO_LIQUIDACION = "TipoLiquidacion";
public static final String DESVIO_TASA = "DesvioTasa";
public static final String TIPO_DESVIO = "TipoDesvio";
public static final String SOL_TIPO_DOC = "SolTipoDoc";
public static final String SOL_NUM_DOC = "SolNumDoc";
public static final String SOL_CARACTER_INVOCADO = "SolCaracterInvocado";
public static final String SOL_PARTICIPACION_SEG = "SolParticipacionSeg";
public static final String ID_PRODUCTO = "idProducto";
public static final String TOPE_CANAL = "topeCanal";
public static final String TOPE_PF_SEGURO = "idProducto";
public static final String TOPE_PJ_GARANTIA = "idProducto";
public static final String PLAZOS_RENOVACION = "plazosRenovacion";
public static final String TASA_FIJA_30_DIAS = "tajaFija30Dias";
public static final String TASAS_VARIABLES = "tajasVariables";
public static final String TASA_PERFIL_ACOPIADOR_SOJA = "tasaPerfilAcopiadorSoja";
public static final String TASA_PERFIL_MI_PYME = "tasaPerfilMiPyme";
public static final String VENTANA_HORARIA = "ventanaHoraria";
public static final String TOTAL_DISPONIBLE = "TotalDisponible";
public AltaAcuerdoCtaCteScopeHelper(DelegateExecution variableScope) {
super(variableScope);
}
@Override
public String getProcessKey() {
return PROCESS_KEY;
}
@Override
public String getMessageKeyFirmaRealizada() {
return MESSAGE_KEY_FIRMA_REALIZADA;
}
@Override
public String getMessageKeyCancelacionSolicitada() {
return MESSAGE_KEY_CANCELACION_SOLICITADA;
}
public String getOperacion() {
return (String) variableScope.getVariable(OPERACION);
}
public void setOperacion(String operacion) {
variableScope.setVariable(OPERACION, operacion);
}
@SuppressWarnings("unchecked")
public List<Integer> getPlazosRenovacion() {
return (List<Integer>) variableScope.getVariable(PLAZOS_RENOVACION);
}
public void setPlazosRenovacion(List<Integer> plazosRenovacion) {
variableScope.setVariable(PLAZOS_RENOVACION, plazosRenovacion);
}
public BigDecimal getTopeCanal() {
return (BigDecimal) variableScope.getVariable(TOPE_CANAL);
}
public void setTopeCanal(BigDecimal topeCanal) {
variableScope.setVariable(TOPE_CANAL, topeCanal);
}
public BigDecimal getTopePfSeguro() {
return (BigDecimal) variableScope.getVariable(TOPE_PF_SEGURO);
}
public void setTopePfSeguro(BigDecimal topePfSeguro) {
variableScope.setVariable(TOPE_PF_SEGURO, topePfSeguro);
}
public BigDecimal getTopePjGarantia() {
return (BigDecimal) variableScope.getVariable(TOPE_PJ_GARANTIA);
}
public void setTopePjGarantia(BigDecimal topePjGarantia) {
variableScope.setVariable(TOPE_PJ_GARANTIA, topePjGarantia);
}
public String getIdProducto() {
return (String) variableScope.getVariable(ID_PRODUCTO);
}
public void setIdProducto(String idProducto) {
variableScope.setVariable(ID_PRODUCTO, idProducto);
}
public BigDecimal getTasaFija30Dias() {
return (BigDecimal) variableScope.getVariable(TASA_FIJA_30_DIAS);
}
public void setTasaFija30Dias(BigDecimal tasaFija30Dias) {
variableScope.setVariable(TASA_FIJA_30_DIAS, tasaFija30Dias);
}
public BigDecimal getTasasVariables() {
return (BigDecimal) variableScope.getVariable(TASAS_VARIABLES);
}
public void setTasasVariables(BigDecimal tasasVariables) {
variableScope.setVariable(TASAS_VARIABLES, tasasVariables);
}
public BigDecimal getTasaPerfilAcopiadorSoja() {
return (BigDecimal) variableScope.getVariable(TASA_PERFIL_ACOPIADOR_SOJA);
}
public void setTasaPerfilAcopiadorSoja(BigDecimal tasaPerfilAcopiadorSoja) {
variableScope.setVariable(TASA_PERFIL_ACOPIADOR_SOJA, tasaPerfilAcopiadorSoja);
}
public BigDecimal getTasaPerfilMiPyme() {
return (BigDecimal) variableScope.getVariable(TASA_PERFIL_MI_PYME);
}
public void setTasaPerfilMiPyme(BigDecimal tasaPerfilMiPyme) {
variableScope.setVariable(TASA_PERFIL_MI_PYME, tasaPerfilMiPyme);
}
public String getVentanaHoraria() {
return (String) variableScope.getVariable(VENTANA_HORARIA);
}
public void setVentanaHoraria(String ventanaHoraria) {
variableScope.setVariable(VENTANA_HORARIA, ventanaHoraria);
}
public String getPeriodos() {
return (String) variableScope.getVariable(PERIODOS);
}
public void setPeriodos(String periodos) {
variableScope.setVariable(PERIODOS, periodos);
}
public BigDecimal getTotalDisponible() {
return (BigDecimal) variableScope.getVariable(TOTAL_DISPONIBLE);
}
public void setTotalDisponible(BigDecimal totalDisponible) {
variableScope.setVariable(TOTAL_DISPONIBLE, totalDisponible);
}
}
\ No newline at end of file
package ar.com.macro.bpm.scope;
import org.camunda.bpm.engine.delegate.DelegateExecution;
public class OfertadorScopeHelper extends ScopeHelper {
// PROCESS KEY
public static final String PROCESS_KEY = "OfertadorProductos";
// MESSAGES KEY
public static final String MESSAGE_KEY_FIRMA_REALIZADA = "AltaDeComercioFirmaRealizada";
public static final String MESSAGE_KEY_CANCELACION_SOLICITADA = "AltaDeComercioCancelacionSolicitada";
// PARAMETROS INICIAR
public static final String NUMERO_IDENTIFICACION = "numeroIdentificacion";
public static final String TIPO_DOCUMENTO = "tipoDocumento";
public OfertadorScopeHelper(DelegateExecution variableScope) {
super(variableScope);
}
@Override
public String getProcessKey() {
return PROCESS_KEY;
}
@Override
public String getMessageKeyFirmaRealizada() {
return MESSAGE_KEY_FIRMA_REALIZADA;
}
@Override
public String getMessageKeyCancelacionSolicitada() {
return MESSAGE_KEY_CANCELACION_SOLICITADA;
}
public String getNumeroIdentificacion() {
return (String) variableScope.getVariable(NUMERO_IDENTIFICACION);
}
public void setNumeroIdentificacion(String numeroIdentificacion) {
variableScope.setVariable(NUMERO_IDENTIFICACION, numeroIdentificacion);
}
public String getTipoDocumento() {
return (String) variableScope.getVariable(TIPO_DOCUMENTO);
}
public void setTipoDocumento(String tipoDocumento) {
variableScope.setVariable(TIPO_DOCUMENTO, tipoDocumento);
}
}
\ No newline at end of file
package ar.com.macro.bpm.scope;
import java.util.Date;
import java.util.List;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.VariableScope;
public abstract class ScopeHelper {
protected final VariableScope variableScope;
public static final String ID_SOLICITUD = "IdSolicitud";
public static final String CANAL = "Canal";
public static final String ID_COBIS = "IDCobis";
// PARAMETROS REALIZAR FIRMA
public static final String FIRM_NOMBRE = "FirmNombre";
public static final String FIRM_APELLI = "FirmApelli";
public static final String FIRM_FECHA_NAC = "FirmFechaNac";
public static final String FIRM_NACIONALIDAD = "FirmNacionalidad";
public static final String FIRM_LUGAR_NAC = "FirmLugarNac";
public static final String FIRM_SEXO = "FirmSexo";
public static final String FIRM_EST_CIVIL = "FirmEstCivil";
public static final String FIRM_TIPO_DOC = "FirmTipoDoc";
public static final String FIRM_NUM_DOC = "FirmNumDoc";
public static final String FIRM_CUIT = "FirmCUIT";
public static final String FIRM_PROV = "FirmProv";
public static final String FIRM_LOCALIDAD = "FirmLocalidad";
public static final String FIRM_CALLE = "FirmCalle";
public static final String FIRM_NRO_CALLE = "FirmNroCalle";
public static final String FIRM_CP = "FirmCP";
public static final String FIRM_PEP = "FirmPEP";
public static final String FIRM_TIPO_PEP = "FirmTipoPEP";
// PARAMETROS CANCELACION
public static final String MOTIVO_CANCELACION = "motivoCancelacion";
public static final String CUIT_FIRMANTE = "CUITFirmante";
// PARAMETROS TYCs
public static final String LISTA_TYCS = "ListaTycs";
public static final String ESTADO_DEL_PROCESO = "estadoDelProceso";
protected ScopeHelper(DelegateExecution execution) {
this.variableScope = execution;
}
public abstract String getProcessKey();
public abstract String getMessageKeyFirmaRealizada();
public abstract String getMessageKeyCancelacionSolicitada();
public String getIdSolicitud() {
return (String) variableScope.getVariable(ID_SOLICITUD);
}
public void setIdSolicitud(String idSolicitud) {
variableScope.setVariable(ID_SOLICITUD, idSolicitud);
}
public String getCanal() {
return (String) variableScope.getVariable(CANAL);
}
public void setCanal(String canal) {
variableScope.setVariable(CANAL, canal);
}
public Long getIdCobis() {
return (Long) variableScope.getVariable(ID_COBIS);
}
public void setIdCobis(Long idCobis) {
variableScope.setVariable(ID_COBIS, idCobis);
}
public String getFirmNombre() {
return (String) variableScope.getVariable(FIRM_NOMBRE);
}
public void setFirmNombre(String firmNombre) {
variableScope.setVariable(FIRM_NOMBRE, firmNombre);
}
public String getFirmApelli() {
return (String) variableScope.getVariable(FIRM_APELLI);
}
public void setFirmApelli(String firmApelli) {
variableScope.setVariable(FIRM_APELLI, firmApelli);
}
public Date getFirmFechaNac() {
return (Date) variableScope.getVariable(FIRM_FECHA_NAC);
}
public void setFirmFechaNac(Date firmFechaNac) {
variableScope.setVariable(FIRM_FECHA_NAC, firmFechaNac);
}
public String getFirmNacionalidad() {
return (String) variableScope.getVariable(FIRM_NACIONALIDAD);
}
public void setFirmNacionalidad(String firmNacionalidad) {
variableScope.setVariable(FIRM_NACIONALIDAD, firmNacionalidad);
}
public String getFirmLugarNac() {
return (String) variableScope.getVariable(FIRM_LUGAR_NAC);
}
public void setFirmLugarNac(String firmLugarNac) {
variableScope.setVariable(FIRM_LUGAR_NAC, firmLugarNac);
}
public String getFirmSexo() {
return (String) variableScope.getVariable(FIRM_SEXO);
}
public void setFirmSexo(String firmSexo) {
variableScope.setVariable(FIRM_SEXO, firmSexo);
}
public String getFirmEstCivil() {
return (String) variableScope.getVariable(FIRM_EST_CIVIL);
}
public void setFirmEstCivil(String firmEstCivil) {
variableScope.setVariable(FIRM_EST_CIVIL, firmEstCivil);
}
public String getFirmTipoDoc() {
return (String) variableScope.getVariable(FIRM_TIPO_DOC);
}
public void setFirmTipoDoc(String firmTipoDoc) {
variableScope.setVariable(FIRM_TIPO_DOC, firmTipoDoc);
}
public Long getFirmNumDoc() {
return (Long) variableScope.getVariable(FIRM_NUM_DOC);
}
public void setFirmNumDoc(Long firmNumDoc) {
variableScope.setVariable(FIRM_NUM_DOC, firmNumDoc);
}
public Long getFirmCuit() {
return (Long) variableScope.getVariable(FIRM_CUIT);
}
public void setFirmCuit(Long firmCuit) {
variableScope.setVariable(FIRM_CUIT, firmCuit);
}
public String getFirmProv() {
return (String) variableScope.getVariable(FIRM_PROV);
}
public void setFirmProv(String firmProv) {
variableScope.setVariable(FIRM_PROV, firmProv);
}
public String getFirmLocalidad() {
return (String) variableScope.getVariable(FIRM_LOCALIDAD);
}
public void setFirmLocalidad(String firmLocalidad) {
variableScope.setVariable(FIRM_LOCALIDAD, firmLocalidad);
}
public String getFirmCalle() {
return (String) variableScope.getVariable(FIRM_CALLE);
}
public void setFirmCalle(String firmCalle) {
variableScope.setVariable(FIRM_CALLE, firmCalle);
}
public Integer getFirmNroCalle() {
return (Integer) variableScope.getVariable(FIRM_NRO_CALLE);
}
public void setFirmNroCalle(Integer firmNroCalle) {
variableScope.setVariable(FIRM_NRO_CALLE, firmNroCalle);
}
public Long getFirmCP() {
return (Long) variableScope.getVariable(FIRM_CP);
}
public void setFirmCP(Long firmCP) {
variableScope.setVariable(FIRM_CP, firmCP);
}
public Boolean getFirmPep() {
return (Boolean) variableScope.getVariable(FIRM_PEP);
}
public void setFirmPep(Boolean firmPep) {
variableScope.setVariable(FIRM_PEP, firmPep);
}
public String getFirmTipoPep() {
return (String) variableScope.getVariable(FIRM_TIPO_PEP);
}
public void setFirmTipoPep(String firmTipoPEP) {
variableScope.setVariable(FIRM_TIPO_PEP, firmTipoPEP);
}
@SuppressWarnings("unchecked")
public List<Integer> getListaTycs() {
return (List<Integer>) variableScope.getVariable(LISTA_TYCS);
}
public String getMotivoCancelacion() {
return (String) variableScope.getVariable(MOTIVO_CANCELACION);
}
public void setMotivoCancelacion(String motivoCancelacion) {
variableScope.setVariable(MOTIVO_CANCELACION, motivoCancelacion);
}
public String getCuitFirmante() {
return (String) variableScope.getVariable(CUIT_FIRMANTE);
}
public void setCuitFirmante(String cuitFirmante) {
variableScope.setVariable(CUIT_FIRMANTE, cuitFirmante);
}
public void setListaTycs(List<Integer> listaTycs) {
variableScope.setVariable(LISTA_TYCS, listaTycs);
}
}
package ar.com.macro.core.application.annotations;
import ar.com.macro.core.application.annotations.impl.MismoTamanoCuotaValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Constraint(validatedBy = MismoTamanoCuotaValidator.class)
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface MismoTamanoCuota {
String message() default "Cuotas y cuota deben ser del mismo tamaño";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
package ar.com.macro.core.application.annotations.impl;
import ar.com.macro.core.application.annotations.MismoTamanoCuota;
import ar.com.macro.core.application.incoming.request.DesbordePrestamoIniciarRequest;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Optional;
public class MismoTamanoCuotaValidator implements ConstraintValidator<MismoTamanoCuota, DesbordePrestamoIniciarRequest> {
@Override
public void initialize(MismoTamanoCuota constraintAnnotation) {
}
@Override
public boolean isValid(DesbordePrestamoIniciarRequest request, ConstraintValidatorContext context) {
return Optional.of(request)
.filter(e->request.getCuota() != null && request.getCuotas() != null)
.map(e -> request.getCuota().size() == request.getCuotas())
.orElse(request.getCuota() == null && request.getCuotas() == null);
}
}
package ar.com.macro.core.application.delegate;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;
import ar.com.macro.adapter.services.ClientesConsultaGeneralService;
import ar.com.macro.bpm.scope.AltaAcuerdoCtaCteScopeHelper;
import ar.com.macro.bpm.scope.OfertadorScopeHelper;
@Component("ACCClientesConsultaGeneral")
public class ACCClientesConsultaGeneralDelegate extends AbstractClientesConsultaGeneralDelegate {
protected ACCClientesConsultaGeneralDelegate(ClientesConsultaGeneralService clientesConsultaGeneralService) {
super(clientesConsultaGeneralService);
}
@Override
public void execute(DelegateExecution delegateExecution) {
super.executeClientesConsultaGeneralDelegate(new OfertadorScopeHelper(delegateExecution));
}
}
package ar.com.macro.core.application.delegate;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;
import ar.com.macro.bpm.scope.AltaAcuerdoCtaCteScopeHelper;
import ar.com.macro.core.application.incoming.response.CondicionesResponse;
import lombok.RequiredArgsConstructor;
@Component("ACCParametrosCondiciones")
@RequiredArgsConstructor
public class ACCParametrosCondicionesDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution delegateExecution) {
final AltaAcuerdoCtaCteScopeHelper scopeHelper = new AltaAcuerdoCtaCteScopeHelper(delegateExecution);
//TODO[EDPC-99-juliano] não temos ainda serviço no ESB, será endpoint ou delegate?
//TODO[EDPC-99-juliano] String canal = Optional.ofNullable(scopeHelper.getCanal()).orElse("TESTE").toString();
//TODO[EDPC-99-juliano] String idProducto = Optional.ofNullable(scopeHelper.getIdProducto()).orElse("1").toString();
//TODO[EDPC-99-juliano] CondicionesResponse parametrosCondiciones = this.esbClient.getCondicionesEsb(canal,idProducto);
List<Integer> plazos = new ArrayList<>();
plazos.add(30);
plazos.add(60);
CondicionesResponse parametrosCondiciones = CondicionesResponse.builder()
.topeCanal(BigDecimal.valueOf(500000))
.topePFseguro(BigDecimal.valueOf(600000))
.topePJGarantia(BigDecimal.valueOf(700000))
.plazosRenovacion(plazos)
.tasaFija30Dias(BigDecimal.valueOf(0.1))
.tasasVariables(BigDecimal.valueOf(0.01))
.tasaPerfilAcopiadorSoja(BigDecimal.valueOf(0.02))
.tasaPerfilMiPyme(BigDecimal.valueOf(0.03))
.ventanaHoraria("[1-5,08:00-19:30]")
.build();
scopeHelper.setTopeCanal(parametrosCondiciones.getTopeCanal());
scopeHelper.setTopePfSeguro(parametrosCondiciones.getTopePFseguro());
scopeHelper.setTopePjGarantia(parametrosCondiciones.getTopePJGarantia());
scopeHelper.setPlazosRenovacion(parametrosCondiciones.getPlazosRenovacion());
scopeHelper.setTasaFija30Dias(parametrosCondiciones.getTasaFija30Dias());
scopeHelper.setTasasVariables(parametrosCondiciones.getTasasVariables());
scopeHelper.setTasaPerfilAcopiadorSoja(parametrosCondiciones.getTasaPerfilAcopiadorSoja());
scopeHelper.setTasaPerfilMiPyme(parametrosCondiciones.getTasaPerfilMiPyme());
scopeHelper.setVentanaHoraria(parametrosCondiciones.getVentanaHoraria());
}
}
package ar.com.macro.core.application.delegate;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;
import ar.com.macro.adapter.services.TycsService;
import ar.com.macro.bpm.scope.AltaAcuerdoCtaCteScopeHelper;
@Component("ACCTyCDisponibles")
public class ACCTyCDisponiblesDelegate extends AbstractTyCDisponiblesDelegate {
protected ACCTyCDisponiblesDelegate(TycsService tycsService) {
super(tycsService);
}
@Override
public void execute(DelegateExecution delegateExecution) {
super.executeTycDisponiblesDelegate(new AltaAcuerdoCtaCteScopeHelper(delegateExecution));
}
}
package ar.com.macro.core.application.delegate;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Optional;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;
import ar.com.macro.bpm.scope.AltaAcuerdoCtaCteScopeHelper;
import ar.com.macro.core.application.outcoming.EsbClient;
import ar.com.macro.core.application.outcoming.response.AperturaLineaResponse;
import ar.com.macro.core.application.outcoming.response.ElementsResponse;
import ar.com.macro.core.application.outcoming.response.RiesgosResponse;
import lombok.RequiredArgsConstructor;
@Component("ACCVerificarDisponible")
@RequiredArgsConstructor
public class ACCVerificarDisponibleDelegate implements JavaDelegate {
public static final String ACUERDOCTA = "ACUERDOCTA";
private final EsbClient esbClient;
@Override
public void execute(DelegateExecution delegateExecution) {
final AltaAcuerdoCtaCteScopeHelper altaAcuerdoCtaCteScopeHelper = new AltaAcuerdoCtaCteScopeHelper(delegateExecution);
altaAcuerdoCtaCteScopeHelper.getOperacion();
// TODO[EDPC-87-mario]: esses campos ainda não existe no processo de acuerdoCTACTE, serão fixos?
String moneda = Optional.ofNullable(delegateExecution.getVariable("moneda")).orElse("80").toString();
String linea = Optional.ofNullable(delegateExecution.getVariable("linea")).orElse("1").toString();
String ente = String.valueOf(altaAcuerdoCtaCteScopeHelper.getIdCobis());
RiesgosResponse riestosCalificacionEndeudamientoCliente = this.esbClient
.getRiestosCalificacionEndeudamientoCliente(ente, moneda, linea);
ElementsResponse elementsResponse = new ElementsResponse();
AperturaLineaResponse aperturaLineaResponse = new AperturaLineaResponse();
aperturaLineaResponse.setOcLinea(ACUERDOCTA);
aperturaLineaResponse.setOiDisponible(BigDecimal.ZERO);
elementsResponse.setAperturaLineas(Collections.singletonList(aperturaLineaResponse));
BigDecimal total = Optional.ofNullable(riestosCalificacionEndeudamientoCliente.getElements())
.orElse(Collections.emptyList())
.stream().findFirst().orElse(elementsResponse)
.getAperturaLineas().stream()
.filter(a -> a.getOdLinea().equalsIgnoreCase(ACUERDOCTA))
.map(AperturaLineaResponse::getOiDisponible)
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
altaAcuerdoCtaCteScopeHelper.setTotalDisponible(total);
}
}
package ar.com.macro.core.application.delegate;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;
import ar.com.macro.adapter.services.ClientesConsultaGeneralService;
import ar.com.macro.bpm.scope.AltaComercioScopeHelper;
import ar.com.macro.core.application.outcoming.response.ClientesConsultaGeneralResponse;
@Component("AComClientesConsultaGeneral")
public class AComClientesConsultaGeneralDelegate extends AbstractClientesConsultaGeneralDelegate {
protected AComClientesConsultaGeneralDelegate(ClientesConsultaGeneralService clientesConsultaGeneralService) {
super(clientesConsultaGeneralService);
}
@Override
public void execute(DelegateExecution delegateExecution) {
final AltaComercioScopeHelper scopeHelper = new AltaComercioScopeHelper(delegateExecution);
/* ClientesConsultaGeneralResponse clientesConsultaGeneralResponse = super.executeClientesConsultaGeneralDelegate(scopeHelper);
scopeHelper.setFirmEmail(clientesConsultaGeneralResponse.getOdDireccionElectronica());
scopeHelper.setFirmPiso(clientesConsultaGeneralResponse.getOnDireccionPiso());
scopeHelper.setFirmDepto(clientesConsultaGeneralResponse.getOnDireccionDepto());
scopeHelper.setFirmProvCod(clientesConsultaGeneralResponse.getOcDireccionProvincia());
scopeHelper.setFirmCodigoArea(clientesConsultaGeneralResponse.getOnTelefonoDdn());
scopeHelper.setFirmTelefone(clientesConsultaGeneralResponse.getOnTelefono());
scopeHelper.setCondicionIva(clientesConsultaGeneralResponse.getOcIva());
scopeHelper.setSujetoObligado(clientesConsultaGeneralResponse.getOmSujetoObligado());*/
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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