Skip to content

Commit 3192efc

Browse files
committed
[feat] 1. adapter to mongodb 2. fix word mistake
1 parent 280dea7 commit 3192efc

File tree

48 files changed

+943
-316
lines changed

Some content is hidden

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

48 files changed

+943
-316
lines changed

src/Passingwind.Abp.ElsaModule.Application.Contracts/Workflow/ActivityConnectionCreateDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public class ActivityConnectionCreateDto
88
public Guid SourceId { get; set; }
99
public Guid TargetId { get; set; }
1010
public string Outcome { get; set; }
11-
public Dictionary<string, object> Arrtibutes { get; set; }
11+
public Dictionary<string, object> Attributes { get; set; }
1212
}
1313
}

src/Passingwind.Abp.ElsaModule.Application.Contracts/Workflow/ActivityConnectionDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public class ActivityConnectionDto : CreationAuditedEntityDto
99
public Guid SourceId { get; set; }
1010
public Guid TargetId { get; set; }
1111
public string Outcome { get; set; }
12-
public Dictionary<string, object> Arrtibutes { get; set; }
12+
public Dictionary<string, object> Attributes { get; set; }
1313
}
1414
}

src/Passingwind.Abp.ElsaModule.Application.Contracts/Workflow/ActivityCreateOrUpdateDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ActivityCreateOrUpdateDto
2323
public bool LoadWorkflowContext { get; set; }
2424
public bool SaveWorkflowContext { get; set; }
2525

26-
public Dictionary<string, object> Arrtibutes { get; set; }
26+
public Dictionary<string, object> Attributes { get; set; }
2727

2828
public List<ActivityDefinitionProperty> Properties { get; set; }
2929

src/Passingwind.Abp.ElsaModule.Application.Contracts/Workflow/ActivityDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ActivityDto : AuditedEntityDto
1818
public bool LoadWorkflowContext { get; set; }
1919
public bool SaveWorkflowContext { get; set; }
2020

21-
public Dictionary<string, object> Arrtibutes { get; set; }
21+
public Dictionary<string, object> Attributes { get; set; }
2222

2323
public List<ActivityDefinitionProperty> Properties { get; set; }
2424

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Threading.Tasks;
23
using Volo.Abp.Application.Dtos;
34
using Volo.Abp.Application.Services;
@@ -6,7 +7,7 @@ namespace Passingwind.Abp.ElsaModule.Common
67
{
78
public interface IWorkflowExecutionLogAppService : IApplicationService
89
{
9-
Task<WorkflowExecutionLogDto> GetAsync(long id);
10+
Task<WorkflowExecutionLogDto> GetAsync(Guid id);
1011
Task<PagedResultDto<WorkflowExecutionLogDto>> GetListAsync(WorkflowExecutionLogListRequestDto input);
1112
}
1213
}

