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
[3344] Add support for reloading representation from the database #3348
base: master
Are you sure you want to change the base?
Conversation
0250015
to
db47907
Compare
@@ -29,6 +29,8 @@ public record DiagramRefreshedEventPayload(UUID id, Diagram diagram, String caus | |||
|
|||
public static final String CAUSE_LAYOUT = "layout"; | |||
|
|||
public static final String CAUSE_RELOAD = "reload"; |
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.
There's a bug here: the new value is not added in the GraphQL Schema and not handled by the front (in DiagramRenderer.tsx
). I'm investigating how exactly it should be handled.
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.
db47907
to
d0f6a38
Compare
d0f6a38
to
b618808
Compare
b618808
to
9cff301
Compare
} else if (changeDescription.getKind().equals(ChangeKind.RELOAD_REPRESENTATION) && changeDescription.getSourceId().equals(this.formDescriptionEditorContext.getFormDescriptionEditor().getId())) { | ||
Optional<FormDescriptionEditor> reloadedFormDescriptionEditor = this.representationSearchService.findById(this.editingContext, this.formDescriptionEditorContext.getFormDescriptionEditor().getId(), FormDescriptionEditor.class); | ||
if (reloadedFormDescriptionEditor.isPresent()) { | ||
this.formDescriptionEditorContext.update(reloadedFormDescriptionEditor.get()); | ||
this.formDescriptionEditorEventFlux.formDescriptionEditorRefreshed(changeDescription.getInput(), reloadedFormDescriptionEditor.get()); | ||
} |
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 took upon myself to add tests last week to make this PR go through the continuous integration without issues and there something I don't understand here because I can't succeed in making this code work. The data structure persisted in the database is not the same as the one sent back to the frontend, the refresh is needed to compute the whole structure since it is not persisted. See these two PRs that you've reviewed before (#1484 and #1963) for additional details.
Without a new refresh and unless I've missed something, I think this will only reload an empty representation. I suspect that the same would be true for at least for the form representation which behave the same way, see CreateFormEventHandler#handle
which does not store the real content of the form in the database. Have you ever seen this code work for forms or form description editors?
I'll push in another commit the tests that I've started to add, could you make the form description editor test succeed and contribute a XxxxLifecycleControllerTests for each representation kind (I've successfully done the Gantt one) to ensure that the mechanism works please.
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'm on it.
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.
Should be fixed. I've added a small test for portals to increase the coverage. There's still a coverage issue with the Hierarchy representation, but it's not clear how to properly test it or of its even relevant.
Bug: #3344 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
16e8bd8
to
6a1fb7e
Compare
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr> Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
6a1fb7e
to
8e726e2
Compare
@@ -55,7 +55,9 @@ public void hierarchyRefreshed(IInput input, Hierarchy newHierarchy) { | |||
} | |||
|
|||
public Flux<IPayload> getFlux(IInput input) { | |||
var initialRefresh = Mono.fromCallable(() -> new HierarchyRefreshedEventPayload(input.id(), this.currentHierarchy)); | |||
var initialRefresh = Mono.fromCallable(() -> { |
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.
Is there anything that should change here?
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.
My mistake. I had changed the formatting to put a breakpoint on the inside of the lambda and forgot to revert.
.../org/eclipse/sirius/web/application/controllers/portal/PortalControllerIntegrationTests.java
Outdated
Show resolved
Hide resolved
.../org/eclipse/sirius/web/application/controllers/portal/PortalControllerIntegrationTests.java
Outdated
Show resolved
Hide resolved
var input = new CreateRepresentationInput(UUID.randomUUID(), TestIdentifiers.ECORE_SAMPLE_PROJECT.toString(), PortalDescriptionProvider.DESCRIPTION_ID, TestIdentifiers.EPACKAGE_OBJECT.toString(), "Sample Portal"); | ||
var flux = this.givenCreatedPortalSubscription.createAndSubscribe(input); | ||
|
||
Consumer<PortalRefreshedEventPayload> initialPortalContentConsumer = payload -> Optional.of(payload) |
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'm not sure what this test adds, why not test the feature that you have added?
* @author pcdavid | ||
*/ | ||
@SubscriptionDataFetcher(type = "Subscription", field = "hierarchyEvent") | ||
public class SubscriptionHierarchyEventDataFetcher implements IDataFetcherWithFieldCoordinates<Publisher<IPayload>> { |
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.
Why is that in a test folder?
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.
We don't have a sirius-components-charts-graphql
module yet and it felt overkill to create one just to host this single class only used in a test, especially as we do not have actual UI to create hierarchy representations.
...g/eclipse/sirius/web/application/controllers/hierarchy/HierarchyEventSubscriptionRunner.java
Outdated
Show resolved
Hide resolved
var deleteWidgetInput = new DeleteWidgetInput( | ||
UUID.randomUUID(), | ||
StudioIdentifiers.SAMPLE_STUDIO_PROJECT.toString(), | ||
formDescriptionEditorId.get(), | ||
newWidgetId.get()); | ||
var result = this.deleteWidgetMutationRunner.run(deleteWidgetInput); | ||
String typename = JsonPath.read(result, "$.data.deleteWidget.__typename"); | ||
assertThat(typename).isEqualTo(SuccessPayload.class.getSimpleName()); | ||
|
||
TestTransaction.flagForCommit(); | ||
TestTransaction.end(); | ||
TestTransaction.start(); |
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.
This will trigger a refresh of the form description editor by itself, wouldn't that make the test "work" even without the reload after that? Unless I missed something, written this way the test does not prove that the feature works.
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.
The test should probably change to show the feature working
} else if (changeDescription.getKind().equals(ChangeKind.RELOAD_REPRESENTATION) && changeDescription.getSourceId().equals(this.currentForm.get().getId())) { | ||
Optional<Form> reloadedForm = this.representationSearchService.findById(this.editingContext, this.currentForm.get().getId(), Form.class); | ||
if (reloadedForm.isPresent()) { | ||
this.currentForm.set(reloadedForm.get()); | ||
this.emitNewForm(changeDescription); | ||
} | ||
} | ||
} |
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.
Would that really work for forms? Wouldn't that reload the empty form from the database and send it back as is to the frontend making everything go blank?
Could you add the relevant tests for all representations to prove that your contribution is working please?
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
5823ed2
to
8c1aec8
Compare
Bug: #3344
Signed-off-by: Pierre-Charles David pierre-charles.david@obeo.fr
Pull request template
General purpose
What is the main goal of this pull request?
Project management
priority:
andpr:
labels been added to the pull request? (In case of doubt, start with the labelspriority: low
andpr: to review later
)area:
,difficulty:
,type:
)CHANGELOG.adoc
been updated to reference the relevant issues?CHANGELOG.adoc
? (Including changes in the GraphQL API)CHANGELOG.adoc
? For example indoc/screenshots/2022.5.0-my-new-feature.png
Architectural decision records (ADR)
[doc]
?CHANGELOG.adoc
?Dependencies
CHANGELOG.adoc
?CHANGELOG.adoc
?Frontend
This section is not relevant if your contribution does not come with changes to the frontend.
General purpose
Typing
We need to improve the typing of our code, as such, we require every contribution to come with proper TypeScript typing for both changes contributing new files and those modifying existing files.
Please ensure that the following statements are true for each file created or modified (this may require you to improve code outside of your contribution).
useMutation<DATA_TYPE, VARIABLE_TYPE>(…)
useQuery<DATA_TYPE, VARIABLE_TYPE>(…)
useSubscription<DATA_TYPE, VARIABLE_TYPE>(…)
useMachine<CONTEXT_TYPE, EVENTS_TYPE>(…)
useState<STATE_TYPE>(…)
?.
(if the GraphQL API specifies that a field cannot benull
, do not treat it has potentiallynull
for example)let diagram: Diagram | null = null;
)Backend
This section is not relevant if your contribution does not come with changes to the backend.
General purpose
Architecture
Review
How to test this PR?
Please describe here the various use cases to test this pull request