diff --git a/pom.xml b/pom.xml index 05ce35e9036870a957511c00a92863dd7b0616d8..4ff004019833341eb7b5e134a69fe51807caeaa6 100644 --- a/pom.xml +++ b/pom.xml @@ -98,6 +98,16 @@ </dependencyManagement> <dependencies> + <dependency> + <groupId>org.camunda.bpm.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>org.camunda.bpm.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId> + <version>2.3.0</version> + </dependency> <dependency> <groupId>io.github.jhipster</groupId> <artifactId>jhipster</artifactId> diff --git a/src/main/java/fr/ippon/jhipster/bpm/config/SecurityConfiguration.java b/src/main/java/fr/ippon/jhipster/bpm/config/SecurityConfiguration.java index 1889cdbe3b4c30c7ddc92d634560f7e72b7f3d18..70cc8ddd098bebb9e14212a2fcc3f9a0cc15d296 100644 --- a/src/main/java/fr/ippon/jhipster/bpm/config/SecurityConfiguration.java +++ b/src/main/java/fr/ippon/jhipster/bpm/config/SecurityConfiguration.java @@ -70,6 +70,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { web.ignoring() .antMatchers(HttpMethod.OPTIONS, "/**") .antMatchers("/app/**/*.{js,html}") + .antMatchers("/api/admin/**/*.{js,html}") .antMatchers("/i18n/**") .antMatchers("/content/**") .antMatchers("/swagger-ui/index.html") @@ -101,6 +102,10 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .antMatchers("/api/account/reset-password/init").permitAll() .antMatchers("/api/account/reset-password/finish").permitAll() .antMatchers("/api/profile-info").permitAll() + .antMatchers("/api/cockpit/**").permitAll() + .antMatchers("/api/tasklist/**").permitAll() + .antMatchers("/api/engine/**").permitAll() + .antMatchers("/api/admin/**").permitAll() .antMatchers("/api/**").authenticated() .antMatchers("/management/health").permitAll() .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN) diff --git a/src/main/java/fr/ippon/jhipster/bpm/tasks/Printer.java b/src/main/java/fr/ippon/jhipster/bpm/tasks/Printer.java new file mode 100644 index 0000000000000000000000000000000000000000..c2224208b89a191902e24c17af506d837074f719 --- /dev/null +++ b/src/main/java/fr/ippon/jhipster/bpm/tasks/Printer.java @@ -0,0 +1,17 @@ +package fr.ippon.jhipster.bpm.tasks; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +@Service +public class Printer { + + private final Logger log = LoggerFactory.getLogger(this.getClass()); + + public void printMessage(DelegateExecution execution) { + + log.info("Hello world "+execution.getVariable("date")); + } +} diff --git a/src/main/java/fr/ippon/jhipster/bpm/web/rest/BPMResource.java b/src/main/java/fr/ippon/jhipster/bpm/web/rest/BPMResource.java new file mode 100644 index 0000000000000000000000000000000000000000..124dbccbe02e1dc3d21079642bf02f9448974d6a --- /dev/null +++ b/src/main/java/fr/ippon/jhipster/bpm/web/rest/BPMResource.java @@ -0,0 +1,34 @@ +package fr.ippon.jhipster.bpm.web.rest; + +import com.codahale.metrics.annotation.Timed; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.runtime.SignalEventReceivedBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDate; +import java.time.LocalDateTime; + + +@RestController +@RequestMapping("/api/bpm") +public class BPMResource { + + private final RuntimeService runtimeService; + + public BPMResource(RuntimeService runtimeService) { + this.runtimeService = runtimeService; + } + + @PostMapping("/signal") + @Timed + public ResponseEntity<Void> sendSignal(@RequestBody String signal) { + SignalEventReceivedBuilder signalEvent = runtimeService.createSignalEvent(signal); + signalEvent.setVariables(ImmutableMap.of("date", LocalDateTime.now())); + signalEvent.send(); + + return ResponseEntity.noContent().build(); + } +} diff --git a/src/main/resources/bpmn/test-1.bpmn b/src/main/resources/bpmn/test-1.bpmn new file mode 100644 index 0000000000000000000000000000000000000000..0a3374f14ca73761bf62baf20806aed0e15eea36 --- /dev/null +++ b/src/main/resources/bpmn/test-1.bpmn @@ -0,0 +1,52 @@ +<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3"> + <bpmn:process id="Process_1" isExecutable="true"> + <bpmn:endEvent id="EndEvent_0j97txi"> + <bpmn:incoming>SequenceFlow_17w5nfr</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1cdbpyo" sourceRef="StartEvent_1" targetRef="Task_1qgx3ke" /> + <bpmn:sequenceFlow id="SequenceFlow_17w5nfr" sourceRef="Task_1qgx3ke" targetRef="EndEvent_0j97txi" /> + <bpmn:serviceTask id="Task_1qgx3ke" name="Test" camunda:expression="#{printer.printMessage(execution)}"> + <bpmn:incoming>SequenceFlow_1cdbpyo</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17w5nfr</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:startEvent id="StartEvent_1" camunda:asyncAfter="true"> + <bpmn:outgoing>SequenceFlow_1cdbpyo</bpmn:outgoing> + <bpmn:signalEventDefinition signalRef="Signal_0bnb6yq" /> + </bpmn:startEvent> + </bpmn:process> + <bpmn:signal id="Signal_0bnb6yq" name="sayHello" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> + <bpmndi:BPMNShape id="EndEvent_0j97txi_di" bpmnElement="EndEvent_0j97txi"> + <dc:Bounds x="531" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="549" y="143" width="0" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1cdbpyo_di" bpmnElement="SequenceFlow_1cdbpyo"> + <di:waypoint xsi:type="dc:Point" x="209" y="120" /> + <di:waypoint xsi:type="dc:Point" x="293" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="251" y="100" width="0" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_17w5nfr_di" bpmnElement="SequenceFlow_17w5nfr"> + <di:waypoint xsi:type="dc:Point" x="393" y="120" /> + <di:waypoint xsi:type="dc:Point" x="531" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="462" y="100" width="0" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1r5ywpa_di" bpmnElement="Task_1qgx3ke"> + <dc:Bounds x="293" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_1gve085_di" bpmnElement="StartEvent_1"> + <dc:Bounds x="173" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="146" y="138" width="0" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index e5dd5427baac45dbeb0c0802b8737112949a7e31..4f8de056fa233817c42f167203216a379a1e6315 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -103,3 +103,10 @@ jhipster: # =================================================================== application: + +camunda: + bpm: + admin-user: + id: admin + password: admin + diff --git a/src/main/webapp/app/home/home.component.html b/src/main/webapp/app/home/home.component.html index 31278a435ae53f4f5e3adbde6d2bd4fb596c01e8..e0e2044d3ac904c1267b91bb1e97f4ab875ea690 100644 --- a/src/main/webapp/app/home/home.component.html +++ b/src/main/webapp/app/home/home.component.html @@ -5,6 +5,7 @@ <div class="col-md-9"> <h1 class="display-4" jhiTranslate="home.title">Welcome, Java Hipster!</h1> <p class="lead" jhiTranslate="home.subtitle">This is your homepage</p> + <button (click)="sayHello()">Say Hello</button> <div [ngSwitch]="isAuthenticated()"> <div class="alert alert-success" *ngSwitchCase="true"> diff --git a/src/main/webapp/app/home/home.component.ts b/src/main/webapp/app/home/home.component.ts index 3f70181336f75dcc1d57bd5f194f44821f52f6db..f951e79106613283f83bb9ce0dc0e832d5103106 100644 --- a/src/main/webapp/app/home/home.component.ts +++ b/src/main/webapp/app/home/home.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { JhiEventManager } from 'ng-jhipster'; -import { Account, LoginModalService, Principal } from '../shared'; +import { Account, LoginModalService, Principal, BpmService } from '../shared'; @Component({ selector: 'jhi-home', @@ -19,7 +19,8 @@ export class HomeComponent implements OnInit { constructor( private principal: Principal, private loginModalService: LoginModalService, - private eventManager: JhiEventManager + private eventManager: JhiEventManager, + private bpmService: BpmService ) { } @@ -45,4 +46,9 @@ export class HomeComponent implements OnInit { login() { this.modalRef = this.loginModalService.open(); } + + sayHello() { + console.log('Say Hello'); + this.bpmService.sendSignal('sayHello').subscribe(); + } } diff --git a/src/main/webapp/app/shared/bpm/bpm.service.ts b/src/main/webapp/app/shared/bpm/bpm.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..117cbb6442200c9f5cc9b87f41aca2ef5cafdacb --- /dev/null +++ b/src/main/webapp/app/shared/bpm/bpm.service.ts @@ -0,0 +1,22 @@ +import { Injectable } from '@angular/core'; +import { Http, Response } from '@angular/http'; +import { SERVER_API_URL } from '../../app.constants'; +import { ResponseWrapper } from '../index'; +import { Observable } from 'rxjs/Observable'; + +@Injectable() +export class BpmService { + + private resourceUrl = SERVER_API_URL + 'api/bpm'; + + constructor(private http: Http) { } + + sendSignal(signalName: string): Observable<Response> { + return this.http.post(`${this.resourceUrl}/signal/`, signalName); + } + + private convertResponse(res: Response): ResponseWrapper { + const jsonResponse = res.json(); + return new ResponseWrapper(res.headers, jsonResponse, res.status); + } +} diff --git a/src/main/webapp/app/shared/index.ts b/src/main/webapp/app/shared/index.ts index 9eb7fc2e4bbd22d67ad200f74f8e6c518c4a4ee7..d70c1ef398e5fee508c546aa325ebe60f659da23 100644 --- a/src/main/webapp/app/shared/index.ts +++ b/src/main/webapp/app/shared/index.ts @@ -18,6 +18,7 @@ export * from './login/login.service'; export * from './user/account.model'; export * from './user/user.model'; export * from './user/user.service'; +export * from './bpm/bpm.service'; export * from './model/response-wrapper.model'; export * from './model/request-util'; export * from './model/base-entity'; diff --git a/src/main/webapp/app/shared/shared.module.ts b/src/main/webapp/app/shared/shared.module.ts index bb3a7b41d707b1001d9d77212d816d4fb5c35460..fd0ae73ebcd881ded2006a2bec3baad94f37fede 100644 --- a/src/main/webapp/app/shared/shared.module.ts +++ b/src/main/webapp/app/shared/shared.module.ts @@ -14,6 +14,7 @@ import { JhiLoginModalComponent, Principal, HasAnyAuthorityDirective, + BpmService, } from './'; @NgModule({ @@ -34,6 +35,7 @@ import { CSRFService, AuthServerProvider, UserService, + BpmService, DatePipe ], entryComponents: [JhiLoginModalComponent],