Skip to content

Commit 49b0989

Browse files
Ticket ## : Display HumanTask in CMMN & BPMN editor
1 parent fe29033 commit 49b0989

22 files changed

Lines changed: 241 additions & 91 deletions

File tree

src/CaseManagement.HumanTask.AspNetCore/Apis/HumanTaskDefsController.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ public async Task<IActionResult> Search([FromBody] SearchHumanTaskDefQuery param
4545
return new OkObjectResult(result);
4646
}
4747

48+
[HttpGet]
49+
public async Task<IActionResult> GetAll(CancellationToken token)
50+
{
51+
var result = await _mediator.Send(new GetAllHumanTaskDefQuery(), token);
52+
return new OkObjectResult(result);
53+
}
54+
4855
[HttpGet("{id}")]
4956
public async Task<IActionResult> Get(string id, CancellationToken token)
5057
{

src/CaseManagement.HumanTask.Persistence.EF/Persistence/HumanTaskDefQueryRepository.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,11 @@ public async Task<FindResponse<HumanTaskDefinitionAggregate>> Search(SearchHuman
9292
Content = content
9393
};
9494
}
95+
96+
public async Task<ICollection<HumanTaskDefinitionAggregate>> GetAll(CancellationToken token)
97+
{
98+
var result = await _humanTaskDBContext.HumanTaskDefinitions.ToListAsync(token);
99+
return result;
100+
}
95101
}
96102
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using CaseManagement.HumanTask.HumanTaskDef.Results;
2+
using MediatR;
3+
using System.Collections.Generic;
4+
5+
namespace CaseManagement.HumanTask.HumanTaskDef.Queries
6+
{
7+
public class GetAllHumanTaskDefQuery : IRequest<ICollection<HumanTaskDefResult>>
8+
{
9+
}
10+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using CaseManagement.HumanTask.HumanTaskDef.Results;
2+
using CaseManagement.HumanTask.Persistence;
3+
using MediatR;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace CaseManagement.HumanTask.HumanTaskDef.Queries.Handlers
10+
{
11+
public class GetAllHumanTaskDefQueryHandler : IRequestHandler<GetAllHumanTaskDefQuery, ICollection<HumanTaskDefResult>>
12+
{
13+
private readonly IHumanTaskDefQueryRepository _humanTaskDefQueryRepository;
14+
15+
public GetAllHumanTaskDefQueryHandler(IHumanTaskDefQueryRepository humanTaskDefQueryRepository)
16+
{
17+
_humanTaskDefQueryRepository = humanTaskDefQueryRepository;
18+
}
19+
20+
public async Task<ICollection<HumanTaskDefResult>> Handle(GetAllHumanTaskDefQuery request, CancellationToken cancellationToken)
21+
{
22+
var result = await _humanTaskDefQueryRepository.GetAll(cancellationToken);
23+
return result.Select(_ => HumanTaskDefResult.ToDto(_)).ToList();
24+
}
25+
}
26+
}

src/CaseManagement.HumanTask/Persistence/IHumanTaskDefQueryRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using CaseManagement.Common.Responses;
22
using CaseManagement.HumanTask.Domains;
33
using CaseManagement.HumanTask.Persistence.Parameters;
4+
using System.Collections.Generic;
45
using System.Threading;
56
using System.Threading.Tasks;
67

@@ -9,6 +10,7 @@ namespace CaseManagement.HumanTask.Persistence
910
public interface IHumanTaskDefQueryRepository
1011
{
1112
Task<HumanTaskDefinitionAggregate> Get(string id, CancellationToken token);
13+
Task<ICollection<HumanTaskDefinitionAggregate>> GetAll(CancellationToken token);
1214
Task<HumanTaskDefinitionAggregate> GetLatest(string name, CancellationToken token);
1315
Task<FindResponse<HumanTaskDefinitionAggregate>> Search(SearchHumanTaskDefParameter parameter, CancellationToken token);
1416
}

src/CaseManagement.HumanTask/Persistence/InMemory/HumanTaskDefQueryRepository.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,10 @@ public Task<FindResponse<HumanTaskDefinitionAggregate>> Search(SearchHumanTaskDe
5656
Content = result.ToList()
5757
});
5858
}
59+
60+
public Task<ICollection<HumanTaskDefinitionAggregate>> GetAll(CancellationToken token)
61+
{
62+
return Task.FromResult((ICollection<HumanTaskDefinitionAggregate>)_humanTaskDefs.ToList());
63+
}
5964
}
6065
}

