Skip to content

Commit aa4802c

Browse files
committed
2 parents 0931aab + db43cc1 commit aa4802c

File tree

11 files changed

+64
-22
lines changed

11 files changed

+64
-22
lines changed

src/WorkflowCore/Services/DefinitionStorage/DefinitionLoader.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public DefinitionLoader(IWorkflowRegistry registry)
2525
{
2626
_registry = registry;
2727
}
28-
28+
2929
public WorkflowDefinition LoadDefinition(string source, Func<string, DefinitionSourceV1> deserializer)
3030
{
3131
var sourceObj = deserializer(source);
@@ -119,7 +119,7 @@ private WorkflowStepCollection ConvertSteps(ICollection<StepSourceV1> source, Ty
119119
targetStep.Outcomes.Add(new StepOutcome() { ExternalNextStepId = $"{nextStep.NextStepId}" });
120120

121121
result.Add(targetStep);
122-
122+
123123
i++;
124124
}
125125

@@ -176,6 +176,11 @@ private void AttachInputs(StepSourceV1 source, Type dataType, Type stepType, Wor
176176
var environmentVarsParameter = Expression.Parameter(typeof(IDictionary), "environment");
177177
var stepProperty = stepType.GetProperty(input.Key);
178178

179+
if (stepProperty == null)
180+
{
181+
throw new ArgumentException($"Unknown property for input {input.Key} on {source.Id}");
182+
}
183+
179184
if (input.Value is string)
180185
{
181186
var acn = BuildScalarInputAction(input, dataParameter, contextParameter, environmentVarsParameter, stepProperty);
@@ -203,7 +208,7 @@ private void AttachOutputs(StepSourceV1 source, Type dataType, Type stepType, Wo
203208

204209
var dataParameter = Expression.Parameter(dataType, "data");
205210
Expression targetProperty;
206-
211+
207212
// Check if our datatype has a matching property
208213
var propertyInfo = dataType.GetProperty(output.Key);
209214
if (propertyInfo != null)
@@ -217,7 +222,7 @@ private void AttachOutputs(StepSourceV1 source, Type dataType, Type stepType, Wo
217222
// If we did not find a matching property try to find a Indexer with string parameter
218223
propertyInfo = dataType.GetProperty("Item");
219224
targetProperty = Expression.Property(dataParameter, propertyInfo, Expression.Constant(output.Key));
220-
225+
221226
Action<IStepBody, object> acn = (pStep, pData) =>
222227
{
223228
object resolvedValue = sourceExpr.Compile().DynamicInvoke(pStep); ;

src/providers/WorkflowCore.Persistence.PostgreSQL/MigrationContextFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class MigrationContextFactory : IDesignTimeDbContextFactory<PostgresConte
77
{
88
public PostgresContext CreateDbContext(string[] args)
99
{
10-
return new PostgresContext(@"Server=127.0.0.1;Port=5432;Database=workflow;User Id=postgres;Password=password;");
10+
return new PostgresContext(@"Server=127.0.0.1;Port=5432;Database=workflow;User Id=postgres;Password=password;","wfc");
1111
}
1212
}
1313
}

src/providers/WorkflowCore.Persistence.PostgreSQL/PostgresContext.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ namespace WorkflowCore.Persistence.PostgreSQL
1212
public class PostgresContext : WorkflowDbContext
1313
{
1414
private readonly string _connectionString;
15+
private readonly string _schemaName;
1516

16-
public PostgresContext(string connectionString)
17+
public PostgresContext(string connectionString,string schemaName)
1718
:base()
1819
{
1920
_connectionString = connectionString;
21+
_schemaName = schemaName;
2022
}
2123

2224
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
@@ -27,37 +29,37 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2729

2830
protected override void ConfigureSubscriptionStorage(EntityTypeBuilder<PersistedSubscription> builder)
2931
{
30-
builder.ToTable("Subscription", "wfc");
32+
builder.ToTable("Subscription", _schemaName);
3133
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
3234
}
3335

3436
protected override void ConfigureWorkflowStorage(EntityTypeBuilder<PersistedWorkflow> builder)
3537
{
36-
builder.ToTable("Workflow", "wfc");
38+
builder.ToTable("Workflow", _schemaName);
3739
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
3840
}
3941

4042
protected override void ConfigureExecutionPointerStorage(EntityTypeBuilder<PersistedExecutionPointer> builder)
4143
{
42-
builder.ToTable("ExecutionPointer", "wfc");
44+
builder.ToTable("ExecutionPointer", _schemaName);
4345
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
4446
}
4547

4648
protected override void ConfigureExecutionErrorStorage(EntityTypeBuilder<PersistedExecutionError> builder)
4749
{
48-
builder.ToTable("ExecutionError", "wfc");
50+
builder.ToTable("ExecutionError", _schemaName);
4951
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
5052
}
5153

5254
protected override void ConfigureExetensionAttributeStorage(EntityTypeBuilder<PersistedExtensionAttribute> builder)
5355
{
54-
builder.ToTable("ExtensionAttribute", "wfc");
56+
builder.ToTable("ExtensionAttribute", _schemaName);
5557
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
5658
}
5759

5860
protected override void ConfigureEventStorage(EntityTypeBuilder<PersistedEvent> builder)
5961
{
60-
builder.ToTable("Event", "wfc");
62+
builder.ToTable("Event", _schemaName);
6163
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
6264
}
6365
}

src/providers/WorkflowCore.Persistence.PostgreSQL/PostgresContextFactory.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ namespace WorkflowCore.Persistence.PostgreSQL
99
public class PostgresContextFactory : IWorkflowDbContextFactory
1010
{
1111
private readonly string _connectionString;
12+
private readonly string _schemaName;
1213

13-
public PostgresContextFactory(string connectionString)
14+
public PostgresContextFactory(string connectionString, string schemaName)
1415
{
1516
_connectionString = connectionString;
17+
_schemaName = schemaName;
1618
}
1719

1820
public WorkflowDbContext Build()
1921
{
20-
return new PostgresContext(_connectionString);
22+
return new PostgresContext(_connectionString,_schemaName);
2123
}
2224
}
2325
}

src/providers/WorkflowCore.Persistence.PostgreSQL/ServiceCollectionExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ namespace Microsoft.Extensions.DependencyInjection
1010
{
1111
public static class ServiceCollectionExtensions
1212
{
13-
public static WorkflowOptions UsePostgreSQL(this WorkflowOptions options, string connectionString, bool canCreateDB, bool canMigrateDB)
13+
public static WorkflowOptions UsePostgreSQL(this WorkflowOptions options,
14+
string connectionString, bool canCreateDB, bool canMigrateDB, string schemaName="wfc")
1415
{
15-
options.UsePersistence(sp => new EntityFrameworkPersistenceProvider(new PostgresContextFactory(connectionString), canCreateDB, canMigrateDB));
16+
options.UsePersistence(sp => new EntityFrameworkPersistenceProvider(new PostgresContextFactory(connectionString, schemaName), canCreateDB, canMigrateDB));
1617
return options;
1718
}
1819
}

src/providers/WorkflowCore.Persistence.PostgreSQL/WorkflowCore.Persistence.PostgreSQL.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
1616
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
1717
<Description>Provides support to persist workflows running on Workflow Core to a PostgreSQL database.</Description>
18-
<Version>2.0.1</Version>
19-
<AssemblyVersion>2.0.1.0</AssemblyVersion>
20-
<FileVersion>2.0.1.0</FileVersion>
18+
<Version>2.0.2</Version>
19+
<AssemblyVersion>2.0.2.0</AssemblyVersion>
20+
<FileVersion>2.0.2.0</FileVersion>
2121
</PropertyGroup>
2222

2323
<ItemGroup>

test/WorkflowCore.TestAssets/Utils.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace WorkflowCore.TestAssets
1010
public static class Utils
1111
{
1212
private static JsonSerializerSettings SerializerSettings = new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All, DateFormatHandling = DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = DateTimeZoneHandling.Utc };
13-
13+
1414
public static T DeepCopy<T>(T obj)
1515
{
1616
string str = JsonConvert.SerializeObject(obj, SerializerSettings);
@@ -32,6 +32,11 @@ public static string GetTestDefinitionDynamicJson()
3232
{
3333
return File.ReadAllText("stored-dynamic-definition.json");
3434
}
35+
36+
public static string GetTestDefinitionJsonMissingInputProperty()
37+
{
38+
return File.ReadAllText("stored-def-missing-input-property.json");
39+
}
3540
}
3641
}
3742

test/WorkflowCore.TestAssets/WorkflowCore.TestAssets.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<EmbeddedResource Include="stored-definition.json">
2626
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2727
</EmbeddedResource>
28+
<EmbeddedResource Include="stored-def-missing-input-property.json">
29+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
30+
</EmbeddedResource>
2831
</ItemGroup>
2932

3033
<ItemGroup>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"Id": "Test",
3+
"Version": 1,
4+
"Description": "",
5+
"DataType": "WorkflowCore.TestAssets.DataTypes.CounterBoard, WorkflowCore.TestAssets",
6+
"Steps": [
7+
{
8+
"Id": "Step1",
9+
"StepType": "WorkflowCore.TestAssets.Steps.Counter, WorkflowCore.TestAssets",
10+
"ErrorBehavior": "Retry",
11+
"Inputs": {
12+
"Value1": "data.Counter1"
13+
},
14+
"Outputs": {
15+
"Counter1": "step.Value"
16+
}
17+
}
18+
]
19+
}

test/WorkflowCore.Tests.PostgreSQL/PostgresPersistenceProviderFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class PostgresPersistenceProviderFixture : BasePersistenceFixture
1919
public PostgresPersistenceProviderFixture(PostgresDockerSetup dockerSetup, ITestOutputHelper output)
2020
{
2121
output.WriteLine($"Connecting on {PostgresDockerSetup.ConnectionString}");
22-
_subject = new EntityFrameworkPersistenceProvider(new PostgresContextFactory(PostgresDockerSetup.ConnectionString), true, true);
22+
_subject = new EntityFrameworkPersistenceProvider(new PostgresContextFactory(PostgresDockerSetup.ConnectionString,"wfc"), true, true);
2323
_subject.EnsureStoreExists();
2424
}
2525
}

0 commit comments

Comments
 (0)