-
Notifications
You must be signed in to change notification settings - Fork 61
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
[4372] Use semantic_data_id as editing context id #4397
base: master
Are you sure you want to change the base?
Conversation
fd7d267
to
2ad3d10
Compare
8d9fe9a
to
c354ee1
Compare
...ava/org/eclipse/sirius/web/application/project/services/TemplateBasedProjectInitializer.java
Outdated
Show resolved
Hide resolved
92b25f9
to
37a7bb4
Compare
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've stopped the review halfway because there is a small mis-understanding. I don't need you to remove the coupling between the editing context id and the project id to replace it by the exact same kind of coupling with the semantic data id.
I need you to make sure that downstream applications can couple the editing context id with something else and we should use the semantic data id as an example. I don't want to see the semantic data id being taken as an hardcoded dependency everywhere.
I first need a pull request making sure that the id of the project is now a string instead of an uuid and just that. After that, I need to be able to leverage that. For this second part, here's another acceptance criteria to ensure that your code works:
I need a piece of code in the project sirius-web-papaya
which ensure that if the project id received by the backend is composed of UUID_OF_A_PAPAYA_PROJECT+demo-papaya
so for example something like this:
http://localhost:5173/projects/f23c3cf0-7244-4892-8a58-82d40bfd1aa7+demo-papaya/edit/d4aa7077-707a-4cfb-a36f-1abdc46219e4
Then a new document with some Papaya content is added in the editing context. This document would not be saved in the editing context once it is persisted. I want to contribute a special IEditingContextLoader for Papaya that can change how data are loaded and a special IEditingContextSaver which changes how data are saved and I want to control how we are finding the editing context id from the project id.
I'm not even 100% sure that we need to change any of the code that you have modified to add this dependency to ISemanticDataSearchService
.
@@ -30,10 +31,17 @@ | |||
*/ | |||
@QueryDataFetcher(type = "Project", field = "currentEditingContext") | |||
public class ProjectCurrentEditingContextDataFetcher implements IDataFetcherWithFieldCoordinates<DataFetcherResult<String>> { | |||
|
|||
private final ISemanticDataSearchService semanticDataSearchService; |
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.
Please use the IEditingContextApplicationService
here and leverage the ISemanticDataSearchService
inside, since it's an application service it will help you not to forget using the @Transactionnal
annotation which we need to have some proper transaction management.
...in/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextLoader.java
Show resolved
Hide resolved
@@ -74,7 +81,9 @@ public void persist(ICause cause, IEditingContext editingContext) { | |||
if (editingContext instanceof IEMFEditingContext emfEditingContext) { | |||
var applyMigrationParticipants = this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(emfEditingContext)); | |||
new UUIDParser().parse(editingContext.getId()) | |||
.map(AggregateReference::<Project, UUID>to) | |||
.flatMap(this.semanticDataSearchService::findById) |
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.
While it should work I suspect that the whole if block will end up being extracted in an IEditingContextSaver
var optionalUUID = new UUIDParser().parse(editingContextId); | ||
if (optionalUUID.isPresent()) { | ||
var optionalSemanticData = this.semanticDataSearchService.findById(optionalUUID.get()); | ||
if (optionalSemanticData.isPresent() && optionalSemanticData.get().getId() != null) { | ||
return this.projectSearchService.findById(optionalSemanticData.get().getProject().getId()) | ||
.map(project -> this.toEditingContext(project, optionalSemanticData.get().getId().toString())); | ||
} | ||
} | ||
return Optional.empty(); |
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 suspect that this is where a generic API will be needed
@@ -50,53 +52,68 @@ public class ObjectRestController { | |||
|
|||
private final IEditingContextDispatcher editingContextDispatcher; | |||
|
|||
public ObjectRestController(IEditingContextDispatcher editingContextDispatcher) { | |||
private final ISemanticDataSearchService semanticDataSearchService; |
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.
You will need to use an application service here to leverage the @Transactionnal
annotation (probably the same IEditingContextApplicationService
?)
@@ -56,18 +58,25 @@ public class CommitRestController { | |||
|
|||
private final IEditingContextDispatcher editingContextDispatcher; | |||
|
|||
public CommitRestController(IEditingContextDispatcher editingContextDispatcher) { | |||
private final ISemanticDataSearchService semanticDataSearchService; |
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.
Same comment
@@ -48,9 +52,12 @@ public class DefaultProjectDataVersiongRestService implements IDefaultProjectDat | |||
|
|||
private final IObjectService objectService; | |||
|
|||
public DefaultProjectDataVersiongRestService(IDefaultObjectRestService defaultObjectRestService, IObjectService objectService) { | |||
private final ISemanticDataSearchService semanticDataSearchService; |
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.
Same comment
this.projectSearchService = Objects.requireNonNull(projectSearchService); | ||
this.projectMapper = Objects.requireNonNull(projectMapper); | ||
this.editingContextSearchService = Objects.requireNonNull(editingContextSearchService); | ||
this.editingContextPersistenceService = Objects.requireNonNull(editingContextPersistenceService); | ||
this.projectTemplateInitializers = Objects.requireNonNull(projectTemplateInitializers); | ||
this.semanticDataSearchService = semanticDataSearchService; |
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.
require non null (same comment at various other locations)
b708dde
to
b82c6aa
Compare
Bug: #4372 Signed-off-by: Michaël Charfadi <[email protected]>
b82c6aa
to
ac67887
Compare
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'll update the PR and ensure that it gets merged
...g/eclipse/sirius/web/application/document/controllers/MutationCreateDocumentDataFetcher.java
Show resolved
Hide resolved
.../sirius-web-application/src/main/java/org/eclipse/sirius/web/application/dto/Identified.java
Show resolved
Hide resolved
...eclipse/sirius/web/application/editingcontext/services/EditingContextApplicationService.java
Show resolved
Hide resolved
...in/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextLoader.java
Show resolved
Hide resolved
.../org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java
Show resolved
Hide resolved
...g/eclipse/sirius/web/application/studio/services/representations/DomainExplorerServices.java
Show resolved
Hide resolved
...eclipse/sirius/web/application/controllers/documents/DocumentControllerIntegrationTests.java
Show resolved
Hide resolved
...rius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.java
Show resolved
Hide resolved
@@ -26,7 +26,8 @@ public final class TestIdentifiers { | |||
public static final String UML_SAMPLE_PROJECT = "7ba7bda7-13b9-422a-838b-e45a3597e952"; | |||
public static final String SYSML_SAMPLE_PROJECT = "4164c661-e0cb-4071-b25d-8516440bb8e8"; | |||
public static final UUID SYSML_IMAGE = UUID.fromString("ff37f0eb-effb-4c57-b17f-76bc7ea64f5b"); | |||
public static final String ECORE_SAMPLE_PROJECT = "99d336a2-3049-439a-8853-b104ffb22653"; | |||
public static final String ECORE_SAMPLE_PROJECT = "cb133bf0-d7aa-4a83-a277-0972919dd46a"; | |||
public static final String ECORE_SAMPLE_PROJECT_ID = "99d336a2-3049-439a-8853-b104ffb22653"; |
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 no reason to rename the existing identifier to use _ID
, it is an identifier, that's the goal of the class. Use another name if it's relevant but right now I don't know how anyone could tell the difference between the identifier ECORE_SAMPLE_PROJECT
and ECORE_SAMPLE_PROJECT_ID
.
@@ -44,6 +44,8 @@ See `PapayaExtensionRegistry.tsx` for an example of how rendering a project subt | |||
It is not an API breaking change but a breaking change from the end-user point of view. | |||
- https://github.com/eclipse-sirius/sirius-web/issues/4500[#4500] [sirius-web] Remove the tight coupling between `SemanticData` and `Project` by removing `SemanticData#project` along with the column `project_id` from the `semantic_data` table | |||
- https://github.com/eclipse-sirius/sirius-web/issues/4501[#4501] [browser] `IReferenceWidgetRootCandidateSearchProvider` API has been renamed to `IModelBrowserRootCandidateSearchProvider` and moved to the `sirius-components-collaborative-browser` module. | |||
- https://github.com/eclipse-sirius/sirius-web/issues/4372[#4372] [sirius-web] The identifier used for editingContextId is now semanticDataId instead of the projectId. |
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.
Since this will be a MASSIVE change for all downstream application which may be using editingContextId
as the projectId
some additional information will be necessary to explain them how to proceed with this breaking change.
Bug: #4372
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