Added correlation activity (#3530)

* Added correlation activity

* Changed the category from "Control Flow" to "Primitives"
This commit is contained in:
cristinamudura 2022-12-14 13:05:45 +01:00 committed by GitHub
parent a21ed913ff
commit bb9ebef362
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,15 @@
import {FunctionalComponent, h} from '@stencil/core';
import {ActivityIconSettings, getActivityIconCssClass} from "./models";
export const CorrelateIcon: FunctionalComponent<ActivityIconSettings> = (settings) => (
<svg class={getActivityIconCssClass(settings)} width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<circle cx="6" cy="6" r="2"/>
<circle cx="18" cy="18" r="2"/>
<path d="M11 6h5a2 2 0 0 1 2 2v8"/>
<polyline points="14 9 11 6 14 3"/>
<path d="M13 18h-5a2 2 0 0 1 -2 -2v-8"/>
<polyline points="10 15 13 18 10 21"/>
</svg>
);

View file

@ -15,3 +15,4 @@ export * from "./read-line";
export * from "./run-javascript";
export * from "./timer";
export * from "./write-line";
export * from "./correlate";

View file

@ -11,7 +11,8 @@ import {
IfIcon,
ReadLineIcon, WriteLineIcon,
RunJavaScriptIcon,
HttpEndpointIcon, HttpResponseIcon, HttpRequestIcon
HttpEndpointIcon, HttpResponseIcon, HttpRequestIcon,
CorrelateIcon
} from "../components/icons/activities";
export type ActivityType = string;
@ -39,6 +40,7 @@ export class ActivityIconRegistry {
this.add('Elsa.FlowJoin', settings => <FlowJoinIcon size={settings?.size}/>);
this.add('Elsa.FlowNode', settings => <FlowNodeIcon size={settings?.size}/>);
this.add('Elsa.SendHttpRequest', settings => <HttpRequestIcon size={settings?.size}/>);
this.add("Elsa.Correlate", settings => <CorrelateIcon size={settings?.size}/>)
}
public add(activityType: ActivityType, icon: ActivityIconProducer) {

View file

@ -0,0 +1,27 @@
using System.ComponentModel;
using System.Text.Json.Serialization;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Core.Models;
namespace Elsa.Workflows.Core.Activities;
[Activity("Elsa", "Primitives", "Set the CorrelationId of the workflow to a given value.")]
public class Correlate : Activity
{
[JsonConstructor]
public Correlate()
{
}
/// <summary>
/// The correlation ID to set.
/// </summary>
[Description("An expression that evaluates to the value to store as the correlation id")]
public Input<string> CorrelationId { get; set; } = default!;
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
var correlationId = context.Get(CorrelationId);
context.WorkflowExecutionContext.CorrelationId = correlationId;
}
}