Skip to content

Commit

Permalink
[4375] Add support for impact analysis before tool execution
Browse files Browse the repository at this point in the history
Bug: #4375
Signed-off-by: Florian ROUËNÉ <[email protected]>
  • Loading branch information
frouene committed Jan 28, 2025
1 parent f39045d commit c1a0064
Show file tree
Hide file tree
Showing 61 changed files with 2,573 additions and 924 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Downstream applications which were using it to change the image of the home butt
- https://github.com/eclipse-sirius/sirius-web/issues/4362[#4362] [sirius-web] The `editProjectNavbarSubtitleExtensionPoint` has been removed.
Use the new frontend extension point `navigationBarCenterContributionExtensionPoint`, which is strictly more powerful, instead.
See `PapayaExtensionRegistry.tsx` for an example of how rendering a project subtitle can be achieved with the new extension point.
- https://github.com/eclipse-sirius/sirius-web/issues/4375[#4375] [diagram] `ToolVariable` has been moved from `sirius-component-collaborative-diagram` to `sirius-component-collaborative`

=== Dependency update

Expand Down Expand Up @@ -107,6 +108,8 @@ The expression can return a string (with a prefix of the form `INFO:`, `WARNING:
It can be used to add new elements before/after the default UI or to completely replace the UI with another one if needed.
Because this new extension point offers complete control of this part of the UI, the `editProjectNavbarSubtitleExtensionPoint` has been removed.
See `PapayaExtensionRegistry.tsx` for how the same result as before can be achieved with the new extension point.
- https://github.com/eclipse-sirius/sirius-web/issues/4375[#4375] [diagram] Add support for a first version of impact analysis before tool execution.


=== Improvements

Expand Down Expand Up @@ -249,7 +252,7 @@ This is now fixed
- https://github.com/eclipse-sirius/sirius-web/issues/4291[#4291] [core] Implement REST API documentation with openAPI v3 and swagger
* Documentation is availlable in the url : /v3/api-docs
* Swagger UI is availlable in the url : /swagger-ui/index.html#/
- https://github.com/eclipse-sirius/sirius-web/issues/4335[#4335] [table] Add support of column reordering in table representation
- https://github.com/eclipse-sirius/sirius-web/issues/4335[#4335] [table] Add support of column reordering in table representation

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*******************************************************************************
* 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
*******************************************************************************/
import { Studio } from '../../../usecases/Studio';
import { Details } from '../../../workbench/Details';
import { Diagram } from '../../../workbench/Diagram';
import { Explorer } from '../../../workbench/Explorer';
import { ImpactAnalysis } from '../../../workbench/ImpactAnalysis';

describe('Impact analysis - diagram', () => {
const domainName: string = 'diagramImpactAnalysis';
context('Given a view with a node tool with impact analysis', () => {
context('When we create a new instance project', () => {
let instanceProjectId: string = '';
const diagramDescriptionName = `${domainName} - simple node`;
const diagramTitle = 'Impact analysis diagram';

beforeEach(() => {
const studio = new Studio();
studio.createProjectFromDomain('Cypress - Studio Instance', domainName, 'Root').then((res) => {
instanceProjectId = res.projectId;
});
});

afterEach(() => cy.deleteProject(instanceProjectId));

it('Then the tool trigger the impact analysis dialog with the good report', () => {
const explorer = new Explorer();
const diagram = new Diagram();
const details = new Details();
const impactAnalysis = new ImpactAnalysis();
explorer.createObject('Root', 'entity1s-Entity1');
details.getTextField('Name').type('InitialName{enter}');
new Explorer().createRepresentation('Root', diagramDescriptionName, diagramTitle);
diagram.fitToScreen();
diagram.getNodes('Impact analysis diagram', 'InitialName').findByTestId('Label - InitialName').click();
diagram.getPalette().should('exist');
diagram.getPalette().findByTestId('tool-Tool with impact analysis').click();
impactAnalysis.getImpactAnalysisDialog().should('exist');
impactAnalysis.getNbElementModified().should('contain', 'Elements modified: 2');
impactAnalysis.getNbElementCreated().should('contain', 'Elements added: 1');
});

it('Then after impact analysis it is possible to confirm the tool execution', () => {
const explorer = new Explorer();
const diagram = new Diagram();
const details = new Details();
const impactAnalysis = new ImpactAnalysis();
explorer.createObject('Root', 'entity1s-Entity1');
details.getTextField('Name').type('InitialName{enter}');
new Explorer().createRepresentation('Root', diagramDescriptionName, diagramTitle);
diagram.fitToScreen();
diagram.getNodes('Impact analysis diagram', 'InitialName').findByTestId('Label - InitialName').click();
diagram.getPalette().should('exist');
diagram.getPalette().findByTestId('tool-Tool with impact analysis').click();
impactAnalysis.getImpactAnalysisDialog().should('exist');
impactAnalysis.confirmExecution();
diagram.getNodes('Impact analysis diagram', 'newName').should('exist');
diagram.getNodes('Impact analysis diagram', 'InitialName').should('not.exist');
});
});
});
});
38 changes: 38 additions & 0 deletions integration-tests/cypress/workbench/ImpactAnalysis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* 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
*******************************************************************************/

export class ImpactAnalysis {
public getImpactAnalysisDialog(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getByTestId('impact-analysis-dialog');
}

public cancelExecution(): void {
cy.getByTestId('impact-analysis-dialog-button-cancel').click();
}

public confirmExecution(): void {
cy.getByTestId('impact-analysis-dialog-button-ok').click();
}

public getNbElementCreated(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getByTestId('impact-analysis-report-nbElementCreated').should('exist');
}

public getNbElementDeleted(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getByTestId('impact-analysis-report-nbElementDeleted').should('exist');
}

public getNbElementModified(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getByTestId('impact-analysis-report-nbElementModified').should('exist');
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2024 Obeo.
* Copyright (c) 2022, 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
Expand Down Expand Up @@ -79,6 +79,7 @@ public CompatibilityPaletteProvider(IIdentifierProvider identifierProvider, IODe
this.odesignRegistry = Objects.requireNonNull(odesignRegistry);
this.interpreterFactory = Objects.requireNonNull(interpreterFactory);
}

@Override
public boolean canHandle(DiagramDescription diagramDescription) {
return this.identifierProvider.findVsmElementId(diagramDescription.getId()).isPresent();
Expand Down Expand Up @@ -136,7 +137,7 @@ private ITool convertTool(org.eclipse.sirius.components.diagrams.tools.ITool too
if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool singleClickOnDiagramElementTool) {
convertedTool = new SingleClickOnDiagramElementTool(singleClickOnDiagramElementTool.getId(), singleClickOnDiagramElementTool.getLabel(),
singleClickOnDiagramElementTool.getIconURL(), singleClickOnDiagramElementTool.getTargetDescriptions(),
singleClickOnDiagramElementTool.getDialogDescriptionId(), singleClickOnDiagramElementTool.isAppliesToDiagramRoot());
singleClickOnDiagramElementTool.getDialogDescriptionId(), singleClickOnDiagramElementTool.isAppliesToDiagramRoot(), singleClickOnDiagramElementTool.isWithImpactAnalysis());
}
if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool singleClickOnTwoDiagramElementsTool) {
List<SingleClickOnTwoDiagramElementsCandidate> candidates = new ArrayList<>();
Expand Down Expand Up @@ -302,26 +303,26 @@ private List<ToolSection> createExtraToolSections(Object diagramElementDescripti
} else {
targetDescriptions.addAll(edgeDescription.getSourceNodeDescriptions());
}
unsynchronizedMapping = SynchronizationPolicy.UNSYNCHRONIZED.equals(((EdgeDescription) diagramElementDescription).getSynchronizationPolicy());
unsynchronizedMapping = SynchronizationPolicy.UNSYNCHRONIZED.equals(edgeDescription.getSynchronizationPolicy());
}

// Graphical Delete Tool for unsynchronized mapping only (the handler is never called)
if (diagramElementDescription instanceof NodeDescription || diagramElementDescription instanceof EdgeDescription) {
// Edit Tool (the handler is never called)
SingleClickOnDiagramElementTool editTool = new SingleClickOnDiagramElementTool("edit", "Edit", List.of(DiagramImageConstants.EDIT_SVG), targetDescriptions, null, false);
SingleClickOnDiagramElementTool editTool = new SingleClickOnDiagramElementTool("edit", "Edit", List.of(DiagramImageConstants.EDIT_SVG), targetDescriptions, null, false, false);
var editToolSection = new ToolSection("edit-section", "", List.of(), List.of(editTool));
extraToolSections.add(editToolSection);

if (unsynchronizedMapping) {
SingleClickOnDiagramElementTool graphicalDeleteTool = new SingleClickOnDiagramElementTool("graphical-delete", "Delete from diagram",
List.of(DiagramImageConstants.GRAPHICAL_DELETE_SVG), targetDescriptions, null, false);
List.of(DiagramImageConstants.GRAPHICAL_DELETE_SVG), targetDescriptions, null, false, false);
var graphicalDeleteToolSection = new ToolSection("graphical-delete-section", "", List.of(), List.of(graphicalDeleteTool));
extraToolSections.add(graphicalDeleteToolSection);
}

// Semantic Delete Tool (the handler is never called)
SingleClickOnDiagramElementTool semanticDeleteTool = new SingleClickOnDiagramElementTool("semantic-delete", "Delete from model",
List.of(DiagramImageConstants.SEMANTIC_DELETE_SVG), targetDescriptions, null, false);
List.of(DiagramImageConstants.SEMANTIC_DELETE_SVG), targetDescriptions, null, false, false);
var graphicalDeleteToolSection = new ToolSection("semantic-delete-section", "", List.of(), List.of(semanticDeleteTool));
extraToolSections.add(graphicalDeleteToolSection);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2024 Obeo.
* Copyright (c) 2021, 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
Expand All @@ -24,6 +24,9 @@
* @author sbegaudeau
*/
public interface IRepresentationSearchService {

Optional<IRepresentation> findById(IEditingContext editingContext, String representationId);

<T extends IRepresentation> Optional<T> findById(IEditingContext editingContext, String representationId, Class<T> representationClass);

boolean existByIdAndKind(String representationId, List<String> kinds);
Expand All @@ -35,6 +38,11 @@ public interface IRepresentationSearchService {
*/
class NoOp implements IRepresentationSearchService {

@Override
public Optional<IRepresentation> findById(IEditingContext editingContext, String representationId) {
return Optional.empty();
}

@Override
public <T extends IRepresentation> Optional<T> findById(IEditingContext editingContext, String representationId, Class<T> representationClass) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* 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.components.collaborative.api;

import java.util.List;

import org.eclipse.sirius.components.collaborative.dto.ToolVariable;
import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.components.representations.IRepresentation;
import org.eclipse.sirius.components.representations.IStatus;

/**
* Used to execute a tool on a representation.
*
* @author frouene
*/
public interface IToolRepresentationExecutor {

boolean canExecute(IEditingContext editingContext, IRepresentation representation);

IStatus execute(IEditingContext editingContext, IRepresentation representation, String toolId, String targetObjectId, List<ToolVariable> variables);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* 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.components.collaborative.dto;

import java.util.List;

/**
* Report with data to display on an impact analysis.
*
* @author frouene
*/
public record ImpactAnalysisReport(int nbElementDeleted, int nbElementModified, int nbElementCreated, List<String> additionalReports) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*******************************************************************************
* 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.components.collaborative.dto;

import java.util.List;
import java.util.UUID;

import org.eclipse.sirius.components.core.api.IInput;

/**
* The input for the "impact analysis" query.
*
* @author frouene
*/
public record InvokeImpactAnalysisToolInput(UUID id, String editingContextId, String representationId, String toolId, String targetObjectId, List<ToolVariable> variables) implements IInput {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2022, 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.components.collaborative.dto;

import java.util.List;
import java.util.Objects;
import java.util.UUID;

import org.eclipse.sirius.components.core.api.IPayload;
import org.eclipse.sirius.components.representations.Message;

/**
* The "initial direct edit element label" success payload.
*
* @author gcoutable
*/
public record InvokeImpactAnalysisToolSuccessPayload(UUID id, ImpactAnalysisReport impactAnalysisReport, List<Message> messages) implements IPayload {

public InvokeImpactAnalysisToolSuccessPayload {
Objects.requireNonNull(id);
Objects.requireNonNull(impactAnalysisReport);
Objects.requireNonNull(messages);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 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
Expand All @@ -10,7 +10,7 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.components.collaborative.diagrams.dto;
package org.eclipse.sirius.components.collaborative.dto;

/**
* Represents a ToolVariable entry.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 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
Expand All @@ -10,7 +10,7 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.components.collaborative.diagrams.dto;
package org.eclipse.sirius.components.collaborative.dto;

/**
* Represent the Type of the Tool Variable.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extend type RepresentationMetadata {
impactAnalysisReport(toolId: ID!, targetObjectId: ID!, variables: [ToolVariable!]!): ImpactAnalysisReport!
}

type ImpactAnalysisReport {
nbElementDeleted: Int!
nbElementModified: Int!
nbElementCreated: Int!
additionalReports: [String!]!
}
Loading

0 comments on commit c1a0064

Please sign in to comment.