@RunWith(SpringRunner.class)
@ComponentScan("hu.user.lis")
@SpringBootTest
-//@TestPropertySource("classpath:application.yaml")
+//@TestPropertySource("classpath:application-test.yaml")
//@AutoConfigureMockMvc
public class AssociatesDataModelIT {
@Autowired
--- /dev/null
+package hu.user.lis.workflow;
+
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+public class BpmnTest {
+ @Autowired
+ private RuntimeService runtimeService;
+
+ protected void waitForFinish(ProcessInstance processInstance) throws InterruptedException {
+ while (true) {
+ ProcessInstance active = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult();
+ if (active == null) {
+ break;
+ }
+ Thread.sleep(1000);
+ }
+ }
+
+ protected void cancelRunningProcesses(String processId) {
+ List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processDefinitionKey(processId).list();
+ processInstances.forEach(p -> {
+ try {
+ runtimeService.deleteProcessInstance(p.getProcessInstanceId(), "Canceled");
+ } catch (Exception e) {
+ }
+ });
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) $today.year-$today.month-24.
+ * By elGekko
+ */
+
+package hu.user.lis.workflow;
+
+import com.google.common.collect.ImmutableMap;
+import hu.user.lis.db.Project;
+import hu.user.lis.db.repository.PartnerRepository;
+import hu.user.lis.db.repository.ProjectRepository;
+import hu.user.lis.db.repository.ProjectStatusRepository;
+import hu.user.lis.workflow.properties.WorkflowProperties;
+import lombok.extern.log4j.Log4j2;
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.Objects;
+
+
+@Log4j2
+@SpringBootTest
+@RunWith(SpringRunner.class)
+@ActiveProfiles("test")
+@ComponentScan("hu.user.lis")
+public class PrepareProjectIT extends BpmnTest {
+ private final String PROCESSID = "prepareProject";
+ @Autowired
+ private RuntimeService runtimeService;
+
+ @Autowired
+ private WorkflowProperties workflowProperties;
+
+ @Autowired
+ private ProjectRepository projectRepository;
+
+ @Autowired
+ private PartnerRepository partnerRepository;
+
+ @Autowired
+ private ProjectStatusRepository projectStatusRepository;
+
+ @Test
+ public void testPrepareProject() throws InterruptedException {
+ Project project = Project.builder()
+ .partner(partnerRepository.findAll().get(0))
+ .projectStatus(projectStatusRepository.findAll().get(0))
+ .name("Teszt projekt")
+ .active(true)
+ .build();
+ try {
+ projectRepository.saveAndFlush(project);
+// log.info("Template source: {}", workflowProperties.getPrepareProject().getTemplateSourceFolder());
+ cancelRunningProcesses(PROCESSID);
+ ImmutableMap<String, Object> params = ImmutableMap.of("projectId", project.getId());
+ ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(PROCESSID, params);
+ waitForFinish(processInstance);
+ } catch (Exception e) {
+ log.error(e);
+ throw e;
+ } finally {
+ if (Objects.nonNull(project.getId())) {
+ projectRepository.delete(project);
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+server:
+ port: 8080
+ servlet:
+ context-path: /
+zk:
+ homepage: index
+ zul-view-resolver-enabled: true
+spring:
+ jpa:
+ # hibernate:
+ # use-new-id-generator-mappings: false
+ show-sql: false
+ properties:
+ hibernate:
+ format_sql: true
+ main:
+ banner-mode: off
+ output:
+ ansi:
+ enabled: always
+ datasource:
+ type: com.zaxxer.hikari.HikariDataSource
+ url: jdbc:db2://dvdev.in.useribm.hu:50000/lis
+ username: db2admin
+ password: password
+camunda.bpm:
+ generic-properties.properties:
+ telemetry-reporter-activate: false
+ job-executor-acquire-by-priority: true
+ job-execution:
+ core-pool-size: 10
+ #lock-time-in-millis: 600000
+ database:
+ type: db2
+ schema-update: false
+ table-prefix: CAMUNDA.
+ schema-name: CAMUNDA
+ webapp:
+ enabled: true
+ index-redirect-enabled: false
+ admin-user:
+ id: kermit
+ password: password
+ firstName: Kermit
+ filter:
+ create: All tasks
+ job-execution.enabled: true
+logging:
+ config: classpath:logback-dev.xml
+ level:
+ org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR
+ org.springframework.web.clientRestTemplate: DEBUG
+ logging.level.org.apache.http: TRACE
+ logging.level.httpclient.wire: TRACE
+application:
+ ui:
+ user-name: user
+ password: password
+ workflow:
+ import-invoice:
+ input-path: /temp/invoice-import
+ project-id-pattern: \d{4}-\d{4}
+ prepare-project:
+ template-source-folder: "valami"
+service:
+ nav:
+ trust:
+ store: classpath:keystore/lis-keystore.jks
+ store.password: password
+ api:
+ url: https://api-test.onlineszamla.nav.gov.hu/invoiceService/v3
+ user: vkvyibj5xgqpbp0
+ password: Salabakt3r
+ sign-key: fe-9d8b-971c878376204BQEWTHH2HI6
+ exchange-key: 3af24BQEWTHH4TSX
+ sender-tax-number: 13364937
+ sender-company: User Rendszerház Kft.
+ sender-country: HU
+ sender-contact: Kovács Géza
+ days-range: 34
\ No newline at end of file
--- /dev/null
+package hu.user.lis.workflow.project;
+
+import hu.user.lis.db.Project;
+import hu.user.lis.db.repository.ProjectRepository;
+import hu.user.lis.workflow.properties.WorkflowProperties;
+import lombok.extern.log4j.Log4j2;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.persistence.EntityNotFoundException;
+
+@Log4j2
+@Component
+public class CreateProjectFolders implements JavaDelegate {
+ @Autowired
+ private ProjectRepository projectRepository;
+
+ @Autowired
+ private WorkflowProperties workflowProperties;
+
+ @Override
+ public void execute(DelegateExecution delegateExecution) throws Exception {
+ Long projectId = (Long) delegateExecution.getVariable("projectId");
+ Project project = projectRepository.findById(projectId).orElseThrow(EntityNotFoundException::new);
+ log.info("Executing on project ID {}", projectId);
+// delegateExecution.setVariableLocal("invoices", invoices);
+ }
+}
private ImportInvoice importInvoice;
+ private PrepareProject prepareProject;
+
@Getter
@Setter
public static class ImportInvoice {
private String projectIdPattern;
}
+ @Getter
+ @Setter
+ public static class PrepareProject {
+ private String templateSourceFolder;
+ }
+
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_08cp8iu" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.14.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
+ <bpmn:process id="prepareProject" name="Prepare Project" isExecutable="true" camunda:historyTimeToLive="180">
+ <bpmn:startEvent id="StartEvent_1">
+ <bpmn:outgoing>Flow_1w8ohiv</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:sequenceFlow id="Flow_1w8ohiv" sourceRef="StartEvent_1" targetRef="createProjectFolders" />
+ <bpmn:serviceTask id="createProjectFolders" name="Create project folders" camunda:delegateExpression="${createProjectFolders}">
+ <bpmn:incoming>Flow_1w8ohiv</bpmn:incoming>
+ <bpmn:outgoing>Flow_0fihphr</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:endEvent id="Event_0h9gy35">
+ <bpmn:incoming>Flow_0fihphr</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_0fihphr" sourceRef="createProjectFolders" targetRef="Event_0h9gy35" />
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="prepareProject">
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
+ <dc:Bounds x="179" y="79" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_06cl6md_di" bpmnElement="createProjectFolders">
+ <dc:Bounds x="270" y="57" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0h9gy35_di" bpmnElement="Event_0h9gy35">
+ <dc:Bounds x="432" y="79" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="Flow_1w8ohiv_di" bpmnElement="Flow_1w8ohiv">
+ <di:waypoint x="215" y="97" />
+ <di:waypoint x="270" y="97" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0fihphr_di" bpmnElement="Flow_0fihphr">
+ <di:waypoint x="370" y="97" />
+ <di:waypoint x="432" y="97" />
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>