-
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
[4444] Allow multiple implementation of IEditingContextSaver & IEditi… #4445
base: master
Are you sure you want to change the base?
Conversation
@@ -40,6 +41,11 @@ public ViewerProjectDataFetcher(IProjectApplicationService projectApplicationSer | |||
@Override | |||
public ProjectDTO get(DataFetchingEnvironment environment) throws Exception { | |||
String projectId = environment.getArgument(PROJECT_ID_ARGUMENT); | |||
var normalizedId = projectId.split("\\+"); |
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 would probably need to use a dedicated API
cac2db5
to
bb225ad
Compare
…ngContextLoader Bug: #4444 Signed-off-by: Michaël Charfadi <[email protected]>
bb225ad
to
2bfe4d5
Compare
Note that it's possible to persist representation by modifying the save method of In conclusion I think we need an API to retrieve the |
@@ -43,9 +43,6 @@ public ViewerEditingContextDataFetcher(IEditingContextApplicationService editing | |||
@Override | |||
public DataFetcherResult<String> get(DataFetchingEnvironment environment) throws Exception { | |||
String editingContextId = environment.getArgument(EDITING_CONTEXT_ID_ARGUMENT); | |||
if (!this.editingContextApplicationService.existsById(editingContextId)) { |
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 need to figure out if the editing context exists, why remove that?
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 editingContext does not exist at this point we just assume that it will exist if a project exists.
So since the new editingContext does not match an existing project with this implementation, I'm not sure how to test this.
} | ||
|
||
public void load(EditingContext editingContext, String projectId) { | ||
public IEditingContext load(String editingContextId) { | ||
var project = this.projectSearchService.findById(editingContextId); |
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.
optionalProject and test that the optional is not empty otherwise return null
return editingContext; | ||
} | ||
|
||
public void toEditingContext(EditingContext editingContext, String 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.
toEditingContext
? You already have an editing context just keep load
@@ -73,6 +97,11 @@ public void load(EditingContext editingContext, String projectId) { | |||
this.editingContextProcessors.forEach(processor -> processor.postProcess(editingContext)); | |||
} | |||
|
|||
@Override | |||
public boolean canHandle(String projectId) { | |||
return new UUIDParser().parse(projectId).isPresent() && this.projectSearchService.existsById(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.
Why are you parsing the UUID? We have moved away from UUID based identifier for the project id
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 testing if the id is the id of a project and in this cas I'm keeping the current implementation
this.semanticDataUpdateService.updateDocuments(cause, projectId, documents, domainUris); | ||
} | ||
|
||
editingContextSavers.stream() |
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.
Just pick the first one, not all of them
|
||
boolean canHandle(String 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.
Why projectId?
public Builder id(UUID id) { | ||
this.id = id; | ||
return this; | ||
} |
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?? Those changes are odd
@Override | ||
public void add(ICause cause, UUID semanticDataId, AggregateReference<Project, String> project) { | ||
var semanticData = SemanticData.newSemanticData() | ||
.id(semanticDataId) | ||
.project(project) | ||
.documents(Set.of()) | ||
.build(cause); | ||
this.semanticDataRepository.save(semanticData); | ||
} |
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 need for that
@@ -39,7 +40,12 @@ public SemanticDataSearchService(ISemanticDataRepository semanticDataRepository) | |||
|
|||
@Override | |||
public Optional<SemanticData> findByProject(AggregateReference<Project, String> project) { | |||
return this.semanticDataRepository.findByProjectId(project.getId()); | |||
return this.semanticDataRepository.findByProjectId(project.getId()).stream().findFirst(); |
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 we will need to change that but I think that you are missing some concept to capture which semantic data to use for a given project, we need to find out how to keep this information in the database.
/** | ||
* Used to create the semantic data. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public interface ISemanticDataCreationService { | ||
void initialize(ICause cause, AggregateReference<Project, String> project); | ||
|
||
void add(ICause cause, UUID semanticDataId, AggregateReference<Project, String> project); |
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.
Can be removed but we will probably need to update the previous method to something like create which would return the created semantic data
…ngContextLoader
Bug : #4444
Signed-off-by: Michaël Charfadi [email protected]
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