Skip to content

Commit f37dd67

Browse files
add DecisionOptionName to WorkflowEventEntity
1 parent 604d3d8 commit f37dd67

File tree

7 files changed

+39
-1
lines changed

7 files changed

+39
-1
lines changed

Signum.Engine.Extensions/Workflow/CaseActivityLogic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ private static void ExecuteBoundaryTimer(CaseActivityEntity ca, WorkflowEventEnt
11211121
}.Save();
11221122
break;
11231123
case WorkflowEventType.BoundaryInterruptingTimer:
1124-
ca.MakeDone(DoneType.Timeout, null);
1124+
ca.MakeDone(DoneType.Timeout, boundaryEvent.DecisionOptionName);
11251125
break;
11261126
default:
11271127
throw new InvalidOperationException("Unexpected Boundary Timer Type " + boundaryEvent.Type);

Signum.Engine.Extensions/Workflow/WorkflowNodeGraph.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Signum.Utilities.DataStructures;
33
using Signum.Entities.Authorization;
44
using Signum.Engine.Authorization;
5+
using Signum.Entities.Reflection;
56

67
namespace Signum.Engine.Workflow;
78

@@ -223,6 +224,19 @@ public void Validate(List<WorkflowIssue> issuesContainer, Action<WorkflowGateway
223224

224225
if (e.Type.IsTimer())
225226
{
227+
if (e.Type == WorkflowEventType.BoundaryInterruptingTimer)
228+
{
229+
var activity = Activities.GetOrThrow(e.BoundaryOf!);
230+
if (string.IsNullOrWhiteSpace(e.DecisionOptionName) && activity.Type == WorkflowActivityType.Decision)
231+
issues.AddError(e, WorkflowValidationMessage.BoundaryTimer0OfActivity1ShouldHave2BecauseActivityIs3.NiceToString(e, activity, e.NicePropertyName(a => a.DecisionOptionName), WorkflowActivityType.Decision.NiceToString()));
232+
233+
if (!string.IsNullOrWhiteSpace(e.DecisionOptionName) && activity.Type != WorkflowActivityType.Decision)
234+
issues.AddError(e, WorkflowValidationMessage.BoundaryTimer0OfActivity1CanNotHave2BecauseActivityIsNot3.NiceToString(e, activity, e.NicePropertyName(a => a.DecisionOptionName), WorkflowActivityType.Decision.NiceToString()));
235+
236+
if (!string.IsNullOrWhiteSpace(e.DecisionOptionName) && !activity.DecisionOptions.Any(a => a.Name == e.DecisionOptionName))
237+
issues.AddError(e, WorkflowValidationMessage.BoundaryTimer0OfActivity1HasInvalid23.NiceToString(e, activity, e.NicePropertyName(a => a.DecisionOptionName), e.DecisionOptionName));
238+
}
239+
226240
var boundaryOutput = NextConnections(e).Only();
227241

228242
if (boundaryOutput == null || boundaryOutput.Type != ConnectionType.Normal)

Signum.Entities.Extensions/Workflow/Workflow.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ public enum WorkflowValidationMessage
277277
DecisionOption0IsDeclaredButNeverUsedInAConnection,
278278
[Description("Decision option name '{0}' is not declared in any activity")]
279279
DecisionOptionName0IsNotDeclaredInAnyActivity,
280+
[Description("Boundary timer '{0}' of activity '{1}' can not have {2} because activity is not {3}")]
281+
BoundaryTimer0OfActivity1CanNotHave2BecauseActivityIsNot3,
282+
[Description("Boundary timer '{0}' of activity '{1}' should have {2} because activity is {3}")]
283+
BoundaryTimer0OfActivity1ShouldHave2BecauseActivityIs3,
284+
[Description("Boundary timer '{0}' of activity '{1}' has invalid {2}: '{3}'")]
285+
BoundaryTimer0OfActivity1HasInvalid23,
280286
}
281287

282288
public enum WorkflowActivityMonitorMessage

Signum.Entities.Extensions/Workflow/WorkflowActivity.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public ModelEntity GetModel()
126126
MainEntityType = we.Lane.Pool.Workflow.MainEntityType,
127127
Type = we.Type,
128128
RunRepeatedly = we.RunRepeatedly,
129+
DecisionOptionName = we.DecisionOptionName,
129130
Timer = we.Timer,
130131
BpmnElementId = we.BpmnElementId
131132
}).ToMList());

Signum.Entities.Extensions/Workflow/WorkflowEvent.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class WorkflowEventEntity : Entity, IWorkflowNodeEntity, IWithModel
1919

2020
public bool RunRepeatedly { get; set; }
2121

22+
[StringLengthValidator(Min = 3, Max = 100)]
23+
public string? DecisionOptionName { get; set; }
24+
2225
public WorkflowTimerEmbedded? Timer { get; set; }
2326

