Skip to content

Commit f3a5785

Browse files
sbegaudeauAxelRICHARD
authored andcommitted
[cleanup] Remove the use of IObjectService to prepare for changes in SW
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@gmail.com>
1 parent 6bb2a6b commit f3a5785

File tree

33 files changed

+173
-151
lines changed

33 files changed

+173
-151
lines changed

backend/application/syson-application-configuration/src/main/java/org/eclipse/syson/application/services/SysMLv2EditService.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023, 2024 Obeo.
2+
* Copyright (c) 2023, 2025 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -28,7 +28,7 @@
2828
import org.eclipse.sirius.components.core.api.IDefaultEditService;
2929
import org.eclipse.sirius.components.core.api.IEditServiceDelegate;
3030
import org.eclipse.sirius.components.core.api.IEditingContext;
31-
import org.eclipse.sirius.components.core.api.IObjectService;
31+
import org.eclipse.sirius.components.core.api.ILabelService;
3232
import org.eclipse.sirius.components.emf.services.api.IEMFEditingContext;
3333
import org.eclipse.sirius.components.emf.services.api.IEMFKindService;
3434
import org.eclipse.syson.services.DeleteService;
@@ -56,17 +56,17 @@ public class SysMLv2EditService implements IEditServiceDelegate {
5656

5757
private final IDefaultEditService defaultEditService;
5858

59-
private final IObjectService objectService;
59+
private final ILabelService labelService;
6060

6161
private final IEMFKindService emfKindService;
6262

6363
private final DeleteService deleteService;
6464

6565
private final UtilService utilService;
6666

67-
public SysMLv2EditService(IDefaultEditService defaultEditService, IObjectService objectService, IEMFKindService emfKindService) {
67+
public SysMLv2EditService(IDefaultEditService defaultEditService, ILabelService labelService, IEMFKindService emfKindService) {
6868
this.defaultEditService = Objects.requireNonNull(defaultEditService);
69-
this.objectService = Objects.requireNonNull(objectService);
69+
this.labelService = Objects.requireNonNull(labelService);
7070
this.emfKindService = Objects.requireNonNull(emfKindService);
7171
this.deleteService = new DeleteService();
7272
this.utilService = new UtilService();
@@ -87,14 +87,14 @@ public List<ChildCreationDescription> getRootCreationDescriptions(IEditingContex
8787
final List<ChildCreationDescription> rootObjectCreationDescription = new ArrayList<>();
8888
if (SysmlPackage.eNS_URI.equals(domainId)) {
8989
if (suggested) {
90-
List<String> iconURL = this.objectService.getImagePath(EcoreUtil.create(SysmlPackage.eINSTANCE.getPackage()));
91-
String label = this.objectService.getLabel(SysmlPackage.eINSTANCE.getPackage());
90+
List<String> iconURL = this.labelService.getImagePath(EcoreUtil.create(SysmlPackage.eINSTANCE.getPackage()));
91+
String label = this.labelService.getLabel(SysmlPackage.eINSTANCE.getPackage());
9292
rootObjectCreationDescription.add(new ChildCreationDescription(ID_PREFIX + SysmlPackage.eINSTANCE.getPackage().getName(), label, iconURL));
9393
} else {
9494
List<EClass> childrenCandidates = new GetChildCreationSwitch().doSwitch(SysmlPackage.eINSTANCE.getNamespace());
9595
childrenCandidates.forEach(candidate -> {
96-
List<String> iconURL = this.objectService.getImagePath(EcoreUtil.create(candidate));
97-
String label = this.objectService.getLabel(candidate);
96+
List<String> iconURL = this.labelService.getImagePath(EcoreUtil.create(candidate));
97+
String label = this.labelService.getLabel(candidate);
9898
ChildCreationDescription childCreationDescription = new ChildCreationDescription(ID_PREFIX + candidate.getName(), label, iconURL);
9999
rootObjectCreationDescription.add(childCreationDescription);
100100
});
@@ -117,8 +117,8 @@ public List<ChildCreationDescription> getChildCreationDescriptions(IEditingConte
117117
if (eClass.isPresent()) {
118118
List<EClass> childrenCandidates = new GetChildCreationSwitch().doSwitch(eClass.get());
119119
childrenCandidates.forEach(candidate -> {
120-
List<String> iconURL = this.objectService.getImagePath(EcoreUtil.create(candidate));
121-
String label = this.objectService.getLabel(candidate);
120+
List<String> iconURL = this.labelService.getImagePath(EcoreUtil.create(candidate));
121+
String label = this.labelService.getLabel(candidate);
122122
ChildCreationDescription childCreationDescription = new ChildCreationDescription(ID_PREFIX + candidate.getName(), label, iconURL);
123123
childCreationDescriptions.add(childCreationDescription);
124124
});

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controller/editingContext/checkers/CheckElementInParent.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Obeo.
2+
* Copyright (c) 2024, 2025 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -21,7 +21,7 @@
2121
import org.eclipse.emf.ecore.EClass;
2222
import org.eclipse.emf.ecore.EReference;
2323
import org.eclipse.sirius.components.core.api.IEditingContext;
24-
import org.eclipse.sirius.components.core.api.IObjectService;
24+
import org.eclipse.sirius.components.core.api.IObjectSearchService;
2525
import org.eclipse.syson.sysml.Element;
2626
import org.eclipse.syson.sysml.helper.EMFUtils;
2727

@@ -32,7 +32,7 @@
3232
*/
3333
public class CheckElementInParent implements ISemanticChecker {
3434

35-
private final IObjectService objectService;
35+
private final IObjectSearchService objectSearchService;
3636

3737
private final String rootElementId;
3838

@@ -42,8 +42,8 @@ public class CheckElementInParent implements ISemanticChecker {
4242

4343
private EClass eClass;
4444

45-
public CheckElementInParent(IObjectService objectService, String rootElementId) {
46-
this.objectService = Objects.requireNonNull(objectService);
45+
public CheckElementInParent(IObjectSearchService objectSearchService, String rootElementId) {
46+
this.objectSearchService = Objects.requireNonNull(objectSearchService);
4747
this.rootElementId = Objects.requireNonNull(rootElementId);
4848
}
4949

@@ -64,7 +64,7 @@ public CheckElementInParent hasType(EClass expectedType) {
6464

6565
@Override
6666
public void check(IEditingContext editingContext) {
67-
Object semanticRootObject = this.objectService.getObject(editingContext, this.rootElementId).orElse(null);
67+
Object semanticRootObject = this.objectSearchService.getObject(editingContext, this.rootElementId).orElse(null);
6868
assertThat(semanticRootObject).isInstanceOf(Element.class);
6969
Element semanticRootElement = (Element) semanticRootObject;
7070
Optional<Element> optParentElement = EMFUtils.allContainedObjectOfType(semanticRootElement, Element.class)

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controller/editingContext/checkers/SemanticCheckerService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.eclipse.emf.ecore.EClass;
1616
import org.eclipse.emf.ecore.EReference;
1717
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload;
18-
import org.eclipse.sirius.components.core.api.IObjectService;
18+
import org.eclipse.sirius.components.core.api.IObjectSearchService;
1919
import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionSuccessPayload;
2020
import org.eclipse.syson.application.data.SysMLv2Identifiers;
2121
import org.eclipse.syson.services.SemanticRunnableFactory;
@@ -31,15 +31,15 @@ public class SemanticCheckerService {
3131

3232
private final SemanticRunnableFactory semanticRunnableFactory;
3333

34-
private final IObjectService objectService;
34+
private final IObjectSearchService objectSearchService;
3535

36-
public SemanticCheckerService(SemanticRunnableFactory semanticRunnableFactory, IObjectService objectService) {
36+
public SemanticCheckerService(SemanticRunnableFactory semanticRunnableFactory, IObjectSearchService objectSearchService) {
3737
this.semanticRunnableFactory = semanticRunnableFactory;
38-
this.objectService = objectService;
38+
this.objectSearchService = objectSearchService;
3939
}
4040

4141
public ISemanticChecker getElementInParentSemanticChecker(String parentLabel, EReference containmentReference, EClass childEClass) {
42-
return new CheckElementInParent(this.objectService, SysMLv2Identifiers.GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT)
42+
return new CheckElementInParent(this.objectSearchService, SysMLv2Identifiers.GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT)
4343
.withParentLabel(parentLabel)
4444
.withContainmentReference(containmentReference)
4545
.hasType(childEClass);

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVAddNewFeatureTypingFromPartUsageTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.eclipse.emf.ecore.EObject;
2424
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput;
2525
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload;
26-
import org.eclipse.sirius.components.core.api.IObjectService;
26+
import org.eclipse.sirius.components.core.api.IObjectSearchService;
2727
import org.eclipse.sirius.components.diagrams.Diagram;
2828
import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionSuccessPayload;
2929
import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider;
@@ -88,7 +88,7 @@ public class GVAddNewFeatureTypingFromPartUsageTests extends AbstractIntegration
8888
private IDiagramIdProvider diagramIdProvider;
8989

9090
@Autowired
91-
private IObjectService objectService;
91+
private IObjectSearchService objectSearchService;
9292

9393
@Autowired
9494
private NodeCreationTester nodeCreationTester;
@@ -173,7 +173,7 @@ public void testApplyTool(EClass eClass, String nodeName, int definitionCompartm
173173

174174
Runnable semanticChecker = this.semanticRunnableFactory.createRunnable(SysMLv2Identifiers.GENERAL_VIEW_EMPTY_EDITING_CONTEXT_ID,
175175
(editingContext, executeEditingContextFunctionInput) -> {
176-
Object semanticRootObject = this.objectService.getObject(editingContext, SysMLv2Identifiers.GENERAL_VIEW_EMPTY_DIAGRAM_OBJECT).orElse(null);
176+
Object semanticRootObject = this.objectSearchService.getObject(editingContext, SysMLv2Identifiers.GENERAL_VIEW_EMPTY_DIAGRAM_OBJECT).orElse(null);
177177
assertThat(semanticRootObject).isInstanceOf(Element.class);
178178
Element semanticRootElement = (Element) semanticRootObject;
179179
assertThat(semanticRootElement).isNotNull();

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVDropFromExplorerTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput;
2727
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload;
2828
import org.eclipse.sirius.components.core.api.IEditingContext;
29-
import org.eclipse.sirius.components.core.api.IObjectService;
29+
import org.eclipse.sirius.components.core.api.IIdentityService;
30+
import org.eclipse.sirius.components.core.api.IObjectSearchService;
3031
import org.eclipse.sirius.components.diagrams.Diagram;
3132
import org.eclipse.sirius.components.diagrams.Node;
3233
import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionSuccessPayload;
@@ -87,7 +88,10 @@ public class GVDropFromExplorerTests extends AbstractIntegrationTests {
8788
private IDiagramIdProvider diagramIdProvider;
8889

8990
@Autowired
90-
private IObjectService objectService;
91+
private IIdentityService identityService;
92+
93+
@Autowired
94+
private IObjectSearchService objectSearchService;
9195

9296
@Autowired
9397
private DropFromExplorerTester dropFromExplorerTester;
@@ -218,13 +222,13 @@ public void dropFromExplorerOnEmptyDiagramNode() {
218222
}
219223

220224
private String getSemanticElementWithTargetObjectLabel(IEditingContext editingContext, String targetObjectLabel) {
221-
Object semanticRootObject = this.objectService.getObject(editingContext,
225+
Object semanticRootObject = this.objectSearchService.getObject(editingContext,
222226
SysMLv2Identifiers.GENERAL_VIEW_ADD_EXISTING_ELEMENTS_DIAGRAM_OBJECT).orElse(null);
223227
assertThat(semanticRootObject).isInstanceOf(Package.class);
224228
Package rootPackage = (Package) semanticRootObject;
225229
Optional<Element> optPartUsage = rootPackage.getOwnedMember().stream().filter(m -> Objects.equals(m.getName(), targetObjectLabel)).findFirst();
226230
assertThat(optPartUsage).isPresent();
227-
String partUsageId = this.objectService.getId(optPartUsage.get());
231+
String partUsageId = this.identityService.getId(optPartUsage.get());
228232
assertThat(partUsageId).isNotNull();
229233
return partUsageId;
230234
}

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVEdgeCreationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput;
2222
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload;
23-
import org.eclipse.sirius.components.core.api.IObjectService;
23+
import org.eclipse.sirius.components.core.api.IObjectSearchService;
2424
import org.eclipse.sirius.components.diagrams.ArrowStyle;
2525
import org.eclipse.sirius.components.diagrams.Diagram;
2626
import org.eclipse.sirius.components.diagrams.Edge;
@@ -82,7 +82,7 @@ public class GVEdgeCreationTests extends AbstractIntegrationTests {
8282
private IDiagramIdProvider diagramIdProvider;
8383

8484
@Autowired
85-
private IObjectService objectService;
85+
private IObjectSearchService objectSearchService;
8686

8787
@Autowired
8888
private EdgeCreationTester edgeCreationTester;
@@ -120,7 +120,7 @@ public void setUp() {
120120
SysMLv2Identifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID);
121121
this.diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(this.diagramDescription, this.diagramIdProvider);
122122
this.diagramCheckerService = new DiagramCheckerService(this.diagramComparator, this.descriptionNameGenerator);
123-
this.semanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectService);
123+
this.semanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectSearchService);
124124
}
125125

126126
@AfterEach

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeActionFlowCreationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload;
3131
import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariable;
3232
import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariableType;
33-
import org.eclipse.sirius.components.core.api.IObjectService;
33+
import org.eclipse.sirius.components.core.api.IObjectSearchService;
3434
import org.eclipse.sirius.components.diagrams.Diagram;
3535
import org.eclipse.sirius.components.diagrams.Node;
3636
import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator;
@@ -110,7 +110,7 @@ public class GVSubNodeActionFlowCreationTests extends AbstractIntegrationTests {
110110
private IDiagramIdProvider diagramIdProvider;
111111

112112
@Autowired
113-
private IObjectService objectService;
113+
private IObjectSearchService objectSearchService;
114114

115115
@Autowired
116116
private NodeCreationTester nodeCreationTester;
@@ -200,7 +200,7 @@ public void setUp() {
200200
this.diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(this.diagramDescription, this.diagramIdProvider);
201201
this.creationTestsService = new NodeCreationTestsService(this.nodeCreationTester, this.descriptionNameGenerator);
202202
this.diagramCheckerService = new DiagramCheckerService(this.diagramComparator, this.descriptionNameGenerator);
203-
this.semanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectService);
203+
this.semanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectSearchService);
204204
}
205205

206206
@AfterEach
@@ -240,7 +240,7 @@ public void createAcceptActionUsagePayload(EClass eClass) {
240240
this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier);
241241

242242
ISemanticChecker semanticChecker = (editingContext) -> {
243-
Object semanticRootObject = this.objectService.getObject(editingContext, SysMLv2Identifiers.GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT).orElse(null);
243+
Object semanticRootObject = this.objectSearchService.getObject(editingContext, SysMLv2Identifiers.GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT).orElse(null);
244244
assertThat(semanticRootObject).isInstanceOf(Element.class);
245245
Element semanticRootElement = (Element) semanticRootObject;
246246
Optional<Element> optParentElement = EMFUtils.allContainedObjectOfType(semanticRootElement, Element.class)
@@ -287,7 +287,7 @@ public void createAcceptActionUsageReceiver() {
287287
this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier);
288288

289289
ISemanticChecker semanticChecker = (editingContext) -> {
290-
Object semanticRootObject = this.objectService.getObject(editingContext, SysMLv2Identifiers.GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT).orElse(null);
290+
Object semanticRootObject = this.objectSearchService.getObject(editingContext, SysMLv2Identifiers.GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT).orElse(null);
291291
assertThat(semanticRootObject).isInstanceOf(Element.class);
292292
Element semanticRootElement = (Element) semanticRootObject;
293293
Optional<Element> optParentElement = EMFUtils.allContainedObjectOfType(semanticRootElement, Element.class)

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeAnalysisCreationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload;
3232
import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariable;
3333
import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariableType;
34-
import org.eclipse.sirius.components.core.api.IObjectService;
34+
import org.eclipse.sirius.components.core.api.IObjectSearchService;
3535
import org.eclipse.sirius.components.diagrams.Diagram;
3636
import org.eclipse.sirius.components.view.diagram.DiagramDescription;
3737
import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider;
@@ -102,7 +102,7 @@ public class GVSubNodeAnalysisCreationTests extends AbstractIntegrationTests {
102102
private IDiagramIdProvider diagramIdProvider;
103103

104104
@Autowired
105-
private IObjectService objectService;
105+
private IObjectSearchService objectSearchService;
106106

107107
@Autowired
108108
private NodeCreationTester nodeCreationTester;
@@ -185,7 +185,7 @@ public void setUp() {
185185
this.diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(this.diagramDescription, this.diagramIdProvider);
186186
this.creationTestsService = new NodeCreationTestsService(this.nodeCreationTester, this.descriptionNameGenerator);
187187
this.diagramCheckerService = new DiagramCheckerService(this.diagramComparator, this.descriptionNameGenerator);
188-
this.semanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectService);
188+
this.semanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectSearchService);
189189
}
190190

191191
@AfterEach
@@ -317,7 +317,7 @@ private void createNewSubjectInCaseUsageSubclass(EClass caseUsageSubclass, Strin
317317
};
318318
this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier);
319319
ISemanticChecker semanticChecker = (editingContext) -> {
320-
Object semanticRootObject = this.objectService.getObject(editingContext, SysMLv2Identifiers.GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT).orElse(null);
320+
Object semanticRootObject = this.objectSearchService.getObject(editingContext, SysMLv2Identifiers.GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT).orElse(null);
321321
assertThat(semanticRootObject).isInstanceOf(Element.class);
322322
Element semanticRootElement = (Element) semanticRootObject;
323323
Optional<ReferenceUsage> optParentElement = EMFUtils.allContainedObjectOfType(semanticRootElement, ReferenceUsage.class)

0 commit comments

Comments
 (0)