-
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.
Bug: #4346 Signed-off-by: Stéphane Bégaudeau <[email protected]>
- Loading branch information
1 parent
0112a51
commit 5091a81
Showing
26 changed files
with
1,417 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
= Add support for a query view | ||
|
||
== Problem | ||
|
||
Sirius Web users need a query view to execute some expressions and view the results. | ||
|
||
== Key Result | ||
|
||
It shall be possible to run a query against the editing context and view the result along with its type (for example to distinguish one element from a list containing only one element). | ||
|
||
The current selection shall be usable as an entry point of the query. | ||
An extension point on the backend shall be available to add custom Java services too. | ||
Various interpreter shall be supported on the backend to let specifiers add custom interpreters. | ||
|
||
This new view shall be contributed using an extension point in order to be removal by downstream projects which may not need it. | ||
|
||
The result of the expression will only be computed when the user will ask for it. | ||
This view will not be a synchronized representation. | ||
|
||
=== Scenario | ||
|
||
==== An user wants to query some model | ||
|
||
- The user open the interpreter view | ||
- The user click on an element in the explorer or another representation like a diagram | ||
- They start typing an expression in the interpreter view and click on a button to perform the query | ||
- The result appears in the result viewer underneath | ||
|
||
|
||
=== Breadboarding | ||
|
||
- A view on the right of the workbench with a textarea to enter an expression and a viewer underneath to display the result. | ||
|
||
|
||
=== Cutting backs | ||
|
||
- Content assist in the interpreter. | ||
|
||
|
||
== Rabbit holes | ||
|
||
|
||
== No-gos |
57 changes: 57 additions & 0 deletions
57
...sirius/web/application/views/query/controllers/MutationEvaluateExpressionDataFetcher.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,57 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.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.components.graphql.api.IExceptionWrapper; | ||
import org.eclipse.sirius.web.application.views.query.dto.EvaluateExpressionInput; | ||
|
||
import graphql.schema.DataFetchingEnvironment; | ||
|
||
/** | ||
* The data fetcher used to evaluate an expression for the interpreter view. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
@MutationDataFetcher(type = "Mutation", field = "evaluateExpression") | ||
public class MutationEvaluateExpressionDataFetcher implements IDataFetcherWithFieldCoordinates<CompletableFuture<IPayload>> { | ||
|
||
private static final String INPUT_ARGUMENT = "input"; | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
private final IExceptionWrapper exceptionWrapper; | ||
|
||
private final IEditingContextDispatcher editingContextDispatcher; | ||
|
||
public MutationEvaluateExpressionDataFetcher(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, EvaluateExpressionInput.class); | ||
return this.exceptionWrapper.wrapMono(() -> this.editingContextDispatcher.dispatchMutation(input.editingContextId(), input), input).toFuture(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...main/java/org/eclipse/sirius/web/application/views/query/dto/BooleanExpressionResult.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,21 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
/** | ||
* Used to return a boolean value. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public record BooleanExpressionResult(boolean value) implements IEvaluateExpressionResult { | ||
} |
25 changes: 25 additions & 0 deletions
25
...main/java/org/eclipse/sirius/web/application/views/query/dto/EvaluateExpressionInput.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,25 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.core.api.IInput; | ||
|
||
/** | ||
* Used to execute an expression. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public record EvaluateExpressionInput(UUID id, String editingContextId, String expression) implements IInput { | ||
} |
29 changes: 29 additions & 0 deletions
29
.../org/eclipse/sirius/web/application/views/query/dto/EvaluateExpressionSuccessPayload.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,29 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.core.api.IPayload; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* Used to indicate that the expression has been successfully evaluated. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public record EvaluateExpressionSuccessPayload( | ||
@NotNull UUID id, | ||
@NotNull IEvaluateExpressionResult result) implements IPayload { | ||
} |
21 changes: 21 additions & 0 deletions
21
...in/java/org/eclipse/sirius/web/application/views/query/dto/IEvaluateExpressionResult.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,21 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
/** | ||
* Interface to be implemented by all the evaluation results. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public interface IEvaluateExpressionResult { | ||
} |
21 changes: 21 additions & 0 deletions
21
...src/main/java/org/eclipse/sirius/web/application/views/query/dto/IntExpressionResult.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,21 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
/** | ||
* Used to return an integer value. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public record IntExpressionResult(int value) implements IEvaluateExpressionResult { | ||
} |
21 changes: 21 additions & 0 deletions
21
.../main/java/org/eclipse/sirius/web/application/views/query/dto/ObjectExpressionResult.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,21 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
/** | ||
* Used to return a single object. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public record ObjectExpressionResult(Object value) implements IEvaluateExpressionResult { | ||
} |
23 changes: 23 additions & 0 deletions
23
...main/java/org/eclipse/sirius/web/application/views/query/dto/ObjectsExpressionResult.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,23 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Used to return a list of objects. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public record ObjectsExpressionResult(List<Object> value) implements IEvaluateExpressionResult { | ||
} |
21 changes: 21 additions & 0 deletions
21
.../main/java/org/eclipse/sirius/web/application/views/query/dto/StringExpressionResult.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,21 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
/** | ||
* Used to return a string based value. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public record StringExpressionResult(String value) implements IEvaluateExpressionResult { | ||
} |
21 changes: 21 additions & 0 deletions
21
...rc/main/java/org/eclipse/sirius/web/application/views/query/dto/VoidExpressionResult.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,21 @@ | ||
/******************************************************************************* | ||
* 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.web.application.views.query.dto; | ||
|
||
/** | ||
* Used to indicate the lack of result. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public record VoidExpressionResult() implements IEvaluateExpressionResult { | ||
} |
Oops, something went wrong.