Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

- https://github.com/eclipse-syson/syson/issues/893[#893] [explorer] Fix _Expand All_ tool in SysON _Explorer_ view
- https://github.com/eclipse-syson/syson/issues/1398[#1398] [explorer] Fix an issue where a d'n'd of an `Element` in a diagram exposed the `Element` twice in the `ViewUsage` associated to the diagram.
- https://github.com/eclipse-syson/syson/issues/1411[#1411] [syson] Fix an issue where model and diagrams referencing standard libraries elements might not correctly loaded.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*******************************************************************************
* 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.syson.application.migration;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;

import java.util.Objects;

import org.eclipse.sirius.components.collaborative.representations.migration.IRepresentationMigrationParticipant;
import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.components.core.api.IObjectSearchService;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.util.ElementUtil;
import org.springframework.stereotype.Service;

/**
* Diagram migration participant used to migrate SysON diagrams with diagram elements having "targetObjectId" pointing
* to standard libraries Elements previous to 2025.8.0.
*
* Let's say we have a Start node pointing to the Actions::Action::start Element from the standard library. This node
* had for "targetObjectId" the "id" of the object instead of its "elementId". But the "id" property changes each time
* the standard libraries are updated. So the "targetObjectId" reference was pointing to nothing after the update. With
* this migration participant, the "targetObjectId" now all point to the "elementId" property which is stable
* before/after standard libraries updates.
*
* This migration participant has been added at the same time than the update of SysONIdentityService which allows to
* get the "elementId" instead of the "id" when it is a library Element.
*
* @author arichard
*/
@Service
public class StandardLibrariesElementsDiagramMigrationParticipant implements IRepresentationMigrationParticipant {

private static final String PARTICIPANT_VERSION = "2025.8.0-202506301700";

private final IObjectSearchService objectSearchService;

public StandardLibrariesElementsDiagramMigrationParticipant(IObjectSearchService objectSearchService) {
this.objectSearchService = Objects.requireNonNull(objectSearchService);
}

@Override
public String getVersion() {
return PARTICIPANT_VERSION;
}

@Override
public String getKind() {
return "siriusComponents://representation?type=Diagram";
}

@Override
public void replaceJsonNode(IEditingContext editingContext, ObjectNode root, String currentAttribute, JsonNode currentValue) {
if (currentAttribute.equals("targetObjectId") && currentValue instanceof TextNode textNode) {
var optElement = this.objectSearchService.getObject(editingContext, textNode.asText())
.filter(Element.class::isInstance)
.map(Element.class::cast);
if (optElement.isPresent()) {
var element = optElement.get();
if (ElementUtil.isStandardLibraryResource(element.eResource())) {
root.put("targetObjectId", element.getElementId());
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*******************************************************************************
* 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.syson.application.migration;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.sirius.components.emf.migration.api.IMigrationParticipant;
import org.eclipse.sirius.emfjson.resource.JsonResource;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.util.ElementUtil;
import org.springframework.stereotype.Service;

/**
* Diagram migration participant used to migrate SysON diagrams with diagram elements having "targetObjectId" pointing
* to standard libraries Elements previous to 2025.8.0.
*
* Let's say we have a FeatureTyping pointing to the SclaraValues::String Element from the standard library. This
* element had for "targetObjectId" the "id" of the object instead of its "elementId". But the "id" property changes
* each time the standard libraries are updated. So the "targetObjectId" reference was pointing to nothing after the
* update. With this migration participant, the "targetObjectId" now all point to the "elementId" property which is
* stable before/after standard libraries updates.
*
* This migration participant has been added at the same time than the update of SysONIdentityService which allows to
* get the "elementId" instead of the "id" when it is a library Element.
*
* @author arichard
*/
@Service
public class StandardLibrariesElementsReferencesMigrationParticipant implements IMigrationParticipant {

private static final String PARTICIPANT_VERSION = "2025.8.0-202506301600";

@Override
public String getVersion() {
return PARTICIPANT_VERSION;
}

@Override
public String getEObjectUri(JsonResource resource, EObject eObject, EReference eReference, String uri) {
if (!eReference.isContainment() && (uri.contains(ElementUtil.SYSML_LIBRARY_SCHEME) || uri.contains(ElementUtil.KERML_LIBRARY_SCHEME))) {
ResourceSet resourceSet = resource.getResourceSet();
String uriWithoutPrefixedType = uri;
if (uri.startsWith("sysml:")) {
if (uri.contains(ElementUtil.SYSML_LIBRARY_SCHEME)) {
int indexOf = uri.indexOf(ElementUtil.SYSML_LIBRARY_SCHEME);
uriWithoutPrefixedType = uri.substring(indexOf);
} else if (uri.contains(ElementUtil.KERML_LIBRARY_SCHEME)) {
int indexOf = uri.indexOf(ElementUtil.KERML_LIBRARY_SCHEME);
uriWithoutPrefixedType = uri.substring(indexOf);
}
}
URI uriAsURI = URI.createURI(uriWithoutPrefixedType);
EObject referencedEObject = resourceSet.getEObject(uriAsURI, false);
if (referencedEObject instanceof Element element) {
int uriFragmentIndex = uri.indexOf('#');
var prefix = uri.substring(0, uriFragmentIndex + 1);
return prefix + element.getElementId();
}
}
return uri;
}
}
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 @@ -17,6 +17,7 @@
import org.eclipse.sirius.components.core.api.IDefaultIdentityService;
import org.eclipse.sirius.components.core.api.IIdentityServiceDelegate;
import org.eclipse.sirius.components.emf.services.IDAdapter;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.Relationship;
import org.eclipse.syson.sysml.util.ElementUtil;
import org.springframework.stereotype.Service;
Expand All @@ -39,12 +40,17 @@ public SysONIdentityService(IDefaultIdentityService defaultIdentityService) {

@Override
public boolean canHandle(Object object) {
return object instanceof Relationship;
return object instanceof Element;
}

@Override
public String getId(Object object) {
var id = this.defaultIdentityService.getId(object);
String id = null;
if (object instanceof Element element && ElementUtil.isFromStandardLibrary(element)) {
id = element.getElementId();
} else {
id = this.defaultIdentityService.getId(object);
}
if (id == null && object instanceof Relationship relationship && relationship.isIsImplied()) {
var idAdapter = new IDAdapter(ElementUtil.generateUUID(relationship));
relationship.eAdapters().add(idAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ public void tearDown() {
}
}

@DisplayName("Given a Part Definition, when using the 'New TextualRepresentation' tool, then a new node should be created with an edge connecting it to the PartDefinition")
@DisplayName("GIVEN a Part Definition, WHEN using the 'New TextualRepresentation' tool, THEN a new node should be created with an edge connecting it to the PartDefinition")
@Test
@Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
public void createTextualRepresentation() {
String parentLabel = "part";
Expand Down Expand Up @@ -196,9 +197,10 @@ public void createTextualRepresentation() {
this.semanticCheckerService.checkEditingContext(semanticChecker, this.verifier);
}

@DisplayName("Given a TextualRepresentation, when using the 'Direct Edit' tool, then the body of the textual representation should be updated")
@DisplayName("GIVEN a TextualRepresentation, WHEN using the 'Direct Edit' tool, THEN the body of the textual representation should be updated")
@Test
@Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
public void directEditTextualRepresentation() {
this.directEditInitialLabelTester.checkDirectEditInitialLabelOnNode(this.verifier, this.diagram, GeneralViewWithTopNodesTestProjectData.GraphicalIds.PART_DEFINITION_TEXTUAL_REP_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public void tearDown() {
}
}

@DisplayName("Given a SysML Project, when New Port tool is requested on a PartUsage, then a new PortUsage border node is created")
@Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@DisplayName("GIVEN a SysML Project, WHEN New Port tool is requested on a PartUsage, THEN a new PortUsage border node is created")
@Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@Test
public void testApplyTool() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public static final class SemanticIds {

public static final String STOA4_ID = "2889857b-02e6-4f55-9ef3-1d2bfe404098";

public static final String START_ACTION_USAGE_ID = "03262155-734a-473f-9535-262925cd5b8b";
public static final String START_ACTION_USAGE_ID = "9a0d2905-0f9c-5bb4-af74-9780d6db1817";

public static final String DONE_ACTION_USAGE_ID = "6f9d8315-c293-4910-9688-668196eb8ec5";
public static final String DONE_ACTION_USAGE_ID = "0cdc3cd3-b06c-5c32-beda-0cf4ba164a64";
}
}
Loading