-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4383] Add support for representation duplication
Bug: #4383 Signed-off-by: Florian ROUËNÉ <[email protected]>
- Loading branch information
Showing
19 changed files
with
695 additions
and
9 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
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
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
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
54 changes: 54 additions & 0 deletions
54
...eb/application/views/explorer/controllers/MutationDuplicateRepresentationDataFetcher.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,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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.web.application.views.explorer.controllers; | ||
|
||
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.core.api.IPayload; | ||
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; | ||
import org.eclipse.sirius.components.graphql.api.IEditingContextDispatcher; | ||
import org.eclipse.sirius.web.application.views.explorer.dto.DuplicateRepresentationInput; | ||
|
||
import graphql.schema.DataFetchingEnvironment; | ||
|
||
/** | ||
* Data fetcher for the field Mutation#duplicateRepresentation. | ||
* | ||
* @author frouene | ||
*/ | ||
@MutationDataFetcher(type = "Mutation", field = "duplicateRepresentation") | ||
public class MutationDuplicateRepresentationDataFetcher implements IDataFetcherWithFieldCoordinates<CompletableFuture<IPayload>> { | ||
|
||
private static final String INPUT_ARGUMENT = "input"; | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
private final IEditingContextDispatcher editingContextDispatcher; | ||
|
||
public MutationDuplicateRepresentationDataFetcher(ObjectMapper objectMapper, IEditingContextDispatcher editingContextDispatcher) { | ||
this.objectMapper = Objects.requireNonNull(objectMapper); | ||
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, DuplicateRepresentationInput.class); | ||
|
||
return this.editingContextDispatcher.dispatchMutation(input.editingContextId(), input).toFuture(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...a/org/eclipse/sirius/web/application/views/explorer/dto/DuplicateRepresentationInput.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,28 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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.web.application.views.explorer.dto; | ||
|
||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.core.api.IInput; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* The input object of the duplicate representation mutation. | ||
* | ||
* @author frouene | ||
*/ | ||
public record DuplicateRepresentationInput(@NotNull UUID id, @NotNull String editingContextId, @NotNull String representationId) implements IInput { | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...ipse/sirius/web/application/views/explorer/dto/DuplicateRepresentationSuccessPayload.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,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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.web.application.views.explorer.dto; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.core.RepresentationMetadata; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.representations.Message; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* The payload of the duplicate representation mutation. | ||
* | ||
* @author frouene | ||
*/ | ||
public record DuplicateRepresentationSuccessPayload(@NotNull UUID id, @NotNull RepresentationMetadata representationMetadata, @NotNull List<Message> messages) implements IPayload { | ||
|
||
} |
Oops, something went wrong.