Skip to content

Commit efee5d9

Browse files
Ticket #105 : Add UI to manage notifications
1 parent 986f496 commit efee5d9

76 files changed

Lines changed: 4174 additions & 17 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/CaseManagement.CMMN/Domains/CasePlanInstance/BaseCasePlanItemInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private Criteria CloneCriteria(Criteria criteria)
9292
{
9393
result.SEntry.IfPart = new IfPart
9494
{
95-
Condition = result.SEntry.IfPart.Condition
95+
Condition = criteria.SEntry.IfPart.Condition
9696
};
9797
}
9898
}

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

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,64 @@ public async Task<IActionResult> UpdateInfo(string id, [FromBody] UpdateNotifica
8888
}
8989
}
9090

91+
[HttpPost("{id}/parameters")]
92+
public async Task<IActionResult> AddParameter(string id, [FromBody] AddNotificationDefParameterCommand parameter, CancellationToken token)
93+
{
94+
try
95+
{
96+
parameter.Id = id;
97+
var result = await _mediator.Send(parameter, token);
98+
return new OkObjectResult(result);
99+
}
100+
catch (UnknownHumanTaskDefException ex)
101+
{
102+
return this.ToError(new List<KeyValuePair<string, string>>
103+
{
104+
new KeyValuePair<string, string>("bad_request", ex.Message)
105+
}, HttpStatusCode.NotFound, Request);
106+
}
107+
catch (BadRequestException ex)
108+
{
109+
return this.ToError(new List<KeyValuePair<string, string>>
110+
{
111+
new KeyValuePair<string, string>("bad_request", ex.Message)
112+
}, HttpStatusCode.BadRequest, Request);
113+
}
114+
catch (AggregateValidationException ex)
115+
{
116+
return this.ToError(ex.Errors, HttpStatusCode.BadRequest, Request);
117+
}
118+
}
119+
120+
[HttpDelete("{id}/parameters/{parameterId}")]
121+
public async Task<IActionResult> DeleteParameter(string id, string parameterId, CancellationToken token)
122+
{
123+
try
124+
{
125+
var cmd = new DeleteNotificationDefParameterCommand { Id = id, ParameterId = parameterId };
126+
await _mediator.Send(cmd, token);
127+
return new NoContentResult();
128+
}
129+
catch (UnknownHumanTaskDefException ex)
130+
{
131+
return this.ToError(new List<KeyValuePair<string, string>>
132+
{
133+
new KeyValuePair<string, string>("bad_request", ex.Message)
134+
}, HttpStatusCode.NotFound, Request);
135+
}
136+
catch (BadRequestException ex)
137+
{
138+
return this.ToError(new List<KeyValuePair<string, string>>
139+
{
140+
new KeyValuePair<string, string>("bad_request", ex.Message)
141+
}, HttpStatusCode.BadRequest, Request);
142+
}
143+
catch (AggregateValidationException ex)
144+
{
145+
return this.ToError(ex.Errors, HttpStatusCode.BadRequest, Request);
146+
}
147+
}
148+
91149
[HttpPost("{id}/assignments")]
92150
public async Task<IActionResult> AddPeopleAssignment(string id, [FromBody] AddNotificationDefPeopleAssignmentCommand cmd, CancellationToken token)
93151
{
@@ -163,7 +221,6 @@ public async Task<IActionResult> AddPresentationElement(string id, [FromBody] Ad
163221
}
164222
}
165223

166-
167224
[HttpDelete("{id}/presentationelts/{usage}/{language}")]
168225
public async Task<IActionResult> AddPresentationElement(string id, PresentationElementUsages usage, string language, CancellationToken token)
169226
{

src/CaseManagement.HumanTask/Domains/NotificationDef/NotificationDefinitionAggregate.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public NotificationDefinitionAggregate()
1818
}
1919

2020
public string Name { get; set; }
21+
public int NbInstances { get; set; }
2122
/// <summary>
2223
/// This element is used to specify the priority of the notification.
2324
/// </summary>
@@ -134,6 +135,7 @@ private void Handle(NotificationDefinitionParameterAddedEvent evt)
134135

