Skip to content

Commit

Permalink
[cleanup] Dispose editing context immediately when a project is deleted
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Charles David <[email protected]>
  • Loading branch information
pcdavid committed Aug 28, 2024
1 parent db03783 commit ee8cb8c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Objects;

import org.eclipse.sirius.components.annotations.spring.graphql.MutationDataFetcher;
import org.eclipse.sirius.components.collaborative.api.IEditingContextEventProcessorRegistry;
import org.eclipse.sirius.components.core.api.IPayload;
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates;
import org.eclipse.sirius.web.application.project.dto.DeleteProjectInput;
Expand All @@ -38,15 +39,19 @@ public class MutationDeleteProjectDataFetcher implements IDataFetcherWithFieldCo

private final IProjectApplicationService projectApplicationService;

public MutationDeleteProjectDataFetcher(ObjectMapper objectMapper, IProjectApplicationService projectApplicationService) {
private final IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry;

public MutationDeleteProjectDataFetcher(ObjectMapper objectMapper, IProjectApplicationService projectApplicationService, IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry) {
this.objectMapper = Objects.requireNonNull(objectMapper);
this.projectApplicationService = Objects.requireNonNull(projectApplicationService);
this.editingContextEventProcessorRegistry = Objects.requireNonNull(editingContextEventProcessorRegistry);
}

@Override
public IPayload get(DataFetchingEnvironment environment) throws Exception {
Object argument = environment.getArgument(INPUT_ARGUMENT);
var input = this.objectMapper.convertValue(argument, DeleteProjectInput.class);
this.editingContextEventProcessorRegistry.disposeEditingContextEventProcessor(input.projectId().toString());
return this.projectApplicationService.deleteProject(input);
}
}

0 comments on commit ee8cb8c

Please sign in to comment.