src/CaseManagement.Website/angularApp/app/bpmns/viewfile/viewfile.component.html

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -98,37 +98,46 @@
9898
<mat-expansion-panel-header>
9999
{{ 'BPMN.USERTASKINFO' | translate }}
100100
</mat-expansion-panel-header>
101-
<!-- WS-HumanTaskDef name -->
102-
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
103-
<mat-label>{{ 'SHARED.NAME' | translate }}</mat-label>
104-
<input matInput name="wsHumanTaskDefName" formControlName="wsHumanTaskDefName" />
105-
</mat-form-field>
106101
<!-- Type -->
107102
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
108103
<mat-label>{{ 'SHARED.IMPLEMENTATION' | translate }}</mat-label>
109104
<mat-select formControlName="implementation">
110105
<mat-option value="##WsHumanTask">{{ 'BPMN.SERVICEIMPLEMENTATION.WSHUMANTASK' | translate }}</mat-option>
111106
</mat-select>
112107
</mat-form-field>
113-
<form [formGroup]="addParameterForm" (ngSubmit)="addParameter(addParameterForm.value)">
114-
<!-- Key -->
115-
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
116-
<mat-label>{{ 'SHARED.KEY' | translate }}</mat-label>
117-
<input matInput name="key" formControlName="key" />
118-
</mat-form-field>
119-
<!-- Value -->
120-
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
121-
<mat-label>{{ 'SHARED.VALUE' | translate }}</mat-label>
122-
<input matInput name="value" formControlName="value" />
123-
</mat-form-field>
124-
<button mat-raised-button color="primary">{{ 'SHARED.ADD' | translate }}</button>
125-
</form>
126-
<mat-list>
127-
<mat-list-item *ngFor="let parameter of parameters" matTooltip="{{ parameter.key }} = {{ parameter.value }}">
128-
<button mat-icon-button (click)="removeParameter(parameter)"><mat-icon>remove</mat-icon></button>
129-
{{ parameter.key }}
130-
</mat-list-item>
131-
</mat-list>
108+
<!-- WS-HumanTaskDef name -->
109+
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
110+
<mat-label>{{ 'SHARED.NAME' | translate }}</mat-label>
111+
<mat-select formControlName="wsHumanTaskDefName" (selectionChange)="onHumanTaskChanged($event)">
112+
<mat-option [value]="humanTask.name" *ngFor="let humanTask of humanTaskDefs">
113+
{{ humanTask.name }}
114+
</mat-option>
115+
</mat-select>
116+
</mat-form-field>
117+
<!-- List of input parameters -->
118+
<div *ngIf="inputParameters.length > 0">
119+
<form [formGroup]="addParameterForm" (ngSubmit)="addParameter(addParameterForm.value)">
120+
<!-- Key -->
121+
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
122+
<mat-label>{{ 'SHARED.KEY' | translate }}</mat-label>
123+
<mat-select formControlName="key">
124+
<mat-option [value]="inputParameter.name" *ngFor="let inputParameter of inputParameters">{{ inputParameter.name }}</mat-option>
125+
</mat-select>
126+
</mat-form-field>
127+
<!-- Value -->
128+
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
129+
<mat-label>{{ 'SHARED.VALUE' | translate }}</mat-label>
130+
<input matInput name="value" formControlName="value" />
131+
</mat-form-field>
132+
<button mat-raised-button color="primary">{{ 'SHARED.ADD' | translate }}</button>
133+
</form>
134+
<mat-list>
135+
<mat-list-item *ngFor="let parameter of parameters" matTooltip="{{ parameter.key }} = {{ parameter.value }}">
136+
<button mat-icon-button (click)="removeParameter(parameter)"><mat-icon>remove</mat-icon></button>
137+
{{ parameter.key }}
138+
</mat-list-item>
139+
</mat-list>
140+
</div>
132141
</mat-expansion-panel>
133142
<!-- Exclusive gateway -->
134143
<mat-expansion-panel *ngIf="selectedElt.type === 'bpmn:ExclusiveGateway'">