135136
OperationParameters.Add(new Parameter
136137
{
138+
Id = evt.Parameter.Id,
137139
IsRequired = evt.Parameter.IsRequired,
138140
Name = evt.Parameter.Name,
139141
Type = evt.Parameter.Type,
@@ -256,12 +258,18 @@ public override object Clone()
256258
{
257259
return new NotificationDefinitionAggregate
258260
{
261+
AggregateId = AggregateId,
262+
Version = Version,
263+
UpdateDateTime = UpdateDateTime,
264+
NbInstances = NbInstances,
265+
CreateDateTime = CreateDateTime,
259266
Name = Name,
260-
OperationParameters = OperationParameters.Select(_ => (Parameter)_.Clone()).ToList(),
261267
Priority = Priority,
268+
Rendering = Rendering,
262269
PeopleAssignments = PeopleAssignments.Select(_ => (PeopleAssignmentDefinition)_.Clone()).ToList(),
263270
PresentationElements = PresentationElements.Select(_ => (PresentationElementDefinition)_.Clone()).ToList(),
264-
Rendering = Rendering
271+
PresentationParameters = PresentationParameters.Select(_ => (PresentationParameter)_.Clone()).ToList(),
272+
OperationParameters = OperationParameters.Select(_ => (Parameter)_.Clone()).ToList()
265273
};
266274
}
267275
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using MediatR;
2+
using static CaseManagement.HumanTask.HumanTaskDef.Results.HumanTaskDefResult;
3+
4+
namespace CaseManagement.HumanTask.NotificationDef.Commands
5+
{
6+
public class AddNotificationDefParameterCommand : IRequest<string>
7+
{
8+
public string Id { get; set; }
9+
public ParameterResult Parameter { get; set; }
10+
}
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using MediatR;
2+
3+
namespace CaseManagement.HumanTask.NotificationDef.Commands
4+
{
5+
public class DeleteNotificationDefParameterCommand : IRequest<bool>
6+
{
7+
public string Id { get; set; }
8+
public string ParameterId { get; set; }
9+
}
10+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using CaseManagement.Common.Exceptions;
2+
using CaseManagement.HumanTask.Exceptions;
3+
using CaseManagement.HumanTask.Persistence;
4+
using CaseManagement.HumanTask.Resources;
5+
using MediatR;
6+
using Microsoft.Extensions.Logging;
7+
using System.Threading;
8+
using System.Threading.Tasks;
9+
10+
namespace CaseManagement.HumanTask.NotificationDef.Commands.Handlers
11+
{
12+
public class AddNotificationDefParameterCommandHandler : IRequestHandler<AddNotificationDefParameterCommand, string>
13+
{
14+
private readonly ILogger<AddNotificationDefParameterCommandHandler> _logger;
15+
private readonly INotificationDefQueryRepository _notificationDefQueryRepository;
16+
private readonly INotificationDefCommandRepository _notificationDefCommandRepository;
17+
18+
public AddNotificationDefParameterCommandHandler(ILogger<AddNotificationDefParameterCommandHandler> logger, INotificationDefQueryRepository notificationDefQueryRepository, INotificationDefCommandRepository notificationDefCommandRepository)
19+
{
20+
_logger = logger;
21+
_notificationDefQueryRepository = notificationDefQueryRepository;
22+
_notificationDefCommandRepository = notificationDefCommandRepository;
23+
}
24+
25+
public async Task<string> Handle(AddNotificationDefParameterCommand request, CancellationToken cancellationToken)
26+
{
27+
var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);
28+
if (result == null)
29+
{
30+
_logger.LogError($"The notification definition '{request.Id}' doesn't exist");
31+
throw new UnknownHumanTaskDefException(string.Format(Global.UnknownNotification, request.Id));
32+
}
33+
34+
if (request.Parameter == null)
35+
{
36+
_logger.LogError($"The 'parameter' parameter is missing");
37+
throw new BadRequestException(string.Format(Global.MissingParameter, "parameter"));
38+
}
39+
40+
var id = result.AddOperationParameter(request.Parameter.ToDomain());
41+
await _notificationDefCommandRepository.Update(result, cancellationToken);
42+
await _notificationDefCommandRepository.SaveChanges(cancellationToken);
43+
_logger.LogInformation($"Notification '{result.Name}', operation parameter '{request.Parameter.Name}' has been added");
44+
return id;
45+
}
46+
}
47+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using CaseManagement.HumanTask.Exceptions;
2+
using CaseManagement.HumanTask.Persistence;
3+
using CaseManagement.HumanTask.Resources;
4+
using MediatR;
5+
using Microsoft.Extensions.Logging;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace CaseManagement.HumanTask.NotificationDef.Commands.Handlers
10+
{
11+
public class DeleteNotificationDefParameterCommandHandler : IRequestHandler<DeleteNotificationDefParameterCommand, bool>
12+
{
13+
private readonly ILogger<DeleteNotificationDefParameterCommandHandler> _logger;
14+
private readonly INotificationDefQueryRepository _notificationDefQueryRepository;
15+
private readonly INotificationDefCommandRepository _notificationDefCommandRepository;
16+
17+
public DeleteNotificationDefParameterCommandHandler(ILogger<DeleteNotificationDefParameterCommandHandler> logger, INotificationDefQueryRepository notificationDefQueryRepository, INotificationDefCommandRepository notificationDefCommandRepository)
18+
{
19+
_logger = logger;
20+
_notificationDefQueryRepository = notificationDefQueryRepository;
21+
_notificationDefCommandRepository = notificationDefCommandRepository;
22+
}
23+
24+
public async Task<bool> Handle(DeleteNotificationDefParameterCommand request, CancellationToken cancellationToken)
25+
{
26+
var result = await _notificationDefQueryRepository.Get(request.Id, cancellationToken);
27+
if (result == null)
28+
{
29+
_logger.LogError($"The notification definition '{request.Id}' doesn't exist");
30+
throw new UnknownNotificationDefException(string.Format(Global.UnknownNotification, request.Id));
31+
}
32+
33+
result.DeleteOperationParameter(request.ParameterId);
34+
await _notificationDefCommandRepository.Update(result, cancellationToken);
35+
await _notificationDefCommandRepository.SaveChanges(cancellationToken);
36+
_logger.LogInformation($"Notification definition '{result.Name}', operation parameter '{request.ParameterId}' has been removed");
37+
return true;
38+
}
39+
}
40+
}

src/CaseManagement.HumanTask/NotificationDef/Results/NotificationDefResult.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ public static NotificationDefResult ToDto(NotificationDefinitionAggregate notifi
2323
{
2424
return new NotificationDefResult
2525
{
26-
26+
CreateDateTime = notificationDef.CreateDateTime,
27+
Id = notificationDef.AggregateId,
28+
Name = notificationDef.Name,
29+
NbInstances = notificationDef.NbInstances,
30+
Priority = notificationDef.Priority,
31+
UpdateDateTime = notificationDef.UpdateDateTime,
32+
Version = notificationDef.Version,
2733
OperationParameters = notificationDef.OperationParameters.Select(_ => ParameterResult.ToDto(_)).ToList(),
2834
PeopleAssignments = notificationDef.PeopleAssignments.Select(_ => PeopleAssignmentDefinitionResult.ToDto(_)).ToList(),
2935
PresentationElements = notificationDef.PresentationElements.Select(_ => PresentationElementDefinitionResult.ToDto(_)).ToList(),
@@ -33,6 +39,7 @@ public static NotificationDefResult ToDto(NotificationDefinitionAggregate notifi
3339

3440
public class ParameterResult
3541
{
42+
public string Id { get; set; }
3643
public string Name { get; set; }
3744
public string Type { get; set; }
3845
public bool IsRequired { get; set; }
@@ -42,6 +49,7 @@ public static ParameterResult ToDto(Parameter par)
4249
{
4350
return new ParameterResult
4451
{
52+
Id = par.Id,
4553
IsRequired = par.IsRequired,
4654
Name = par.Name,
4755
Type = Enum.GetName(typeof(ParameterTypes), par.Type),

src/CaseManagement.Website/CaseManagement.Website.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@
3333
<None Remove="angularApp\app\humantasks\viewdef\rendering\components\txt\txt.component.scss" />
3434
<None Remove="angularApp\app\humantasks\viewdef\rendering\components\txt\txt.component.ts" />
3535
<None Remove="angularApp\app\humantasks\viewdef\rendering\guidgenerator.ts" />
36+
<None Remove="angularApp\app\notifications\viewdef\info\addassignment.dialog.component.html" />
37+
<None Remove="angularApp\app\notifications\viewdef\info\addassignment.dialog.component.scss" />
38+
<None Remove="angularApp\app\notifications\viewdef\info\addparameter.dialog.component.html" />
39+
<None Remove="angularApp\app\notifications\viewdef\info\addparameter.dialog.component.scss" />
3640
<None Remove="angularApp\app\shared\SidenavService.ts" />
3741
<None Remove="angularApp\app\stores\bpmninstances\models\bpmn-instance.model.ts" />
42+
<None Remove="angularApp\app\stores\notificationdefs\models\notificationdef.model.ts" />
3843
</ItemGroup>
3944
<ItemGroup>
4045
<PackageReference Include="Microsoft.AspNetCore.App" />
@@ -114,7 +119,16 @@
114119
</TypeScriptCompile>
115120
<TypeScriptCompile Include="angularApp\app\humantasks\viewdef\rendering\components\txt\txt.component.ts" />
116121
<TypeScriptCompile Include="angularApp\app\humantasks\viewdef\rendering\guidgenerator.ts" />
122+
<TypeScriptCompile Include="angularApp\app\notifications\viewdef\info\addassignment.dialog.component.html" />
123+
<TypeScriptCompile Include="angularApp\app\notifications\viewdef\info\addassignment.dialog.component.scss">
124+
<SubType>Code</SubType>
125+
</TypeScriptCompile>
126+
<TypeScriptCompile Include="angularApp\app\notifications\viewdef\info\addparameter.dialog.component.html" />
127+
<TypeScriptCompile Include="angularApp\app\notifications\viewdef\info\addparameter.dialog.component.scss">
128+
<SubType>Code</SubType>
129+
</TypeScriptCompile>
117130
<TypeScriptCompile Include="angularApp\app\shared\SidenavService.ts" />
118131
<TypeScriptCompile Include="angularApp\app\stores\bpmninstances\models\bpmn-instance.model.ts" />
132+
<TypeScriptCompile Include="angularApp\app\stores\notificationdefs\models\notificationdef.model.ts" />
119133
</ItemGroup>
120134
</Project>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<a *ngIf="isConnected" [routerLink]="['/bpmns']" mat-list-item href="#">{{ "MENU.PROCESSES" | translate }}</a>
66
<a *ngIf="isConnected" [routerLink]="['/cmmns']" mat-list-item href="#">{{ "MENU.CASES" | translate }}</a>
77
<a *ngIf="isConnected" [routerLink]="['/humantasks']" mat-list-item href="#">{{ "MENU.HUMANTASKS" | translate }}</a>
8+
<a *ngIf="isConnected" [routerLink]="['/notifications']" mat-list-item href="#">{{ "MENU.NOTIFICATIONS" | translate }}</a>
89
<a href="#" *ngIf="!isConnected" (click)="login($event)" mat-button>{{ "MENU.AUTHENTICATE" | translate }}</a>
910
<a href="#" *ngIf="!isConnected" (click)="chooseSession($event)" mat-button>{{ "MENU.CHOOSE_SESSION" | translate }}</a>
1011
</mat-list>
@@ -20,6 +21,7 @@
2021
<a *ngIf="isConnected" [routerLink]="['/bpmns']" mat-button href="#">{{ "MENU.PROCESSES" | translate }}</a>
2122
<a *ngIf="isConnected" [routerLink]="['/cmmns']" mat-button href="#">{{ "MENU.CASES" | translate }}</a>
2223
<a *ngIf="isConnected" [routerLink]="['/humantasks']" mat-button href="#">{{ "MENU.HUMANTASKS" | translate }}</a>
24+
<a *ngIf="isConnected" [routerLink]="['/notifications']" mat-button href="#">{{ "MENU.NOTIFICATIONS" | translate }}</a>
2325
</div>
2426
<span class="navigation-spacer"></span>
2527
<div fxShow="true" fxHide.lt-md="true">

0 commit comments

Comments
 (0)