-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use 'instanceandevents' endpoint when updating process state #937
Open
martinothamar
wants to merge
2
commits into
main
Choose a base branch
from
chore/use-instanceandevents-endpoint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+112
−213
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,11 @@ public interface IInstanceClient | |
/// </summary> | ||
Task<Instance> UpdateProcess(Instance instance); | ||
|
||
/// <summary> | ||
/// Updates the process model of the instance and the instance events and returns the updated instance. | ||
/// </summary> | ||
Task<Instance> UpdateProcessAndEvents(Instance instance, List<InstanceEvent> events); | ||
|
||
/// <summary> | ||
/// Creates an instance of an application with no data. | ||
/// </summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ namespace Altinn.App.Core.Internal.Process; | |
public class ProcessEventDispatcher : IProcessEventDispatcher | ||
{ | ||
private readonly IInstanceClient _instanceClient; | ||
private readonly IInstanceEventClient _instanceEventClient; | ||
private readonly IEventsClient _eventsClient; | ||
private readonly IOptions<AppSettings> _appSettings; | ||
private readonly ILogger<ProcessEventDispatcher> _logger; | ||
|
@@ -23,14 +22,12 @@ public class ProcessEventDispatcher : IProcessEventDispatcher | |
/// </summary> | ||
public ProcessEventDispatcher( | ||
IInstanceClient instanceClient, | ||
IInstanceEventClient instanceEventClient, | ||
IEventsClient eventsClient, | ||
IOptions<AppSettings> appSettings, | ||
ILogger<ProcessEventDispatcher> logger | ||
) | ||
{ | ||
_instanceClient = instanceClient; | ||
_instanceEventClient = instanceEventClient; | ||
_eventsClient = eventsClient; | ||
_appSettings = appSettings; | ||
_logger = logger; | ||
|
@@ -39,12 +36,7 @@ ILogger<ProcessEventDispatcher> logger | |
/// <inheritdoc/> | ||
public async Task<Instance> DispatchToStorage(Instance instance, List<InstanceEvent>? events) | ||
{ | ||
// need to update the instance process and then the instance in case appbase has changed it, e.g. endEvent sets status.archived | ||
Instance updatedInstance = await _instanceClient.UpdateProcess(instance); | ||
await DispatchProcessEventsToStorage(updatedInstance, events); | ||
|
||
// remember to get the instance anew since AppBase can have updated a data element or stored something in the database. | ||
updatedInstance = await _instanceClient.GetInstance(updatedInstance); | ||
Instance updatedInstance = await _instanceClient.UpdateProcessAndEvents(instance, events ?? []); | ||
|
||
return updatedInstance; | ||
} | ||
|
@@ -74,19 +66,4 @@ await _eventsClient.AddEvent( | |
} | ||
} | ||
} | ||
|
||
private async Task DispatchProcessEventsToStorage(Instance instance, List<InstanceEvent>? events) | ||
{ | ||
string org = instance.Org; | ||
string app = instance.AppId.Split("/")[1]; | ||
|
||
if (events != null) | ||
{ | ||
foreach (InstanceEvent instanceEvent in events) | ||
{ | ||
instanceEvent.InstanceId = instance.Id; | ||
await _instanceEventClient.SaveInstanceEvent(instanceEvent, org, app); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,11 @@ public Task<Instance> UpdateProcess(Instance instance) | |
return Task.FromResult(storedInstance); | ||
} | ||
|
||
public Task<Instance> UpdateProcessAndEvents(Instance instance, List<InstanceEvent> events) | ||
{ | ||
return UpdateProcess(instance); | ||
} | ||
|
||
private static Instance GetTestInstance(string app, string org, int instanceOwnerId, Guid instanceId) | ||
{ | ||
string instancePath = GetInstancePath(app, org, instanceOwnerId, instanceId); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5365,7 +5365,8 @@ | |
"type": "boolean" | ||
}, | ||
"allowInSubform": { | ||
"type": "boolean" | ||
"type": "boolean", | ||
"deprecated": true | ||
}, | ||
"shadowFields": { | ||
"$ref": "#/components/schemas/ShadowFields" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3290,6 +3290,7 @@ components: | |
type: boolean | ||
allowInSubform: | ||
type: boolean | ||
deprecated: true | ||
shadowFields: | ||
$ref: '#/components/schemas/ShadowFields' | ||
additionalProperties: false | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These loops are needed because
GenerateProcessStartEvents
is creating the events, at which pointInstanceId
is null..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this a bug before this fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, as it started to happen after switching to the new endpoint.. Don't know why, will do some digging to make sure