Commit 1a172e23 authored by Hubert FONGARNAND's avatar Hubert FONGARNAND
Browse files

Add camunda workflow engine to JHipster

parent d3fd47a6
...@@ -98,6 +98,16 @@ ...@@ -98,6 +98,16 @@
</dependencyManagement> </dependencyManagement>
<dependencies> <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> <dependency>
<groupId>io.github.jhipster</groupId> <groupId>io.github.jhipster</groupId>
<artifactId>jhipster</artifactId> <artifactId>jhipster</artifactId>
......
...@@ -70,6 +70,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { ...@@ -70,6 +70,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
web.ignoring() web.ignoring()
.antMatchers(HttpMethod.OPTIONS, "/**") .antMatchers(HttpMethod.OPTIONS, "/**")
.antMatchers("/app/**/*.{js,html}") .antMatchers("/app/**/*.{js,html}")
.antMatchers("/api/admin/**/*.{js,html}")
.antMatchers("/i18n/**") .antMatchers("/i18n/**")
.antMatchers("/content/**") .antMatchers("/content/**")
.antMatchers("/swagger-ui/index.html") .antMatchers("/swagger-ui/index.html")
...@@ -101,6 +102,10 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { ...@@ -101,6 +102,10 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers("/api/account/reset-password/init").permitAll() .antMatchers("/api/account/reset-password/init").permitAll()
.antMatchers("/api/account/reset-password/finish").permitAll() .antMatchers("/api/account/reset-password/finish").permitAll()
.antMatchers("/api/profile-info").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("/api/**").authenticated()
.antMatchers("/management/health").permitAll() .antMatchers("/management/health").permitAll()
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
......
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"));
}
}
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();
}
}
<?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>
...@@ -103,3 +103,10 @@ jhipster: ...@@ -103,3 +103,10 @@ jhipster:
# =================================================================== # ===================================================================
application: application:
camunda:
bpm:
admin-user:
id: admin
password: admin
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<div class="col-md-9"> <div class="col-md-9">
<h1 class="display-4" jhiTranslate="home.title">Welcome, Java Hipster!</h1> <h1 class="display-4" jhiTranslate="home.title">Welcome, Java Hipster!</h1>
<p class="lead" jhiTranslate="home.subtitle">This is your homepage</p> <p class="lead" jhiTranslate="home.subtitle">This is your homepage</p>
<button (click)="sayHello()">Say Hello</button>
<div [ngSwitch]="isAuthenticated()"> <div [ngSwitch]="isAuthenticated()">
<div class="alert alert-success" *ngSwitchCase="true"> <div class="alert alert-success" *ngSwitchCase="true">
......
...@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { JhiEventManager } from 'ng-jhipster'; import { JhiEventManager } from 'ng-jhipster';
import { Account, LoginModalService, Principal } from '../shared'; import { Account, LoginModalService, Principal, BpmService } from '../shared';
@Component({ @Component({
selector: 'jhi-home', selector: 'jhi-home',
...@@ -19,7 +19,8 @@ export class HomeComponent implements OnInit { ...@@ -19,7 +19,8 @@ export class HomeComponent implements OnInit {
constructor( constructor(
private principal: Principal, private principal: Principal,
private loginModalService: LoginModalService, private loginModalService: LoginModalService,
private eventManager: JhiEventManager private eventManager: JhiEventManager,
private bpmService: BpmService
) { ) {
} }
...@@ -45,4 +46,9 @@ export class HomeComponent implements OnInit { ...@@ -45,4 +46,9 @@ export class HomeComponent implements OnInit {
login() { login() {
this.modalRef = this.loginModalService.open(); this.modalRef = this.loginModalService.open();
} }
sayHello() {
console.log('Say Hello');
this.bpmService.sendSignal('sayHello').subscribe();
}
} }
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);
}
}
...@@ -18,6 +18,7 @@ export * from './login/login.service'; ...@@ -18,6 +18,7 @@ export * from './login/login.service';
export * from './user/account.model'; export * from './user/account.model';
export * from './user/user.model'; export * from './user/user.model';
export * from './user/user.service'; export * from './user/user.service';
export * from './bpm/bpm.service';
export * from './model/response-wrapper.model'; export * from './model/response-wrapper.model';
export * from './model/request-util'; export * from './model/request-util';
export * from './model/base-entity'; export * from './model/base-entity';
......
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
JhiLoginModalComponent, JhiLoginModalComponent,
Principal, Principal,
HasAnyAuthorityDirective, HasAnyAuthorityDirective,
BpmService,
} from './'; } from './';
@NgModule({ @NgModule({
...@@ -34,6 +35,7 @@ import { ...@@ -34,6 +35,7 @@ import {
CSRFService, CSRFService,
AuthServerProvider, AuthServerProvider,
UserService, UserService,
BpmService,
DatePipe DatePipe
], ],
entryComponents: [JhiLoginModalComponent], entryComponents: [JhiLoginModalComponent],
......
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