2427
public Lite<WorkflowActivityEntity>? BoundaryOf { get; set; }
@@ -37,6 +40,7 @@ public ModelEntity GetModel()
3740
Name = this.Name,
3841
Type = this.Type,
3942
RunRepeatedly = this.RunRepeatedly,
43+
DecisionOptionName = this.DecisionOptionName,
4044
Task = WorkflowEventTaskModel.GetModel(this),
4145
Timer = this.Timer,
4246
BpmnElementId = this.BpmnElementId,
@@ -51,6 +55,7 @@ public void SetModel(ModelEntity model)
5155
this.Name = wModel.Name;
5256
this.Type = wModel.Type;
5357
this.RunRepeatedly = wModel.RunRepeatedly;
58+
this.DecisionOptionName = wModel.DecisionOptionName;
5459
this.Timer = wModel.Timer;
5560
this.BpmnElementId = wModel.BpmnElementId;
5661
this.CopyMixinsFrom(wModel);
@@ -62,6 +67,9 @@ public void SetModel(ModelEntity model)
6267
if (pi.Name == nameof(RunRepeatedly) && RunRepeatedly && Type != WorkflowEventType.BoundaryForkTimer)
6368
RunRepeatedly = false;
6469

70+
if (pi.Name == nameof(DecisionOptionName) && !string.IsNullOrWhiteSpace(DecisionOptionName) && Type != WorkflowEventType.BoundaryInterruptingTimer)
71+
DecisionOptionName = null;
72+
6573
return base.PropertyValidation(pi);
6674
}
6775
}
@@ -146,6 +154,9 @@ public class WorkflowEventModel : ModelEntity
146154

147155
public bool RunRepeatedly { get; set; }
148156

157+
[StringLengthValidator(Min = 3, Max = 100)]
158+
public string? DecisionOptionName { get; set; }
159+
149160
public WorkflowEventTaskModel? Task { get; set; }
150161

151162
public WorkflowTimerEmbedded? Timer { get; set; }

Signum.React.Extensions/Workflow/Signum.Entities.Workflow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ export interface WorkflowEventEntity extends Entities.Entity, IWorkflowNodeEntit
503503
lane: WorkflowLaneEntity;
504504
type: WorkflowEventType;
505505
runRepeatedly: boolean;
506+
decisionOptionName: string | null;
506507
timer: WorkflowTimerEmbedded | null;
507508
boundaryOf: Entities.Lite<WorkflowActivityEntity> | null;
508509
xml: WorkflowXmlEmbedded;
@@ -515,6 +516,7 @@ export interface WorkflowEventModel extends Entities.ModelEntity {
515516
name: string | null;
516517
type: WorkflowEventType;
517518
runRepeatedly: boolean;
519+
decisionOptionName: string | null;
518520
task: WorkflowEventTaskModel | null;
519521
timer: WorkflowTimerEmbedded | null;
520522
bpmnElementId: string;
@@ -847,6 +849,9 @@ export module WorkflowValidationMessage {
847849
export const Join0OfType1DoesNotMatchWithItsPairTheSplit2OfType3 = new MessageKey("WorkflowValidationMessage", "Join0OfType1DoesNotMatchWithItsPairTheSplit2OfType3");
848850
export const DecisionOption0IsDeclaredButNeverUsedInAConnection = new MessageKey("WorkflowValidationMessage", "DecisionOption0IsDeclaredButNeverUsedInAConnection");
849851
export const DecisionOptionName0IsNotDeclaredInAnyActivity = new MessageKey("WorkflowValidationMessage", "DecisionOptionName0IsNotDeclaredInAnyActivity");
852+
export const BoundaryTimer0OfActivity1CanNotHave2BecauseActivityIsNot3 = new MessageKey("WorkflowValidationMessage", "BoundaryTimer0OfActivity1CanNotHave2BecauseActivityIsNot3");
853+
export const BoundaryTimer0OfActivity1ShouldHave2BecauseActivityIs3 = new MessageKey("WorkflowValidationMessage", "BoundaryTimer0OfActivity1ShouldHave2BecauseActivityIs3");
854+
export const BoundaryTimer0OfActivity1HasInvalid23 = new MessageKey("WorkflowValidationMessage", "BoundaryTimer0OfActivity1HasInvalid23");
850855
}
851856

852857
export const WorkflowXmlEmbedded = new Type<WorkflowXmlEmbedded>("WorkflowXmlEmbedded");

Signum.React.Extensions/Workflow/Workflow/WorkflowEventModel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export default function WorkflowEventModelComponent(p: WorkflowEventModelCompone
6262
<ValueLine ctx={ctx.subCtx(we => we.name)} />
6363
<ValueLine ctx={ctx.subCtx(we => we.type)} readOnly={isTimer(ctx.value.type!)} optionItems={getTypeComboItems()} onChange={loadTask} />
6464
{ctx.value.type == "BoundaryForkTimer" && <ValueLine ctx={ctx.subCtx(a => a.runRepeatedly)} />}
65+
{ctx.value.type == "BoundaryInterruptingTimer" && <ValueLine ctx={ctx.subCtx(a => a.decisionOptionName)} />}
6566
{ctx.value.task && <WorkflowEventTask ctx={ctx.subCtx(a => a.task!)} mainEntityType={ctx.value.mainEntityType} isConditional={isConditional()} />}
6667
{ctx.value.timer && <WorkflowTimer ctx={ctx.subCtx(a => a.timer!)} mainEntityType={ctx.value.mainEntityType}/>}
6768
</div>

0 commit comments

Comments
 (0)