-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3655] Support "Delete Task Dependency" tool in gantt
Bug: #3655 Signed-off-by: Laurent Fasani <[email protected]>
- Loading branch information
Showing
55 changed files
with
1,275 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...lipse/sirius/components/collaborative/gantt/dto/input/DeleteGanttTaskDependencyInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.gantt.dto.input; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.collaborative.gantt.api.IGanttInput; | ||
|
||
/** | ||
* The input of the "Delete task dependency" mutation. | ||
* | ||
* @author lfasani | ||
*/ | ||
public record DeleteGanttTaskDependencyInput(UUID id, String editingContextId, String representationId, String sourceTaskId, String targetTaskId) implements IGanttInput { | ||
public DeleteGanttTaskDependencyInput { | ||
Objects.requireNonNull(id); | ||
Objects.requireNonNull(editingContextId); | ||
Objects.requireNonNull(representationId); | ||
Objects.requireNonNull(sourceTaskId); | ||
Objects.requireNonNull(targetTaskId); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...ipse/sirius/components/collaborative/gantt/handlers/DeleteTaskDependencyEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.gantt.handlers; | ||
|
||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.ChangeDescription; | ||
import org.eclipse.sirius.components.collaborative.api.ChangeKind; | ||
import org.eclipse.sirius.components.collaborative.api.Monitoring; | ||
import org.eclipse.sirius.components.collaborative.gantt.api.IGanttContext; | ||
import org.eclipse.sirius.components.collaborative.gantt.api.IGanttEventHandler; | ||
import org.eclipse.sirius.components.collaborative.gantt.api.IGanttInput; | ||
import org.eclipse.sirius.components.collaborative.gantt.api.IGanttTaskService; | ||
import org.eclipse.sirius.components.collaborative.gantt.dto.input.DeleteGanttTaskDependencyInput; | ||
import org.eclipse.sirius.components.collaborative.gantt.message.ICollaborativeGanttMessageService; | ||
import org.eclipse.sirius.components.core.api.ErrorPayload; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.springframework.stereotype.Service; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
import reactor.core.publisher.Sinks.Many; | ||
import reactor.core.publisher.Sinks.One; | ||
|
||
/** | ||
* Handle "Delete Task Dependency" events. | ||
* | ||
* @author lfasani | ||
*/ | ||
@Service | ||
public class DeleteTaskDependencyEventHandler implements IGanttEventHandler { | ||
|
||
private final IGanttTaskService ganttTaskService; | ||
|
||
private final ICollaborativeGanttMessageService messageService; | ||
|
||
private final Counter counter; | ||
|
||
public DeleteTaskDependencyEventHandler(IGanttTaskService ganttTaskService, ICollaborativeGanttMessageService messageService, MeterRegistry meterRegistry) { | ||
this.ganttTaskService = Objects.requireNonNull(ganttTaskService); | ||
this.messageService = Objects.requireNonNull(messageService); | ||
|
||
this.counter = Counter.builder(Monitoring.EVENT_HANDLER).tag(Monitoring.NAME, this.getClass().getSimpleName()).register(meterRegistry); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(IGanttInput ganttInput) { | ||
return ganttInput instanceof DeleteGanttTaskDependencyInput; | ||
} | ||
|
||
@Override | ||
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, IGanttContext ganttContext, IGanttInput ganttInput) { | ||
this.counter.increment(); | ||
|
||
String message = this.messageService.invalidInput(ganttInput.getClass().getSimpleName(), DeleteGanttTaskDependencyInput.class.getSimpleName()); | ||
IPayload payload = new ErrorPayload(ganttInput.id(), message); | ||
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, ganttInput.representationId(), ganttInput); | ||
|
||
if (ganttInput instanceof DeleteGanttTaskDependencyInput input) { | ||
payload = this.ganttTaskService.deleteTaskDependency(input, editingContext, ganttContext.getGantt()); | ||
|
||
changeDescription = new ChangeDescription(ChangeKind.SEMANTIC_CHANGE, ganttInput.representationId(), ganttInput); | ||
} | ||
|
||
payloadSink.tryEmitValue(payload); | ||
changeDescriptionSink.tryEmitNext(changeDescription); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...mponents/gantt/graphql/datafetchers/mutation/MutationDeleteTaskDependencyDataFetcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.gantt.graphql.datafetchers.mutation; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import java.util.Objects; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.eclipse.sirius.components.annotations.spring.graphql.MutationDataFetcher; | ||
import org.eclipse.sirius.components.collaborative.gantt.dto.input.DeleteGanttTaskDependencyInput; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; | ||
import org.eclipse.sirius.components.graphql.api.IEditingContextDispatcher; | ||
import org.eclipse.sirius.components.graphql.api.IExceptionWrapper; | ||
|
||
import graphql.schema.DataFetchingEnvironment; | ||
|
||
/** | ||
* The data fetcher used to delete a gantt task dependency. | ||
* | ||
* @author lfasani | ||
*/ | ||
@MutationDataFetcher(type = "Mutation", field = "deleteGanttTaskDependency") | ||
public class MutationDeleteTaskDependencyDataFetcher implements IDataFetcherWithFieldCoordinates<CompletableFuture<IPayload>> { | ||
|
||
private static final String INPUT_ARGUMENT = "input"; | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
private final IExceptionWrapper exceptionWrapper; | ||
|
||
private final IEditingContextDispatcher editingContextDispatcher; | ||
|
||
public MutationDeleteTaskDependencyDataFetcher(ObjectMapper objectMapper, IExceptionWrapper exceptionWrapper, IEditingContextDispatcher editingContextDispatcher) { | ||
this.objectMapper = Objects.requireNonNull(objectMapper); | ||
this.exceptionWrapper = Objects.requireNonNull(exceptionWrapper); | ||
this.editingContextDispatcher = Objects.requireNonNull(editingContextDispatcher); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<IPayload> get(DataFetchingEnvironment environment) throws Exception { | ||
Object argument = environment.getArgument(INPUT_ARGUMENT); | ||
var input = this.objectMapper.convertValue(argument, DeleteGanttTaskDependencyInput.class); | ||
|
||
return this.exceptionWrapper.wrapMono(() -> this.editingContextDispatcher.dispatchMutation(input.editingContextId(), input), input).toFuture(); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
...org/eclipse/sirius/components/gantt/tests/graphql/CreateTaskDependencyMutationRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.gantt.tests.graphql; | ||
|
||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.collaborative.gantt.dto.input.CreateGanttTaskDependencyInput; | ||
import org.eclipse.sirius.components.graphql.tests.api.IGraphQLRequestor; | ||
import org.eclipse.sirius.components.graphql.tests.api.IMutationRunner; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Used to create a Task Dependency with the GraphQL API. | ||
* | ||
* @author lfasani | ||
*/ | ||
@Service | ||
public class CreateTaskDependencyMutationRunner implements IMutationRunner<CreateGanttTaskDependencyInput> { | ||
|
||
private static final String CREATE_TASK_DEPENDENCY_MUTATION = """ | ||
mutation createGanttTaskDependency($input: CreateGanttTaskDependencyInput!) { | ||
createGanttTaskDependency(input: $input) { | ||
__typename | ||
... on ErrorPayload { | ||
messages { | ||
body | ||
level | ||
} | ||
} | ||
... on SuccessPayload { | ||
messages { | ||
body | ||
level | ||
} | ||
} | ||
} | ||
} | ||
"""; | ||
|
||
private final IGraphQLRequestor graphQLRequestor; | ||
|
||
public CreateTaskDependencyMutationRunner(IGraphQLRequestor graphQLRequestor) { | ||
this.graphQLRequestor = Objects.requireNonNull(graphQLRequestor); | ||
} | ||
|
||
@Override | ||
public String run(CreateGanttTaskDependencyInput input) { | ||
return this.graphQLRequestor.execute(CREATE_TASK_DEPENDENCY_MUTATION, input); | ||
} | ||
} |
Oops, something went wrong.