-
Notifications
You must be signed in to change notification settings - Fork 58
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
private final TransactionTemplate transactionTemplate; | ||
|
||
private final ApplicationEventPublisher applicationEventPublisher; | ||
//private final ApplicationEventPublisher applicationEventPublisher; |
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.
No sure if I should adopt a Parameters object or move some things around
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.
Or I could remove ApplicationEventPublisher
& TransactionTemplate
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.
No sure if I should adopt a Parameters object or move some things around
I have not looked into this in details but there are some very specific places where we had to do that because we can't use Spring dependency injection but if the question arises anywhere else the answer is always no. This "parameters" object pattern is something we don't want to propagate.
9406d58
to
92b25f9
Compare
Bug: #4372 Signed-off-by: Michaël Charfadi <[email protected]>
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.
@@ -63,7 +62,7 @@ public EditingContextLoader(ISemanticDataSearchService semanticDataSearchService | |||
public void load(EditingContext editingContext, UUID projectId) { | |||
this.editingContextProcessors.forEach(processor -> processor.preProcess(editingContext)); | |||
|
|||
this.semanticDataSearchService.findByProject(AggregateReference.to(projectId)) | |||
this.semanticDataSearchService.findById(UUID.fromString(editingContext.getId())) |
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 the projectId
parameter still revenant now? Shouldn't we have something to select a relevant loader? We will see with a test.
@@ -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)
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