src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowExecutionLog/WorkflowExecutionLogDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Passingwind.Abp.ElsaModule.Common
66
{
7-
public class WorkflowExecutionLogDto : CreationAuditedEntityDto<long>
7+
public class WorkflowExecutionLogDto : CreationAuditedEntityDto<Guid>
88
{
99
public Guid WorkflowInstanceId { get; set; }
1010
public Guid ActivityId { get; set; }

src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowInstances/WorkflowInstanceBasicDto.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ namespace Passingwind.Abp.ElsaModule.WorkflowInstances
66
{
77
public class WorkflowInstanceBasicDto : AuditedEntityDto<Guid>
88
{
9-
public Guid DefinitionId { get; set; }
10-
public Guid DefinitionVersionId { get; set; }
9+
public Guid WorkflowDefinitionId { get; set; }
10+
11+
public Guid WorkflowDefinitionVersionId { get; set; }
1112

1213
public string Name { get; set; }
1314
public int Version { get; set; }

src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowInstances/WorkflowInstanceDto.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ namespace Passingwind.Abp.ElsaModule.WorkflowInstances
88
{
99
public class WorkflowInstanceDto : AuditedEntityDto<Guid>
1010
{
11-
public Guid DefinitionId { get; set; }
12-
public Guid DefinitionVersionId { get; set; }
11+
public Guid WorkflowDefinitionId { get; set; }
12+
13+
public Guid WorkflowDefinitionVersionId { get; set; }
1314

1415
public string Name { get; set; }
1516
public int Version { get; set; }
Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using AutoMapper;
22
using Elsa.Metadata;
3+
using Newtonsoft.Json.Linq;
34
using Passingwind.Abp.ElsaModule.Common;
45
using Passingwind.Abp.ElsaModule.Designer;
56
using Passingwind.Abp.ElsaModule.Workflow;
@@ -17,42 +18,44 @@ public ElsaModuleApplicationAutoMapperProfile()
1718
* Alternatively, you can split your mapping configurations
1819
* into multiple profile classes for a better organization. */
1920

20-
CreateMap<WorkflowDefinitionCreateOrUpdateDto, WorkflowDefinition>()
21-
.Ignore(x => x.TenantId)
22-
.Ignore(x => x.LatestVersion)
23-
.Ignore(x => x.PublishedVersion)
24-
.Ignore(x => x.Id)
25-
.Ignore(x => x.ContextOptions)
26-
.Ignore(x => x.CustomAttributes)
27-
.Ignore(x => x.Variables)
28-
.IgnoreFullAuditedObjectProperties();
21+
//CreateMap<WorkflowDefinitionCreateOrUpdateDto, WorkflowDefinition>()
22+
// .Ignore(x => x.TenantId)
23+
// .Ignore(x => x.LatestVersion)
24+
// .Ignore(x => x.PublishedVersion)
25+
// .Ignore(x => x.Id)
26+
// .Ignore(x => x.ContextOptions)
27+
// .Ignore(x => x.CustomAttributes)
28+
// .Ignore(x => x.Variables)
29+
// .Ignore(x => x.ConcurrencyStamp)
30+
// .Ignore(x => x.ExtraProperties)
31+
// .IgnoreFullAuditedObjectProperties();
2932

30-
CreateMap<WorkflowDefinitionVersionCreateOrUpdateDto, WorkflowDefinitionVersion>()
31-
.Ignore(x => x.TenantId)
32-
//.Ignore(x => x.Definition)
33-
.Ignore(x => x.DefinitionId)
34-
.Ignore(x => x.Id)
35-
.Ignore(x => x.IsLatest)
36-
//.Ignore(x => x.IsPublished)
37-
.Ignore(x => x.Version)
38-
.IgnoreFullAuditedObjectProperties();
33+
//CreateMap<WorkflowDefinitionVersionCreateOrUpdateDto, WorkflowDefinitionVersion>()
34+
// .Ignore(x => x.TenantId)
35+
// //.Ignore(x => x.Definition)
36+
// .Ignore(x => x.DefinitionId)
37+
// .Ignore(x => x.Id)
38+
// .Ignore(x => x.IsLatest)
39+
// //.Ignore(x => x.IsPublished)
40+
// .Ignore(x => x.Version)
41+
// .IgnoreFullAuditedObjectProperties();
3942

4043
CreateMap<WorkflowDefinitionVersion, WorkflowDefinitionVersionListItemDto>();
4144
CreateMap<WorkflowDefinition, WorkflowDefinitionDto>();
4245
CreateMap<WorkflowDefinitionVersion, WorkflowDefinitionVersionDto>()
4346
.Ignore(x => x.Definition);
4447

45-
CreateMap<ActivityCreateOrUpdateDto, Activity>()
46-
.Ignore(x => x.DefinitionVersionId)
47-
.IgnoreAuditedObjectProperties();
48+
//CreateMap<ActivityCreateOrUpdateDto, Activity>()
49+
// .Ignore(x => x.WorkflowDefinitionVersionId)
50+
// .IgnoreAuditedObjectProperties();
4851

49-
CreateMap<ActivityConnectionDto, ActivityConnection>()
50-
.Ignore(x => x.DefinitionVersionId)
51-
.IgnoreCreationAuditedObjectProperties();
52+
//CreateMap<ActivityConnectionDto, ActivityConnection>()
53+
// .Ignore(x => x.WorkflowDefinitionVersionId)
54+
// .IgnoreCreationAuditedObjectProperties();
5255

53-
CreateMap<ActivityConnectionCreateDto, ActivityConnection>()
54-
.Ignore(x => x.DefinitionVersionId)
55-
.IgnoreCreationAuditedObjectProperties();
56+
//CreateMap<ActivityConnectionCreateDto, ActivityConnection>()
57+
// .Ignore(x => x.WorkflowDefinitionVersionId)
58+
// .IgnoreCreationAuditedObjectProperties();
5659

5760
CreateMap<Activity, ActivityDto>();
5861
CreateMap<ActivityConnection, ActivityConnectionDto>();
@@ -62,7 +65,8 @@ public ElsaModuleApplicationAutoMapperProfile()
6265
CreateMap<WorkflowInstance, WorkflowInstanceDto>();
6366
CreateMap<WorkflowInstance, WorkflowInstanceBasicDto>();
6467

65-
CreateMap<WorkflowExecutionLog, WorkflowExecutionLogDto>();
68+
CreateMap<WorkflowExecutionLog, WorkflowExecutionLogDto>()
69+
.ForMember(x => x.Data, x => x.MapFrom(s => string.IsNullOrEmpty(s.Data) ? default : JObject.Parse(s.Data)));
6670

6771
}
6872
}

src/Passingwind.Abp.ElsaModule.Application/WorkflowDefinitions/WorkflowDefinitionAppService.cs

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Threading.Tasks;
55
using Elsa.Models;
66
using Elsa.Services;
7-
using Passingwind.Abp.ElsaModule.Workflow;
87
using Passingwind.Abp.ElsaModule.WorkflowDefinitions;
98
using Volo.Abp;
109
using Volo.Abp.Application.Dtos;
@@ -29,24 +28,54 @@ public WorkflowDefinitionAppService(IWorkflowDefinitionRepository workflowDefini
2928

3029
public virtual async Task<WorkflowDefinitionVersionDto> CreateAsync(WorkflowDefinitionVersionCreateOrUpdateDto input)
3130
{
32-
WorkflowDefinition defintion = ObjectMapper.Map<WorkflowDefinitionCreateOrUpdateDto, WorkflowDefinition>(input.Definition);
33-
WorkflowDefinitionVersion version = ObjectMapper.Map<WorkflowDefinitionVersionCreateOrUpdateDto, WorkflowDefinitionVersion>(input);
31+
WorkflowDefinition defintion = await _workflowDefinitionManager.CreateDefinitionAsync(
32+
input.Definition.Name,
33+
input.Definition.DisplayName,
34+
CurrentTenant.Id,
35+
input.Definition.Description,
36+
input.Definition.IsSingleton,
37+
input.Definition.DeleteCompletedInstances,
38+
input.Definition.Channel,
39+
input.Definition.Tag,
40+
input.Definition.PersistenceBehavior,
41+
input.Definition.ContextOptions,
42+
input.Definition.Variables,
43+
default
44+
);
45+
defintion.SetVersion(1, null);
46+
47+
WorkflowDefinitionVersion version = await _workflowDefinitionManager.CreateDefinitionVersionAsync(
48+
defintion.Id,
49+
CurrentTenant.Id,
50+
input.Activities?.Select(x => new Activity(
51+
x.ActivityId,
52+
x.Type,
53+
x.Name,
54+
x.DisplayName,
55+
x.Description,
56+
x.PersistWorkflow,
57+
x.LoadWorkflowContext,
58+
x.SaveWorkflowContext,
59+
x.Attributes,
60+
x.Properties,
61+
x.PropertyStorageProviders))?.ToList(),
62+
input.Connections.Select(x => new ActivityConnection(
63+
x.SourceId,
64+
x.TargetId,
65+
x.Outcome,
66+
x.Attributes))?.ToList()
67+
);
3468

3569
version.SetIsLatest(true);
3670

37-
defintion.SetVersion(version.Version, null);
38-
3971
if (input.IsPublished)
4072
{
4173
version.SetIsPublished(true);
4274
defintion.SetVersion(version.Version, version.Version);
4375
}
4476

45-
defintion.SetId(GuidGenerator.Create());
46-
version.SetDefinitionId(defintion.Id);
47-
4877
defintion = await _workflowDefinitionRepository.InsertAsync(defintion);
49-
await _workflowDefinitionVersionRepository.InsertAsync(version);
78+
version = await _workflowDefinitionVersionRepository.InsertAsync(version);
5079

5180
var dto = ObjectMapper.Map<WorkflowDefinitionVersion, WorkflowDefinitionVersionDto>(version);
5281
dto.Definition = ObjectMapper.Map<WorkflowDefinition, WorkflowDefinitionDto>(defintion);
@@ -142,7 +171,26 @@ public virtual async Task<WorkflowDefinitionVersionDto> UpdateAsync(Guid id, Wor
142171
{
143172
await _workflowDefinitionManager.UnsetLatestVersionAsync(id);
144173

145-
currentVersion = await _workflowDefinitionManager.CreateDefinitionVersionAsync(id, CurrentTenant.Id, ObjectMapper.Map<List<ActivityCreateOrUpdateDto>, List<Activity>>(input.Activities), ObjectMapper.Map<List<ActivityConnectionCreateDto>, List<ActivityConnection>>(input.Connections));
174+
currentVersion = await _workflowDefinitionManager.CreateDefinitionVersionAsync(
175+
id,
176+
CurrentTenant.Id,
177+
input.Activities?.Select(x => new Activity(
178+
x.ActivityId,
179+
x.Type,
180+
x.Name,
181+
x.DisplayName,
182+
x.Description,
183+
x.PersistWorkflow,
184+
x.LoadWorkflowContext,
185+
x.SaveWorkflowContext,
186+
x.Attributes,
187+
x.Properties,
188+
x.PropertyStorageProviders))?.ToList(),
189+
input.Connections.Select(x => new ActivityConnection(
190+
x.SourceId,
191+
x.TargetId,
192+
x.Outcome,
193+
x.Attributes))?.ToList());
146194

147195
currentVersion.SetVersion(defintion.LatestVersion + 1);
148196
currentVersion.SetIsLatest(true);
@@ -163,7 +211,23 @@ public virtual async Task<WorkflowDefinitionVersionDto> UpdateAsync(Guid id, Wor
163211
if (currentVersion == null)
164212
throw new UserFriendlyException($"The latest versiont '{defintion.LatestVersion}' not found.");
165213

166-
currentVersion = ObjectMapper.Map<WorkflowDefinitionVersionCreateOrUpdateDto, WorkflowDefinitionVersion>(input, currentVersion);
214+
await _workflowDefinitionManager.UpdateDefinitionVersionAsync(currentVersion, input.Activities?.Select(x => new Activity(
215+
x.ActivityId,
216+
x.Type,
217+
x.Name,
218+
x.DisplayName,
219+
x.Description,
220+
x.PersistWorkflow,
221+
x.LoadWorkflowContext,
222+
x.SaveWorkflowContext,
223+
x.Attributes,
224+
x.Properties,
225+
x.PropertyStorageProviders))?.ToList(),
226+
input.Connections.Select(x => new ActivityConnection(
227+
x.SourceId,
228+
x.TargetId,
229+
x.Outcome,
230+
x.Attributes))?.ToList());
167231

168232
if (input.IsPublished)
169233
{

0 commit comments

Comments
 (0)