src/CaseManagement.Website/angularApp/app/bpmns/viewfile/viewfile.component.ts

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { TranslateService } from '@ngx-translate/core';
1414
import { merge } from 'rxjs';
1515
import { filter } from 'rxjs/operators';
1616
import { ViewXmlDialog } from './view-xml-dialog';
17+
import { HumanTaskDef } from '@app/stores/humantaskdefs/models/humantaskdef.model';
18+
import { Parameter } from '@app/stores/common/parameter.model';
19+
import { BpmnFileState } from '@app/stores/bpmnfiles/reducers/bpmnfile.reducers';
1720
let BpmnViewer = require('bpmn-js/lib/Modeler'),
1821
propertiesPanelModule = require('bpmn-js-properties-panel'),
1922
propertiesProviderModule = require('bpmn-js-properties-panel/lib/provider/bpmn');
@@ -42,6 +45,8 @@ export class ViewBpmnFileComponent implements OnInit, OnDestroy {
4245
bpmnFile: BpmnFile = new BpmnFile();
4346
bpmnFiles: BpmnFile[] = [];
4447
bpmnInstances$: BpmnInstance[] = [];
48+
inputParameters: Parameter[] = [];
49+
humanTaskDefs: HumanTaskDef[] = [];
4550
versionFormControl: FormControl = new FormControl('');
4651
saveForm: FormGroup = new FormGroup({
4752
name: new FormControl({ value: '' }),
@@ -107,16 +112,17 @@ export class ViewBpmnFileComponent implements OnInit, OnDestroy {
107112
this.bpmnFiles = res.content;
108113
this.versionFormControl.setValue(this.bpmnFile.version);
109114
});
110-
this.bpmnFileListener = this.store.pipe(select(fromAppState.selectBpmnFileResult)).subscribe((bpmnFile: BpmnFile) => {
111-
if (!bpmnFile) {
115+
this.bpmnFileListener = this.store.pipe(select(fromAppState.selectBpmnFileResult)).subscribe((bpmnFileState: BpmnFileState) => {
116+
if (!bpmnFileState || !bpmnFileState.content) {
112117
return;
113118
}
114119

115-
this.bpmnFile = bpmnFile;
116-
this.saveForm.controls['name'].setValue(bpmnFile.name);
117-
this.saveForm.controls['description'].setValue(bpmnFile.description);
118-
this.viewer.importXML(bpmnFile.payload);
119-
const request = new fromBpmnFileActions.SearchBpmnFiles("create_datetime", "desc", 20000, 0, false, bpmnFile.fileId);
120+
this.bpmnFile = bpmnFileState.content;
121+
this.humanTaskDefs = bpmnFileState.humanTaskDefs;
122+
this.saveForm.controls['name'].setValue(bpmnFileState.content.name);
123+
this.saveForm.controls['description'].setValue(bpmnFileState.content.description);
124+
this.viewer.importXML(bpmnFileState.content.payload);
125+
const request = new fromBpmnFileActions.SearchBpmnFiles("create_datetime", "desc", 20000, 0, false, bpmnFileState.content.fileId);
120126
this.store.dispatch(request);
121127
});
122128
this.updatePropertiesForm.valueChanges.subscribe(() => {
@@ -286,6 +292,7 @@ export class ViewBpmnFileComponent implements OnInit, OnDestroy {
286292
if (bo.$type === 'bpmn:UserTask') {
287293
const index = this.parameters.indexOf(elt);
288294
this.parameters.splice(index, 1);
295+
this.saveProperties(this.updatePropertiesForm.value);
289296
}
290297
}
291298

@@ -298,6 +305,7 @@ export class ViewBpmnFileComponent implements OnInit, OnDestroy {
298305
if (bo.$type === 'bpmn:UserTask') {
299306
this.parameters.push(form);
300307
this.addParameterForm.reset();
308+
this.saveProperties(this.updatePropertiesForm.value);
301309
}
302310
}
303311

@@ -333,6 +341,23 @@ export class ViewBpmnFileComponent implements OnInit, OnDestroy {
333341
});
334342
}
335343

344+
onHumanTaskChanged(evt: any) {
345+
const value: string = evt.value;
346+
this.selectHumanTask(value);
347+
}
348+
349+
private selectHumanTask(name: string) {
350+
const filteredHumanTaskDefs = this.humanTaskDefs.filter(function (ht: HumanTaskDef) {
351+
return ht.name === name;
352+
})
353+
if (filteredHumanTaskDefs.length !== 1) {
354+
this.inputParameters = [];
355+
return;
356+
}
357+
358+
this.inputParameters = HumanTaskDef.getInputOperationParameters(filteredHumanTaskDefs[0]);
359+
}
360+
336361
private updateProperties(elt: any) {
337362
this.buildingForm = true;
338363
this.updatePropertiesForm.reset();
@@ -350,6 +375,7 @@ export class ViewBpmnFileComponent implements OnInit, OnDestroy {
350375
if (bo.$type === 'bpmn:UserTask') {
351376
this.updatePropertiesForm.get('implementation').setValue(bo.implementation);
352377
this.updatePropertiesForm.get('wsHumanTaskDefName').setValue(bo.get('cmg:wsHumanTaskDefName'));
378+
this.selectHumanTask(bo.get('cmg:wsHumanTaskDefName'));
353379
const parameters = this.getExtension(bo, 'cmg:Parameters');
354380
self.parameters = [];
355381
if (parameters && parameters.parameter) {

src/CaseManagement.Website/angularApp/app/bpmns/viewinstance/view.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { TranslateService } from '@ngx-translate/core';
1111
import { filter } from 'rxjs/operators';
1212
import { FormControl } from '@angular/forms';
1313
import { ViewMessageDialog } from './view-message-dialog';
14+
import { BpmnFileState } from '@app/stores/bpmnfiles/reducers/bpmnfile.reducers';
1415

1516
let BpmnViewer = require('bpmn-js/lib/Viewer');
1617

@@ -68,12 +69,12 @@ export class ViewBpmnInstanceComponent implements OnInit, OnDestroy {
6869
duration: 2000
6970
});
7071
});
71-
this.bpmnFileListener = this.store.pipe(select(fromAppState.selectBpmnFileResult)).subscribe((e: BpmnFile) => {
72-
if (!e || !e.payload) {
72+
this.bpmnFileListener = this.store.pipe(select(fromAppState.selectBpmnFileResult)).subscribe((e: BpmnFileState) => {
73+
if (!e || !e.content || !e.content.payload) {
7374
return;
7475
}
7576

76-
this.bpmnFile = e;
77+
this.bpmnFile = e.content;
7778
this.refreshCanvas();
7879

7980
});

0 commit comments

Comments
 (0)