Editing a template version is now immutable.
This commit is contained in:
parent
007522ceba
commit
9a360feb7f
@ -19,12 +19,12 @@ public class WorkflowVersion : IGeneralId, ISoftDeletable
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public Guid Guid { get; set; }
|
public Guid Guid { get; set; } = Guid.NewGuid();
|
||||||
|
|
||||||
public long WorkflowId { get; set; }
|
public long WorkflowId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public long Version { get; set; } = 0;
|
public long Version { get; set; } = 1;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public long DomainId { get; set; }
|
public long DomainId { get; set; }
|
||||||
|
|||||||
@ -100,14 +100,21 @@ public class WorkflowTemplateManager : IWorkflowTemplateManager
|
|||||||
{
|
{
|
||||||
var domain = await _domainRepository.GetDomainById(template.DomainId!, cancellationToken) ?? throw new NotFoundException("Unable to find Domain with provided id");
|
var domain = await _domainRepository.GetDomainById(template.DomainId!, cancellationToken) ?? throw new NotFoundException("Unable to find Domain with provided id");
|
||||||
|
|
||||||
version.Domain = domain;
|
var workflow = version.Workflow;
|
||||||
version.DomainId = domain.Id;
|
workflow.Name = template.WorkflowName;
|
||||||
version.Description = template.Description;
|
|
||||||
version.ActivityNameTemplate = template.ActivityNameTemplate;
|
var newVersion = new e_suite.Database.Core.Tables.Workflow.WorkflowVersion
|
||||||
version.Deleted = false;
|
{
|
||||||
version.Version = template.Version+1;
|
Domain = domain,
|
||||||
version.Tasks = template.Tasks;
|
DomainId = domain.Id,
|
||||||
version.Workflow.Name = template.WorkflowName;
|
Description = template.Description,
|
||||||
|
ActivityNameTemplate = template.ActivityNameTemplate,
|
||||||
|
Deleted = false,
|
||||||
|
Version = template.Version + 1,
|
||||||
|
Tasks = template.Tasks,
|
||||||
|
Workflow = workflow
|
||||||
|
};
|
||||||
|
return newVersion;
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +129,7 @@ public class WorkflowTemplateManager : IWorkflowTemplateManager
|
|||||||
await AlterWorkflowTemplateVersionAsync(auditUserDetails, templateId, async version =>
|
await AlterWorkflowTemplateVersionAsync(auditUserDetails, templateId, async version =>
|
||||||
{
|
{
|
||||||
await patch.ApplyTo(version);
|
await patch.ApplyTo(version);
|
||||||
|
return version;
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,13 +159,11 @@ public class WorkflowTemplateManager : IWorkflowTemplateManager
|
|||||||
|
|
||||||
var dbWorkflowTemplate = new WorkflowVersion
|
var dbWorkflowTemplate = new WorkflowVersion
|
||||||
{
|
{
|
||||||
Guid = Guid.NewGuid(),
|
|
||||||
ActivityNameTemplate = template.ActivityNameTemplate,
|
ActivityNameTemplate = template.ActivityNameTemplate,
|
||||||
Description = template.Description,
|
Description = template.Description,
|
||||||
Domain = workflowDomain,
|
Domain = workflowDomain,
|
||||||
Tasks = template.Tasks,
|
Tasks = template.Tasks,
|
||||||
Workflow = workflow,
|
Workflow = workflow,
|
||||||
Version = 1
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//This will attempt to parse the data onto the internal workflow structure.
|
//This will attempt to parse the data onto the internal workflow structure.
|
||||||
@ -179,23 +185,31 @@ public class WorkflowTemplateManager : IWorkflowTemplateManager
|
|||||||
await AlterWorkflowTemplateVersionAsync(auditUserDetails, templateId, async version =>
|
await AlterWorkflowTemplateVersionAsync(auditUserDetails, templateId, async version =>
|
||||||
{
|
{
|
||||||
version.Deleted = true;
|
version.Deleted = true;
|
||||||
|
return version;
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AlterWorkflowTemplateVersionAsync(
|
private async Task AlterWorkflowTemplateVersionAsync(
|
||||||
AuditUserDetails auditUserDetails,
|
AuditUserDetails auditUserDetails,
|
||||||
IGeneralIdRef generalIdRef,
|
IGeneralIdRef generalIdRef,
|
||||||
Func<e_suite.Database.Core.Tables.Workflow.WorkflowVersion, Task> applyChanges,
|
Func<e_suite.Database.Core.Tables.Workflow.WorkflowVersion,
|
||||||
|
Task<e_suite.Database.Core.Tables.Workflow.WorkflowVersion?>> applyChanges,
|
||||||
CancellationToken cancellationToken
|
CancellationToken cancellationToken
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
await _workflowTemplateRepository.TransactionAsync(async () =>
|
await _workflowTemplateRepository.TransactionAsync(async () =>
|
||||||
{
|
{
|
||||||
var workflowVersion = await _workflowTemplateRepository.GetWorkflowVersions().FindByGeneralIdRefAsync(generalIdRef, cancellationToken) ?? throw new NotFoundException("SsoProvider with this id does not exists");
|
var workflowVersion =
|
||||||
|
await _workflowTemplateRepository.GetWorkflowVersions()
|
||||||
|
.FindByGeneralIdRefAsync(generalIdRef, cancellationToken) ??
|
||||||
|
throw new NotFoundException("SsoProvider with this id does not exists");
|
||||||
|
|
||||||
await applyChanges(workflowVersion);
|
var newVersion = await applyChanges(workflowVersion);
|
||||||
|
if (newVersion != workflowVersion)
|
||||||
await _workflowTemplateRepository.EditWorkflowVersionAsync(auditUserDetails, workflowVersion, cancellationToken);
|
await _workflowTemplateRepository.AddWorkflowVersion(auditUserDetails, newVersion, cancellationToken);
|
||||||
|
else
|
||||||
|
await _workflowTemplateRepository.EditWorkflowVersionAsync(auditUserDetails, workflowVersion,
|
||||||
|
cancellationToken);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user