diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 93bc74481a6..795102be4ce 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -50,7 +50,10 @@ As a result, the following maven modules have been deleted: `sirius-web-sample-a * The `String` attribute `org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolInput#selectedObjectId` has been replaced by the attribute `variables` of type `List` - https://github.com/eclipse-sirius/sirius-web/issues/3437[#3437] [core] Migrate frontend to MUI 5, if you contributed React componenent that use MUI, you should upgrade them to use MUI 5. -- https://github.com/eclipse-sirius/sirius-web/issues/3678[#3678] [core] Remove `IRepresentationMetadataSearchService#findByRepresentation`, use `IRepresentationMetadataSearchService#findByRepresentationId` instead. +- https://github.com/eclipse-sirius/sirius-web/issues/3678[#3678] [core] Remove `IRepresentationMetadataSearchService#findByRepresentation`, use `IRepresentationMetadataSearchService#findByRepresentationId` instead. +- https://github.com/eclipse-sirius/sirius-web/issues/3679[#3679] [core] Split representation metadata from content ++ Remove `org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService` and its implementation. ++ Use `org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService#findAllMetadataByTargetObjectId` instead of `org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService#findAllByTargetObjectId`. === Dependency update diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/configuration/CompatibilityConfiguration.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/configuration/CompatibilityConfiguration.java index fd967d64feb..cb327e347b8 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/configuration/CompatibilityConfiguration.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/configuration/CompatibilityConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 THALES GLOBAL SERVICES and others. + * Copyright (c) 2019, 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 @@ -23,7 +23,6 @@ import org.eclipse.sirius.components.compatibility.emf.diagrams.CanCreateDiagramPredicate; import org.eclipse.sirius.components.compatibility.emf.modeloperations.ModelOperationHandlerSwitch; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -46,9 +45,9 @@ public ICanCreateDiagramPredicateFactory canCreateDiagramPredicateFactory() { } @Bean - public IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, + public IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider(IObjectService objectService, IIdentifierProvider identifierProvider, List externalJavaActionProviders) { - return (interpreter) -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, externalJavaActionProviders, interpreter); + return (interpreter) -> new ModelOperationHandlerSwitch(objectService, identifierProvider, externalJavaActionProviders, interpreter); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ChangeContextOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ChangeContextOperationHandler.java index 445564e89fe..a313bd47320 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ChangeContextOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ChangeContextOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -21,7 +21,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.VariableManager; @@ -37,8 +36,6 @@ public class ChangeContextOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -47,10 +44,9 @@ public class ChangeContextOperationHandler implements IModelOperationHandler { private final ChangeContext changeContext; - public ChangeContextOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public ChangeContextOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, ChangeContext changeContext) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -67,7 +63,7 @@ public IStatus handle(Map variables) { } List subModelOperations = this.changeContext.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ChildModelOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ChildModelOperationHandler.java index 2eac9b4a9be..60e88dfe30c 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ChildModelOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ChildModelOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -21,7 +21,6 @@ import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.compatibility.emf.api.IExternalJavaActionProvider; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.Failure; import org.eclipse.sirius.components.representations.IStatus; @@ -42,12 +41,12 @@ public ChildModelOperationHandler(List externalJava this.externalJavaActionProviders = Objects.requireNonNull(externalJavaActionProviders); } - public IStatus handle(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, + public IStatus handle(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, Map variables, List modelOperations) { Success success = new Success(); boolean hasBeenSuccessfullyExecuted = true; - ModelOperationHandlerSwitch modelOperationHandlerSwitch = new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, + ModelOperationHandlerSwitch modelOperationHandlerSwitch = new ModelOperationHandlerSwitch(objectService, identifierProvider, this.externalJavaActionProviders, interpreter); for (ModelOperation modelOperation : modelOperations) { Optional optionalModelOperationHandler = modelOperationHandlerSwitch.apply(modelOperation); diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/CreateInstanceOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/CreateInstanceOperationHandler.java index b43870bfc1f..49f8613379c 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/CreateInstanceOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/CreateInstanceOperationHandler.java @@ -26,10 +26,9 @@ import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; -import org.eclipse.sirius.components.emf.EPackageService; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; +import org.eclipse.sirius.components.emf.EPackageService; import org.eclipse.sirius.components.emf.services.api.IEMFEditingContext; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; @@ -57,8 +56,6 @@ public class CreateInstanceOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -69,11 +66,10 @@ public class CreateInstanceOperationHandler implements IModelOperationHandler { private final CreateInstance createInstance; - public CreateInstanceOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public CreateInstanceOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, EPackageService ePackageService, ChildModelOperationHandler childModelOperationHandler, CreateInstance createInstance) { this.objectService = Objects.requireNonNull(objectService); this.identifierProvider = Objects.requireNonNull(identifierProvider); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.interpreter = Objects.requireNonNull(interpreter); this.ePackageService = Objects.requireNonNull(ePackageService); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -133,6 +129,6 @@ public IStatus handle(Map variables) { } List subModelOperations = this.createInstance.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/CreateViewOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/CreateViewOperationHandler.java index 7133ec3bf29..6d8a73a6c2e 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/CreateViewOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/CreateViewOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2023 Obeo. + * Copyright (c) 2021, 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 @@ -23,7 +23,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.diagrams.Diagram; import org.eclipse.sirius.components.diagrams.Node; import org.eclipse.sirius.components.diagrams.ViewCreationRequest; @@ -50,8 +49,6 @@ public class CreateViewOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -60,10 +57,9 @@ public class CreateViewOperationHandler implements IModelOperationHandler { private final CreateView createView; - public CreateViewOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationSearchService, IIdentifierProvider identifierProvider, + public CreateViewOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, CreateView createView) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -77,11 +73,9 @@ public IStatus handle(Map variables) { var optionalParentElement = this.interpreter.evaluateExpression(variables, containerViewExpression).asObject(); var optionalParentElementId = optionalParentElement.flatMap(parentElement -> { Optional optionalElementId = Optional.empty(); - if (parentElement instanceof Diagram) { - Diagram diagram = (Diagram) parentElement; + if (parentElement instanceof Diagram diagram) { optionalElementId = Optional.of(diagram.getId()); - } else if (parentElement instanceof Node) { - Node node = (Node) parentElement; + } else if (parentElement instanceof Node node) { optionalElementId = Optional.of(node.getId()); } return optionalElementId; @@ -119,7 +113,7 @@ public IStatus handle(Map variables) { Map childVariables = new HashMap<>(variables); List subModelOperations = this.createView.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/DeleteViewOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/DeleteViewOperationHandler.java index 9e7a520dedc..e78b7b09e58 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/DeleteViewOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/DeleteViewOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2022 Obeo. + * Copyright (c) 2021, 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 @@ -22,7 +22,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.diagrams.Node; import org.eclipse.sirius.components.diagrams.ViewDeletionRequest; import org.eclipse.sirius.components.interpreter.AQLInterpreter; @@ -41,8 +40,6 @@ public class DeleteViewOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -51,10 +48,9 @@ public class DeleteViewOperationHandler implements IModelOperationHandler { private final DeleteView deleteView; - public DeleteViewOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationSearchService, IIdentifierProvider identifierProvider, + public DeleteViewOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, DeleteView deleteView) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -79,7 +75,7 @@ public IStatus handle(Map variables) { Map childVariables = new HashMap<>(variables); List subModelOperations = this.deleteView.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } return new Failure(""); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ExternalJavaActionOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ExternalJavaActionOperationHandler.java index 0faa93b175f..4de2debdecd 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ExternalJavaActionOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ExternalJavaActionOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2022 Obeo and others. + * Copyright (c) 2021, 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 @@ -23,7 +23,6 @@ import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.compatibility.emf.api.IExternalJavaActionProvider; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.Failure; import org.eclipse.sirius.components.representations.IStatus; @@ -46,8 +45,6 @@ public class ExternalJavaActionOperationHandler implements IModelOperationHandle private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -58,10 +55,9 @@ public class ExternalJavaActionOperationHandler implements IModelOperationHandle private final ExternalJavaAction externalJavaAction; - public ExternalJavaActionOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationSearchService, IIdentifierProvider identifierProvider, + public ExternalJavaActionOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, List externalJavaActionProviders, ExternalJavaAction externalJavaAction) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -98,7 +94,7 @@ public IStatus handle(Map variables) { } List subModelOperations = this.externalJavaAction.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, variables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, variables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ForOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ForOperationHandler.java index e5fa79ced1d..fe078be5615 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ForOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ForOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -21,7 +21,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; @@ -37,8 +36,6 @@ public class ForOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -47,10 +44,9 @@ public class ForOperationHandler implements IModelOperationHandler { private final For forOperation; - public ForOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public ForOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, For forOperation) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -73,7 +69,7 @@ public IStatus handle(Map variables) { childVariables.put(iteratedVariableName, object); List subModelOperations = this.forOperation.getSubModelOperations(); - this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/IfOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/IfOperationHandler.java index c4d98059d8d..1e83c12d8b0 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/IfOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/IfOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -20,7 +20,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; @@ -36,8 +35,6 @@ public class IfOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -46,10 +43,9 @@ public class IfOperationHandler implements IModelOperationHandler { private final If ifOperation; - public IfOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public IfOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, If ifOperation) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -64,7 +60,7 @@ public IStatus handle(Map variables) { if (optionalValueObject.isPresent() && optionalValueObject.get()) { List subModelOperations = this.ifOperation.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, variables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, variables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/LetOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/LetOperationHandler.java index 11e4201d6cb..83f34fc824a 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/LetOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/LetOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -21,7 +21,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.viewpoint.description.tool.Let; @@ -36,8 +35,6 @@ public class LetOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -46,10 +43,9 @@ public class LetOperationHandler implements IModelOperationHandler { private final Let letOperation; - public LetOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public LetOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, Let letOperation) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -73,7 +69,7 @@ public IStatus handle(Map variables) { } List subModelOperations = this.letOperation.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ModelOperationHandlerSwitch.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ModelOperationHandlerSwitch.java index 20e9cd2b6e6..e9f7142b7d1 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ModelOperationHandlerSwitch.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/ModelOperationHandlerSwitch.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2024 Obeo and others. + * Copyright (c) 2019, 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 @@ -19,10 +19,9 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; -import org.eclipse.sirius.components.emf.EPackageService; import org.eclipse.sirius.components.compatibility.emf.api.IExternalJavaActionProvider; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; +import org.eclipse.sirius.components.emf.EPackageService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.diagram.description.tool.CreateView; import org.eclipse.sirius.diagram.description.tool.Navigation; @@ -54,8 +53,6 @@ public class ModelOperationHandlerSwitch implements Function externalJavaActionProviders; @@ -64,10 +61,9 @@ public class ModelOperationHandlerSwitch implements Function externalJavaActionProviders, AQLInterpreter interpreter) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.externalJavaActionProviders = Objects.requireNonNull(externalJavaActionProviders); this.interpreter = Objects.requireNonNull(interpreter); @@ -121,51 +117,51 @@ public Optional apply(ModelOperation modelOperation) { } private Optional caseChangeContext(ChangeContext changeContextOperation) { - return Optional.of(new ChangeContextOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, + return Optional.of(new ChangeContextOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, changeContextOperation)); } private Optional caseCreateInstance(CreateInstance createInstanceOperation) { - return Optional.of(new CreateInstanceOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, new EPackageService(), + return Optional.of(new CreateInstanceOperationHandler(this.objectService, this.identifierProvider, this.interpreter, new EPackageService(), this.childModelOperationHandler, createInstanceOperation)); } private Optional caseCreateView(CreateView createViewOperation) { - return Optional.of(new CreateViewOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, + return Optional.of(new CreateViewOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, createViewOperation)); } private Optional caseDeleteView(DeleteView deleteViewOperation) { - return Optional.of(new DeleteViewOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, + return Optional.of(new DeleteViewOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, deleteViewOperation)); } private Optional caseFor(For forOperation) { return Optional - .of(new ForOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, forOperation)); + .of(new ForOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, forOperation)); } private Optional caseIf(If ifOperation) { return Optional - .of(new IfOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, ifOperation)); + .of(new IfOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, ifOperation)); } private Optional caseLet(Let letOperation) { return Optional - .of(new LetOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, letOperation)); + .of(new LetOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, letOperation)); } private Optional caseMoveElement(MoveElement moveElementOperation) { - return Optional.of(new MoveElementOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, + return Optional.of(new MoveElementOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, moveElementOperation)); } private Optional caseNavigation(Navigation navigationOperation) { - return Optional.of(new NavigationOperationHandler(this.objectService, this.identifierProvider, this.representationMetadataSearchService, this.interpreter, navigationOperation)); + return Optional.of(new NavigationOperationHandler(this.objectService, this.identifierProvider, this.interpreter, navigationOperation)); } private Optional caseRemoveElement(RemoveElement removeElementOperation) { - return Optional.of(new RemoveElementOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, + return Optional.of(new RemoveElementOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, removeElementOperation)); } @@ -174,22 +170,22 @@ private Optional caseSetObject(SetObject setObjectOperat } private Optional caseSetValue(SetValue setValueOperation) { - return Optional.of(new SetValueOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, + return Optional.of(new SetValueOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, setValueOperation)); } private Optional caseUnset(Unset unsetOperation) { return Optional.of( - new UnsetOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, unsetOperation)); + new UnsetOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, unsetOperation)); } private Optional caseSwitch(Switch switchOperation) { return Optional.of( - new SwitchOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, switchOperation)); + new SwitchOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, switchOperation)); } private Optional caseExternalJavaAction(ExternalJavaAction externalJavaAction) { - return Optional.of(new ExternalJavaActionOperationHandler(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, + return Optional.of(new ExternalJavaActionOperationHandler(this.objectService, this.identifierProvider, this.interpreter, this.childModelOperationHandler, this.externalJavaActionProviders, externalJavaAction)); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/MoveElementOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/MoveElementOperationHandler.java index 833e4730a42..152a0cf9f38 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/MoveElementOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/MoveElementOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -22,7 +22,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.VariableManager; @@ -42,8 +41,6 @@ public class MoveElementOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -52,10 +49,9 @@ public class MoveElementOperationHandler implements IModelOperationHandler { private final MoveElement moveElementOperation; - public MoveElementOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public MoveElementOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, MoveElement moveElementOperation) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -87,7 +83,7 @@ public IStatus handle(Map variables) { Map childVariables = new HashMap<>(variables); List subModelOperations = this.moveElementOperation.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } /** @@ -105,7 +101,6 @@ private void doMoveElement(EObject newContainer, EObject valueObject, String fea Object currentValueOnContainer = ecoreIntrinsicExtender.eGet(newContainer, featureName); if (currentValueOnContainer == null) { this.logger.warn("Impossible to add a value to the reference {} of the object {}", featureName, newContainer); - return; } } else { ecoreIntrinsicExtender.eAdd(newContainer, featureName, valueObject); diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/NavigationOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/NavigationOperationHandler.java index c1195e689bb..4d3a9fdcb36 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/NavigationOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/NavigationOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Obeo. + * Copyright (c) 2022, 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 @@ -20,7 +20,6 @@ import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; @@ -41,15 +40,12 @@ public class NavigationOperationHandler implements IModelOperationHandler { private final IIdentifierProvider identifierProvider; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final Navigation navigation; - public NavigationOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, IRepresentationMetadataSearchService representationMetadataSearchService, + public NavigationOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, Navigation navigation) { this.objectService = Objects.requireNonNull(objectService); this.identifierProvider = Objects.requireNonNull(identifierProvider); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.navigation = Objects.requireNonNull(navigation); } @@ -59,24 +55,14 @@ public IStatus handle(Map variables) { Object editingContextVariable = variables.get(IEditingContext.EDITING_CONTEXT); boolean createIfNotExistent = this.navigation.isCreateIfNotExistent(); - if (!createIfNotExistent && editingContextVariable instanceof IEditingContext) { - IEditingContext editingContext = (IEditingContext) editingContextVariable; + if (!createIfNotExistent && editingContextVariable instanceof IEditingContext editingContext) { DiagramDescription diagramDescription = this.navigation.getDiagramDescription(); String diagramDescriptionId = this.identifierProvider.getIdentifier(diagramDescription); Object self = variables.get(VariableManager.SELF); String selfId = this.objectService.getId(self); - // @formatter:off - List entries = this.representationMetadataSearchService.findAllByTargetObjectId(editingContext, selfId).stream() - .filter(representationMetadata -> representationMetadata.getDescriptionId().equals(diagramDescriptionId)) - .map(representationMetadata -> { - String id = representationMetadata.getId(); - String label = representationMetadata.getLabel(); - String kind = representationMetadata.getKind(); - return new WorkbenchSelectionEntry(id, label, kind); - }).toList(); - // @formatter:on + List entries = List.of(); if (!entries.isEmpty()) { WorkbenchSelection newSelection = new WorkbenchSelection(entries); success.getParameters().put(Success.NEW_SELECTION, newSelection); diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/RemoveElementOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/RemoveElementOperationHandler.java index c225a1492f4..127df7f1894 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/RemoveElementOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/RemoveElementOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -22,7 +22,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.VariableManager; @@ -41,8 +40,6 @@ public class RemoveElementOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -53,10 +50,9 @@ public class RemoveElementOperationHandler implements IModelOperationHandler { private final Logger logger = LoggerFactory.getLogger(RemoveElementOperationHandler.class); - public RemoveElementOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public RemoveElementOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, RemoveElement removeElementOperation) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -85,7 +81,7 @@ public IStatus handle(Map variables) { Map childVariables = new HashMap<>(variables); List subModelOperations = this.removeElementOperation.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/SetValueOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/SetValueOperationHandler.java index 741ac284467..f273bb0c8f1 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/SetValueOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/SetValueOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -22,7 +22,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.VariableManager; @@ -39,8 +38,6 @@ public class SetValueOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -49,10 +46,9 @@ public class SetValueOperationHandler implements IModelOperationHandler { private final SetValue setValue; - public SetValueOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public SetValueOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, SetValue setValue) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -82,7 +78,7 @@ public IStatus handle(Map variables) { Map childVariables = new HashMap<>(variables); List subModelOperations = this.setValue.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/SwitchOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/SwitchOperationHandler.java index 5dcf3fd7f3f..961adecac11 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/SwitchOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/SwitchOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -22,7 +22,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; @@ -40,8 +39,6 @@ public class SwitchOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -50,10 +47,9 @@ public class SwitchOperationHandler implements IModelOperationHandler { private final Switch switchOperation; - public SwitchOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public SwitchOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, Switch switchOperation) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -74,7 +70,7 @@ public IStatus handle(Map variables) { if (optionalValueObject.isPresent() && optionalValueObject.get()) { List subModelOperations = switchCase.getSubModelOperations(); - status = this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, + status = this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); oneCaseHasBeenExecuted = true; @@ -87,7 +83,7 @@ public IStatus handle(Map variables) { Default defaultCase = this.switchOperation.getDefault(); if (defaultCase != null) { List subModelOperations = defaultCase.getSubModelOperations(); - status = this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, + status = this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/UnsetOperationHandler.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/UnsetOperationHandler.java index 10ead0edca0..ab608d3f8d2 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/UnsetOperationHandler.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/main/java/org/eclipse/sirius/components/compatibility/emf/modeloperations/UnsetOperationHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2023 Obeo. + * Copyright (c) 2019, 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 @@ -25,7 +25,6 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.api.IModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.VariableManager; @@ -41,8 +40,6 @@ public class UnsetOperationHandler implements IModelOperationHandler { private final IObjectService objectService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IIdentifierProvider identifierProvider; private final AQLInterpreter interpreter; @@ -51,10 +48,9 @@ public class UnsetOperationHandler implements IModelOperationHandler { private final Unset unsetOperation; - public UnsetOperationHandler(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IIdentifierProvider identifierProvider, + public UnsetOperationHandler(IObjectService objectService, IIdentifierProvider identifierProvider, AQLInterpreter interpreter, ChildModelOperationHandler childModelOperationHandler, Unset unsetOperation) { this.objectService = Objects.requireNonNull(objectService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.identifierProvider = Objects.requireNonNull(identifierProvider); this.interpreter = Objects.requireNonNull(interpreter); this.childModelOperationHandler = Objects.requireNonNull(childModelOperationHandler); @@ -124,7 +120,7 @@ private void unset(EObject context, EStructuralFeature featureToEdit, List variables) { Map childVariables = new HashMap<>(variables); List subModelOperations = this.unsetOperation.getSubModelOperations(); - return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); + return this.childModelOperationHandler.handle(this.objectService, this.identifierProvider, this.interpreter, childVariables, subModelOperations); } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/diagrams/EdgeMappingConverterTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/diagrams/EdgeMappingConverterTests.java index 8be48ce0dcd..c26e5660ce0 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/diagrams/EdgeMappingConverterTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/diagrams/EdgeMappingConverterTests.java @@ -26,7 +26,6 @@ import org.eclipse.sirius.components.compatibility.emf.modeloperations.ModelOperationHandlerSwitch; import org.eclipse.sirius.components.core.api.IEditService; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.diagrams.FreeFormLayoutStrategy; import org.eclipse.sirius.components.diagrams.InsideLabelLocation; import org.eclipse.sirius.components.diagrams.LabelOverflowStrategy; @@ -75,7 +74,6 @@ public void testEdgeFromNodeToContainer() { ); IObjectService objectService = new IObjectService.NoOp(); - IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp(); IIdentifierProvider identifierProvider = new IIdentifierProvider.NoOp() { @Override public String getIdentifier(Object element) { @@ -83,8 +81,8 @@ public String getIdentifier(Object element) { } }; ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new; - IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, - List.of(), interpeter); + IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpreter -> new ModelOperationHandlerSwitch(objectService, identifierProvider, + List.of(), interpreter); EdgeMappingConverter edgeMappingConverter = new EdgeMappingConverter(new IObjectService.NoOp(), new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider); @@ -157,7 +155,6 @@ public void testEdgeFromContainerToNode() { ); IObjectService objectService = new IObjectService.NoOp(); - IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp(); IIdentifierProvider identifierProvider = new IIdentifierProvider.NoOp() { @Override public String getIdentifier(Object element) { @@ -166,8 +163,8 @@ public String getIdentifier(Object element) { }; ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new; - IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, - List.of(), interpeter); + IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpreter -> new ModelOperationHandlerSwitch(objectService, identifierProvider, + List.of(), interpreter); EdgeMappingConverter edgeMappingConverter = new EdgeMappingConverter(objectService, new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider); @@ -197,7 +194,6 @@ public void testEdgeFromContainerToContainer() { ); IObjectService objectService = new IObjectService.NoOp(); - IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp(); IIdentifierProvider identifierProvider = new IIdentifierProvider.NoOp() { @Override public String getIdentifier(Object element) { @@ -205,8 +201,8 @@ public String getIdentifier(Object element) { } }; ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new; - IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, - List.of(), interpeter); + IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpreter -> new ModelOperationHandlerSwitch(objectService, identifierProvider, + List.of(), interpreter); EdgeMappingConverter edgeMappingConverter = new EdgeMappingConverter(objectService, new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider); diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ChangeContextOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ChangeContextOperationHandlerTests.java index f06ec9af490..3027e23c7dd 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ChangeContextOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ChangeContextOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -48,8 +48,9 @@ public void initialize() { this.changeContext = ToolFactory.eINSTANCE.createChangeContext(); - this.changeContextOperationHandler = new ChangeContextOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), - this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.changeContext); + this.changeContextOperationHandler = new ChangeContextOperationHandler(this.operationTestContext.getObjectService(), + this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), + this.changeContext); } @Test diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ChildModelOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ChildModelOperationHandlerTests.java index ecf82d2c116..31e20e0efcf 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ChildModelOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ChildModelOperationHandlerTests.java @@ -23,7 +23,6 @@ import org.eclipse.sirius.components.compatibility.emf.compatibility.diagrams.TestDiagramBuilder; import org.eclipse.sirius.components.compatibility.emf.modeloperations.ChildModelOperationHandler; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.interpreter.Result; import org.eclipse.sirius.components.interpreter.Status; @@ -70,7 +69,7 @@ public Result evaluateExpression(Map variables, String expressio } }; - IStatus status = new ChildModelOperationHandler(List.of()).handle(objectService, new IRepresentationMetadataSearchService.NoOp(), identifierProvider, interpreter, Map.of(), + IStatus status = new ChildModelOperationHandler(List.of()).handle(objectService, identifierProvider, interpreter, Map.of(), List.of(createView)); assertThat(status).isInstanceOf(Success.class); diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateInstanceOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateInstanceOperationHandlerTests.java index e77fcafc04e..6b94b0084e2 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateInstanceOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateInstanceOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2024 Obeo and others. + * Copyright (c) 2019, 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 @@ -21,11 +21,11 @@ import org.eclipse.emf.ecore.ENamedElement; import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.sirius.components.emf.EPackageService; import org.eclipse.sirius.components.compatibility.emf.compatibility.services.EditingDomainFactory; import org.eclipse.sirius.components.compatibility.emf.modeloperations.ChildModelOperationHandler; import org.eclipse.sirius.components.compatibility.emf.modeloperations.CreateInstanceOperationHandler; import org.eclipse.sirius.components.core.api.IEditingContext; +import org.eclipse.sirius.components.emf.EPackageService; import org.eclipse.sirius.components.emf.services.api.IEMFEditingContext; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; @@ -73,7 +73,7 @@ public AdapterFactoryEditingDomain getDomain() { this.createInstanceOperation = ToolFactory.eINSTANCE.createCreateInstance(); - this.createInstanceOperationHandler = new CreateInstanceOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.createInstanceOperationHandler = new CreateInstanceOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new EPackageService(), new ChildModelOperationHandler(List.of()), this.createInstanceOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateViewOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateViewOperationHandlerTests.java index 4ec31b29732..ca347b6b8eb 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateViewOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateViewOperationHandlerTests.java @@ -120,7 +120,7 @@ public AdapterFactoryEditingDomain getDomain() { this.operationTestContext.getVariables().put(IEditingContext.EDITING_CONTEXT, editingContext); this.operationTestContext.getVariables().put(CONTAINER_VIEW, diagram); this.createViewOperation = org.eclipse.sirius.diagram.description.tool.ToolFactory.eINSTANCE.createCreateView(); - this.createViewOperationHandler = new CreateViewOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.createViewOperationHandler = new CreateViewOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.createViewOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/DeleteViewOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/DeleteViewOperationHandlerTests.java index 24f431d605f..65c63b0920e 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/DeleteViewOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/DeleteViewOperationHandlerTests.java @@ -156,7 +156,7 @@ public AdapterFactoryEditingDomain getDomain() { this.operationTestContext.getVariables().put(CONTAINER_VIEW, diagram); this.operationTestContext.getVariables().put(VariableManager.SELF, diagram.getNodes().get(0)); this.deleteViewOperation = ToolFactory.eINSTANCE.createDeleteView(); - this.deleteViewOperationHandler = new DeleteViewOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.deleteViewOperationHandler = new DeleteViewOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.deleteViewOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ForOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ForOperationHandlerTests.java index 2f6dd774811..25a1f26b940 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ForOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/ForOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -52,7 +52,7 @@ public void initialize() { this.forOperation = ToolFactory.eINSTANCE.createFor(); - this.forOperationHandler = new ForOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.forOperationHandler = new ForOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.forOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/IfOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/IfOperationHandlerTests.java index dfadcd5eafc..8cc6eee24c5 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/IfOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/IfOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -50,7 +50,7 @@ public void initialize() { this.ifOperation = ToolFactory.eINSTANCE.createIf(); - this.ifOperationHandler = new IfOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.ifOperationHandler = new IfOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.ifOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/LetOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/LetOperationHandlerTests.java index be8ffadbe6d..00e7c2a0b23 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/LetOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/LetOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -49,7 +49,7 @@ public void initialize() { this.operationTestContext = new OperationTestContext(); this.letOperation = ToolFactory.eINSTANCE.createLet(); - this.letOperationHandler = new LetOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.letOperationHandler = new LetOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.letOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/MoveElementOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/MoveElementOperationHandlerTests.java index bbd54e8c9da..6ea8718a831 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/MoveElementOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/MoveElementOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -66,7 +66,7 @@ public void initialize() { this.moveElementOperation = ToolFactory.eINSTANCE.createMoveElement(); - this.moveElementOperationHandler = new MoveElementOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.moveElementOperationHandler = new MoveElementOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.moveElementOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/NavigationOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/NavigationOperationHandlerTests.java index 9dcfa71e5bd..58bbf75123b 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/NavigationOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/NavigationOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Obeo. + * Copyright (c) 2022, 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 @@ -20,16 +20,11 @@ import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.compatibility.emf.modeloperations.ChildModelOperationHandler; -import org.eclipse.sirius.components.core.RepresentationMetadata; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; -import org.eclipse.sirius.components.diagrams.Diagram; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; -import org.eclipse.sirius.components.representations.WorkbenchSelection; -import org.eclipse.sirius.components.representations.WorkbenchSelectionEntry; import org.eclipse.sirius.diagram.description.DescriptionFactory; import org.eclipse.sirius.diagram.description.DiagramDescription; import org.eclipse.sirius.diagram.description.tool.Navigation; @@ -59,16 +54,6 @@ public class NavigationOperationHandlerTests { private static final String SECOND_DIAGRAM_DESCRIPTION_ID = UUID.randomUUID().toString(); - private final IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp() { - @Override - public List findAllByTargetObjectId(IEditingContext editingContext, String targetObjectId) { - var firstRepresentationMetadata = new RepresentationMetadata(FIRST_DIAGRAM_ID, Diagram.KIND, FIRST_DIAGRAM_LABEL, FIRST_DIAGRAM_DESCRIPTION_ID); - var secondRepresentationMetadata = new RepresentationMetadata(SECOND_DIAGRAM_ID, Diagram.KIND, SECOND_DIAGRAM_LABEL, FIRST_DIAGRAM_DESCRIPTION_ID); - var thirdRepresentationMetadata = new RepresentationMetadata(THIRD_DIAGRAM_ID, Diagram.KIND, THIRD_DIAGRAM_LABEL, SECOND_DIAGRAM_DESCRIPTION_ID); - return List.of(firstRepresentationMetadata, secondRepresentationMetadata, thirdRepresentationMetadata); - } - }; - private final IIdentifierProvider diagramDescriptionIdentifierProvider = new IIdentifierProvider.NoOp() { @Override public String getIdentifier(Object element) { @@ -86,22 +71,10 @@ public void testChildModelOperationWithSelection() { navigation.setCreateIfNotExistent(false); navigation.setDiagramDescription(diagramDescription); - IStatus status = new ChildModelOperationHandler(List.of()).handle(new IObjectService.NoOp(), this.representationMetadataSearchService, this.diagramDescriptionIdentifierProvider, + IStatus status = new ChildModelOperationHandler(List.of()).handle(new IObjectService.NoOp(), this.diagramDescriptionIdentifierProvider, new AQLInterpreter(List.of(), List.of()), Map.of(IEditingContext.EDITING_CONTEXT, new IEditingContext.NoOp()), List.of(navigation)); assertThat(status).isInstanceOf(Success.class); - - Success success = (Success) status; - Object selectionParameter = success.getParameters().get(Success.NEW_SELECTION); - assertThat(selectionParameter).isInstanceOf(WorkbenchSelection.class); - - WorkbenchSelection selection = (WorkbenchSelection) selectionParameter; - // @formatter:off - assertThat(selection).isEqualTo(new WorkbenchSelection(List.of( - new WorkbenchSelectionEntry(FIRST_DIAGRAM_ID, FIRST_DIAGRAM_LABEL, Diagram.KIND), - new WorkbenchSelectionEntry(SECOND_DIAGRAM_ID, SECOND_DIAGRAM_LABEL, Diagram.KIND) - ))); - // @formatter:on } @Test @@ -118,22 +91,10 @@ public void testMultipleChildModelOperationWithSelection() { secondNavigation.setCreateIfNotExistent(false); secondNavigation.setDiagramDescription(secondDiagramDescription); - IStatus status = new ChildModelOperationHandler(List.of()).handle(new IObjectService.NoOp(), this.representationMetadataSearchService, this.diagramDescriptionIdentifierProvider, + IStatus status = new ChildModelOperationHandler(List.of()).handle(new IObjectService.NoOp(), this.diagramDescriptionIdentifierProvider, new AQLInterpreter(List.of(), List.of()), Map.of(IEditingContext.EDITING_CONTEXT, new IEditingContext.NoOp()), List.of(firstNavigation, secondNavigation)); assertThat(status).isInstanceOf(Success.class); - - Success success = (Success) status; - Object selectionParameter = success.getParameters().get(Success.NEW_SELECTION); - assertThat(selectionParameter).isInstanceOf(WorkbenchSelection.class); - - WorkbenchSelection selection = (WorkbenchSelection) selectionParameter; - // @formatter:off - assertThat(selection).isEqualTo(new WorkbenchSelection(List.of( - new WorkbenchSelectionEntry(FIRST_DIAGRAM_ID, FIRST_DIAGRAM_LABEL, Diagram.KIND), - new WorkbenchSelectionEntry(SECOND_DIAGRAM_ID, SECOND_DIAGRAM_LABEL, Diagram.KIND), - new WorkbenchSelectionEntry(THIRD_DIAGRAM_ID, THIRD_DIAGRAM_LABEL, Diagram.KIND) - ))); // @formatter:on } } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/OperationTestContext.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/OperationTestContext.java index 33bccdefed2..1c7c55c6864 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/OperationTestContext.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/OperationTestContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 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 @@ -23,7 +23,6 @@ import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.representations.VariableManager; @@ -46,8 +45,6 @@ public class OperationTestContext { private IObjectService objectService; - private IRepresentationMetadataSearchService representationMetadataSearchService; - private IIdentifierProvider identifierProvider; private AQLInterpreter interpreter; @@ -61,7 +58,6 @@ public OperationTestContext() { this.rootPackage.getEClassifiers().add(0, this.class1); this.objectService = new IObjectService.NoOp(); - this.representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp(); this.identifierProvider = new IIdentifierProvider.NoOp() { @Override public String getIdentifier(Object element) { @@ -90,10 +86,6 @@ public IObjectService getObjectService() { return this.objectService; } - public IRepresentationMetadataSearchService getRepresentationMetadataSearchService() { - return this.representationMetadataSearchService; - } - public IIdentifierProvider getIdentifierProvider() { return this.identifierProvider; } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/RemoveElementOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/RemoveElementOperationHandlerTests.java index c29c70a4122..610f75e74e4 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/RemoveElementOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/RemoveElementOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -47,7 +47,7 @@ public void initialize() { this.removeElementOperation = ToolFactory.eINSTANCE.createRemoveElement(); - this.removeElementOperationHandler = new RemoveElementOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.removeElementOperationHandler = new RemoveElementOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.removeElementOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/SetValueOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/SetValueOperationHandlerTests.java index 75732b248d3..14711f298fd 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/SetValueOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/SetValueOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -50,7 +50,7 @@ public void initialize() { this.setValue = ToolFactory.eINSTANCE.createSetValue(); - this.setValueOperationHandler = new SetValueOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.setValueOperationHandler = new SetValueOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.setValue); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/SwitchOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/SwitchOperationHandlerTests.java index 07f509ca7b0..595a180730a 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/SwitchOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/SwitchOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -73,7 +73,7 @@ public void initialize() { this.defaultCase.getSubModelOperations().add(subChangeContextDefault); this.switchOperation.setDefault(this.defaultCase); - this.switchOperationHandler = new SwitchOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.switchOperationHandler = new SwitchOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.switchOperation); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/UnsetOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/UnsetOperationHandlerTests.java index 36d86b55096..39e88dd7218 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/UnsetOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/UnsetOperationHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 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 @@ -64,7 +64,7 @@ public void initialize() { this.operationTestContext.getRootPackage().setEFactoryInstance(EcoreFactory.eINSTANCE.createEFactory()); this.unset = ToolFactory.eINSTANCE.createUnset(); - this.unsetOperationHandler = new UnsetOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), + this.unsetOperationHandler = new UnsetOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new ChildModelOperationHandler(List.of()), this.unset); } diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/properties/FormRendererTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/properties/FormRendererTests.java index 87f1d3ee2bc..969f60e2c61 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/properties/FormRendererTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/properties/FormRendererTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2023 Obeo and others. + * Copyright (c) 2019, 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 @@ -28,7 +28,6 @@ import org.eclipse.sirius.components.compatibility.forms.ViewExtensionDescriptionConverter; import org.eclipse.sirius.components.compatibility.services.representations.IdentifiedElementLabelProvider; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.forms.AbstractWidget; import org.eclipse.sirius.components.forms.Form; import org.eclipse.sirius.components.forms.Group; @@ -74,7 +73,6 @@ public AQLInterpreter create(ViewExtensionDescription viewExtensionDescription) }; IObjectService objectService = new IObjectService.NoOp(); - IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp(); IIdentifierProvider identifierProvider = new IIdentifierProvider.NoOp() { @Override public String getIdentifier(Object element) { @@ -84,8 +82,8 @@ public String getIdentifier(Object element) { IdentifiedElementLabelProvider identifiedElementLabelProvider = new IdentifiedElementLabelProvider(); ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new; - IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, - List.of(), interpeter); + IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpreter -> new ModelOperationHandlerSwitch(objectService, identifierProvider, + List.of(), interpreter); ViewExtensionDescriptionConverter converter = new ViewExtensionDescriptionConverter(objectService, interpreterFactory, identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider, identifiedElementLabelProvider); FormDescription description = converter.convert(viewExtensionDescription); diff --git a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/handlers/GetRepresentationDescriptionEventHandler.java b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/handlers/GetRepresentationDescriptionEventHandler.java index f1d94b52ea7..d1050073f30 100644 --- a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/handlers/GetRepresentationDescriptionEventHandler.java +++ b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/handlers/GetRepresentationDescriptionEventHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Obeo. + * Copyright (c) 2023, 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 @@ -12,6 +12,7 @@ *******************************************************************************/ package org.eclipse.sirius.components.collaborative.handlers; +import java.util.List; import java.util.Objects; import org.eclipse.sirius.components.collaborative.api.ChangeDescription; @@ -24,7 +25,7 @@ import org.eclipse.sirius.components.core.api.IInput; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; +import org.eclipse.sirius.components.core.api.IRepresentationMetadataProvider; import org.eclipse.sirius.components.representations.IRepresentationDescription; import org.springframework.stereotype.Service; @@ -39,12 +40,12 @@ @Service public class GetRepresentationDescriptionEventHandler implements IEditingContextEventHandler { - private final IRepresentationMetadataSearchService representationMetadataSearchService; + private final List representationMetadataProviders; private final IRepresentationDescriptionSearchService representationDescriptionSearchService; - public GetRepresentationDescriptionEventHandler(IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationDescriptionSearchService representationDescriptionSearchService) { - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); + public GetRepresentationDescriptionEventHandler(List representationMetadataProviders, IRepresentationDescriptionSearchService representationDescriptionSearchService) { + this.representationMetadataProviders = representationMetadataProviders; this.representationDescriptionSearchService = Objects.requireNonNull(representationDescriptionSearchService); } @@ -56,7 +57,9 @@ public boolean canHandle(IEditingContext editingContext, IInput input) { @Override public void handle(One payloadSink, Many changeDescriptionSink, IEditingContext editingContext, IInput input) { if (input instanceof GetRepresentationDescriptionInput getRepresentationDescriptionInput) { - IRepresentationDescription representationDescription = this.representationMetadataSearchService.findByRepresentationId(getRepresentationDescriptionInput.representationId()) + IRepresentationDescription representationDescription = this.representationMetadataProviders.stream() + .flatMap(provider -> provider.getMetadata(getRepresentationDescriptionInput.representationId()).stream()) + .findFirst() .map(RepresentationMetadata::getDescriptionId) .flatMap(representationDescriptionId -> this.representationDescriptionSearchService.findById(editingContext, representationDescriptionId)) .orElse(null); diff --git a/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/IRepresentationMetadataSearchService.java b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/IRepresentationMetadataSearchService.java deleted file mode 100644 index fcccf58c13f..00000000000 --- a/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/IRepresentationMetadataSearchService.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022, 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.components.core.api; - -import java.util.List; -import java.util.Optional; - -import org.eclipse.sirius.components.core.RepresentationMetadata; - -/** - * Used to search and retrieve the metadata of a representation. - * - * @author sbegaudeau - */ -public interface IRepresentationMetadataSearchService { - Optional findByRepresentationId(String representationId); - - List findAllByTargetObjectId(IEditingContext editingContext, String targetObjectId); - - /** - * Implementation which does nothing, used for mocks in unit tests. - * - * @author arichard - */ - class NoOp implements IRepresentationMetadataSearchService { - - @Override - public Optional findByRepresentationId(String representationId) { - return Optional.empty(); - } - - @Override - public List findAllByTargetObjectId(IEditingContext editingContext, String targetObjectId) { - return List.of(); - } - } -} diff --git a/packages/core/backend/sirius-components-representations/src/main/java/org/eclipse/sirius/components/representations/IRepresentation.java b/packages/core/backend/sirius-components-representations/src/main/java/org/eclipse/sirius/components/representations/IRepresentation.java index 5f83f545d06..b75d4b985e1 100644 --- a/packages/core/backend/sirius-components-representations/src/main/java/org/eclipse/sirius/components/representations/IRepresentation.java +++ b/packages/core/backend/sirius-components-representations/src/main/java/org/eclipse/sirius/components/representations/IRepresentation.java @@ -29,36 +29,4 @@ public interface IRepresentation { String getKind(); String getTargetObjectId(); - - /** - * Implementation which does nothing, used for mocks in unit tests. - * - * @author gcoutable - */ - class NoOp implements IRepresentation { - @Override - public String getId() { - return ""; - } - - @Override - public String getDescriptionId() { - return ""; - } - - @Override - public String getLabel() { - return ""; - } - - @Override - public String getKind() { - return ""; - } - - @Override - public String getTargetObjectId() { - return ""; - } - } } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java index 7533320c661..36d7fc7c76e 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java @@ -63,6 +63,8 @@ import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.representations.WorkbenchSelection; +import org.eclipse.sirius.components.representations.WorkbenchSelectionEntry; import org.junit.jupiter.api.Test; import io.micrometer.core.instrument.simple.SimpleMeterRegistry; @@ -350,7 +352,19 @@ public Optional findEdgeById(Diagram diagram, String edgeId) { } }; - var tool = this.createTool(TOOL_ID, false, List.of(edgeDescription)); + String selectionEntryId = "entryId"; + String selectionEntryLabel = "entry label"; + String selectionEntryKind = "entryKind"; + var expectedSelectionEntry = new WorkbenchSelectionEntry(selectionEntryId, selectionEntryLabel, selectionEntryKind); + var expectedWorkbenchSelection = new WorkbenchSelection(List.of(expectedSelectionEntry)); + + var tool = this.createTool(TOOL_ID, false, List.of(), null, variableManager -> { + var newSelectionEntry = new WorkbenchSelectionEntry(selectionEntryId, selectionEntryLabel, selectionEntryKind); + var newWorkbenchSelection = new WorkbenchSelection(List.of(newSelectionEntry)); + var success = new Success(); + success.getParameters().put(Success.NEW_SELECTION, newWorkbenchSelection); + return success; + }); var toolService = new IToolService.NoOp() { @Override @@ -378,6 +392,10 @@ public Optional findToolById(IEditingContext editingContext, Diagram diag IPayload payload = payloadSink.asMono().block(); assertThat(payload).isInstanceOf(InvokeSingleClickOnDiagramElementToolSuccessPayload.class); + + var workbenchSelection = ((InvokeSingleClickOnDiagramElementToolSuccessPayload) payload).newSelection(); + assertThat(workbenchSelection).isNotNull(); + assertThat(workbenchSelection).isEqualTo(expectedWorkbenchSelection); } @Test diff --git a/packages/emf/backend/sirius-components-emf/src/test/java/org/eclipse/sirius/components/emf/services/DefaultObjectSearchServiceTests.java b/packages/emf/backend/sirius-components-emf/src/test/java/org/eclipse/sirius/components/emf/services/DefaultObjectSearchServiceTests.java deleted file mode 100644 index f9cf76322a8..00000000000 --- a/packages/emf/backend/sirius-components-emf/src/test/java/org/eclipse/sirius/components/emf/services/DefaultObjectSearchServiceTests.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * 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.components.emf.services; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Optional; - -import org.eclipse.sirius.components.collaborative.api.IRepresentationSearchService; -import org.eclipse.sirius.components.core.api.IDefaultObjectSearchService; -import org.eclipse.sirius.components.core.api.IEditingContext; -import org.eclipse.sirius.components.representations.IRepresentation; -import org.junit.jupiter.api.Test; - -/** - * Test for the default implementation if {@link IDefaultObjectSearchService}. - * - * @author pcdavid - */ -public class DefaultObjectSearchServiceTests { - - @Test - public void testFindsRepresentationFromItsId() { - var fakeId = "fake"; - IRepresentation fakeRepresentation = new IRepresentation.NoOp() { - @Override - public String getId() { - return fakeId; - } - }; - - IRepresentationSearchService representationSearchService = new IRepresentationSearchService.NoOp() { - @Override - public Optional findById(IEditingContext editingContext, String representationId, Class representationClass) { - if (fakeId.equals(representationId)) { - return Optional.of(fakeRepresentation).map(representationClass::cast); - } else { - return Optional.empty(); - } - } - }; - DefaultObjectSearchService defaultObjectSearchService = new DefaultObjectSearchService(representationSearchService); - - var optionalObject = defaultObjectSearchService.getObject(new IEditingContext.NoOp(), fakeId); - assertThat(optionalObject).containsSame(fakeRepresentation); - } - - @Test - public void testFindsEditingContextFromItsId() { - var editingContextId = "editingContextId"; - IEditingContext editingContext = () -> editingContextId; - - DefaultObjectSearchService defaultObjectSearchService = new DefaultObjectSearchService(new IRepresentationSearchService.NoOp()); - - var optionalObject = defaultObjectSearchService.getObject(editingContext, editingContextId); - assertThat(optionalObject).containsSame(editingContext); - } - -} diff --git a/packages/portals/backend/sirius-components-portals-graphql/src/main/java/org/eclipse/sirius/components/portals/graphql/datafetchers/query/PortalViewRepresentationMetadataDataFetcher.java b/packages/portals/backend/sirius-components-portals-graphql/src/main/java/org/eclipse/sirius/components/portals/graphql/datafetchers/query/PortalViewRepresentationMetadataDataFetcher.java index dee12b071de..deb6113db76 100644 --- a/packages/portals/backend/sirius-components-portals-graphql/src/main/java/org/eclipse/sirius/components/portals/graphql/datafetchers/query/PortalViewRepresentationMetadataDataFetcher.java +++ b/packages/portals/backend/sirius-components-portals-graphql/src/main/java/org/eclipse/sirius/components/portals/graphql/datafetchers/query/PortalViewRepresentationMetadataDataFetcher.java @@ -12,9 +12,11 @@ *******************************************************************************/ package org.eclipse.sirius.components.portals.graphql.datafetchers.query; +import java.util.List; + import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher; import org.eclipse.sirius.components.core.RepresentationMetadata; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; +import org.eclipse.sirius.components.core.api.IRepresentationMetadataProvider; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; import org.eclipse.sirius.components.portals.PortalView; @@ -27,15 +29,17 @@ */ @QueryDataFetcher(type = "PortalView", field = "representationMetadata") public class PortalViewRepresentationMetadataDataFetcher implements IDataFetcherWithFieldCoordinates { - private final IRepresentationMetadataSearchService representationMetadataSearchService; + private final List representationMetadataProviders; - public PortalViewRepresentationMetadataDataFetcher(IRepresentationMetadataSearchService representationMetadataSearchService) { - this.representationMetadataSearchService = representationMetadataSearchService; + public PortalViewRepresentationMetadataDataFetcher(List representationMetadataProviders) { + this.representationMetadataProviders = representationMetadataProviders; } @Override public RepresentationMetadata get(DataFetchingEnvironment environment) throws Exception { PortalView portalView = environment.getSource(); - return this.representationMetadataSearchService.findByRepresentationId(portalView.getRepresentationId()).orElseThrow(); + return this.representationMetadataProviders.stream() + .flatMap(provider -> provider.getMetadata(portalView.getRepresentationId()).stream()) + .findFirst().orElseThrow(); } } diff --git a/packages/portals/backend/sirius-components-portals-tests/src/main/java/org/eclipse/sirius/components/portals/tests/graphql/AddPortalViewMutationRunner.java b/packages/portals/backend/sirius-components-portals-tests/src/main/java/org/eclipse/sirius/components/portals/tests/graphql/AddPortalViewMutationRunner.java new file mode 100644 index 00000000000..a62ca9fb216 --- /dev/null +++ b/packages/portals/backend/sirius-components-portals-tests/src/main/java/org/eclipse/sirius/components/portals/tests/graphql/AddPortalViewMutationRunner.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * 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.components.portals.tests.graphql; + +import java.util.Objects; + +import org.eclipse.sirius.components.collaborative.portals.dto.AddPortalViewInput; +import org.eclipse.sirius.components.graphql.tests.api.IGraphQLRequestor; +import org.eclipse.sirius.components.graphql.tests.api.IMutationRunner; +import org.springframework.stereotype.Service; + +/** + * Used to add a representation to a portal. + * + * @author gcoutable + */ +@Service +public class AddPortalViewMutationRunner implements IMutationRunner { + + private static final String ADD_PORTAL_VIEW = """ + mutation addPortalView($input: AddPortalViewInput!) { + addPortalView(input: $input) { + __typename + ... on SuccessPayload { + id + } + ... on ErrorPayload { + message + } + } + } + """; + + private final IGraphQLRequestor graphQLRequestor; + + public AddPortalViewMutationRunner(IGraphQLRequestor graphQLRequestor) { + this.graphQLRequestor = Objects.requireNonNull(graphQLRequestor); + } + + @Override + public String run(AddPortalViewInput input) { + return this.graphQLRequestor.execute(ADD_PORTAL_VIEW, input); + } +} diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/portals/LayoutPortalMutationRunner.java b/packages/portals/backend/sirius-components-portals-tests/src/main/java/org/eclipse/sirius/components/portals/tests/graphql/LayoutPortalMutationRunner.java similarity index 96% rename from packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/portals/LayoutPortalMutationRunner.java rename to packages/portals/backend/sirius-components-portals-tests/src/main/java/org/eclipse/sirius/components/portals/tests/graphql/LayoutPortalMutationRunner.java index bbab0bd0a8b..631b875b164 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/portals/LayoutPortalMutationRunner.java +++ b/packages/portals/backend/sirius-components-portals-tests/src/main/java/org/eclipse/sirius/components/portals/tests/graphql/LayoutPortalMutationRunner.java @@ -10,7 +10,7 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -package org.eclipse.sirius.web.services.portals; +package org.eclipse.sirius.components.portals.tests.graphql; import java.util.Objects; diff --git a/packages/portals/backend/sirius-components-portals/src/main/java/org/eclipse/sirius/components/portals/PortalViewLayoutData.java b/packages/portals/backend/sirius-components-portals/src/main/java/org/eclipse/sirius/components/portals/PortalViewLayoutData.java index f6a54d0a94d..2ef4cf36294 100644 --- a/packages/portals/backend/sirius-components-portals/src/main/java/org/eclipse/sirius/components/portals/PortalViewLayoutData.java +++ b/packages/portals/backend/sirius-components-portals/src/main/java/org/eclipse/sirius/components/portals/PortalViewLayoutData.java @@ -75,7 +75,7 @@ public static Builder newPortalViewLayoutData(String portalViewId) { @SuppressWarnings("checkstyle:HiddenField") public static final class Builder { - private String portalViewId; + private final String portalViewId; private int x; @@ -111,7 +111,7 @@ public Builder height(int height) { public PortalViewLayoutData build() { PortalViewLayoutData portalViewLayoutData = new PortalViewLayoutData(); - portalViewLayoutData.portalViewId = this.portalViewId; + portalViewLayoutData.portalViewId = Objects.requireNonNull(this.portalViewId); portalViewLayoutData.x = this.x; portalViewLayoutData.y = this.y; portalViewLayoutData.width = this.width; diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectRepresentationDataExportParticipant.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectRepresentationDataExportParticipant.java index 95fc0fb3a15..e978572ac85 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectRepresentationDataExportParticipant.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectRepresentationDataExportParticipant.java @@ -28,10 +28,10 @@ import org.eclipse.sirius.components.emf.services.api.IEMFEditingContext; import org.eclipse.sirius.emfjson.resource.JsonResourceFactoryImpl; import org.eclipse.sirius.web.application.project.services.api.IProjectExportParticipant; -import org.eclipse.sirius.web.application.representation.services.RepresentationSearchService; -import org.eclipse.sirius.web.application.representation.services.api.IRepresentationDataMigrationService; +import org.eclipse.sirius.web.application.representation.services.api.IRepresentationContentMigrationService; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.jdbc.core.mapping.AggregateReference; @@ -47,42 +47,44 @@ public class ProjectRepresentationDataExportParticipant implements IProjectExpor private final IEditingContextSearchService editingContextSearchService; - private final IRepresentationDataSearchService representationDataSearchService; + private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final ObjectMapper objectMapper; + private final IRepresentationContentSearchService representationContentSearchService; - private final IRepresentationDataMigrationService representationDataMigrationService; + private final ObjectMapper objectMapper; - private final RepresentationSearchService representationSearchService; + private final IRepresentationContentMigrationService representationContentMigrationService; private final Logger logger = LoggerFactory.getLogger(ProjectRepresentationDataExportParticipant.class); - public ProjectRepresentationDataExportParticipant(IEditingContextSearchService editingContextSearchService, IRepresentationDataSearchService representationDataSearchService, ObjectMapper objectMapper, IRepresentationDataMigrationService representationDataMigrationService, RepresentationSearchService representationSearchService) { + public ProjectRepresentationDataExportParticipant(IEditingContextSearchService editingContextSearchService, IRepresentationMetadataSearchService representationMetadataSearchService, + IRepresentationContentSearchService representationContentSearchService, ObjectMapper objectMapper, IRepresentationContentMigrationService representationContentMigrationService) { this.editingContextSearchService = Objects.requireNonNull(editingContextSearchService); - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); + this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); + this.representationContentSearchService = Objects.requireNonNull(representationContentSearchService); this.objectMapper = Objects.requireNonNull(objectMapper); - this.representationDataMigrationService = Objects.requireNonNull(representationDataMigrationService); - this.representationSearchService = Objects.requireNonNull(representationSearchService); + this.representationContentMigrationService = Objects.requireNonNull(representationContentMigrationService); } @Override public Map exportData(Project project, ZipOutputStream outputStream) { Map> representationManifests = new HashMap<>(); - var allRepresentationMetadata = this.representationDataSearchService.findAllMetadataByProject(AggregateReference.to(project.getId())); + var allRepresentationMetadata = this.representationMetadataSearchService.findAllMetadataByProject(AggregateReference.to(project.getId())); for (var representationMetadata: allRepresentationMetadata) { - var optionalRepresentationContentNode = this.representationDataSearchService.findContentById(representationMetadata.id()) - .flatMap(this.representationDataMigrationService::getMigratedContent); + var optionalRepresentationContentNode = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(representationMetadata.getId())) + .flatMap(representationContent -> this.representationContentMigrationService.getMigratedContent(representationMetadata, representationContent)); + if (optionalRepresentationContentNode.isPresent()) { var representationContentNode = optionalRepresentationContentNode.get(); var exportData = new RepresentationSerializedExportData( - representationMetadata.id(), - representationMetadata.project().getId(), - representationMetadata.descriptionId(), - representationMetadata.targetObjectId(), - representationMetadata.label(), - representationMetadata.kind(), + representationMetadata.getId(), + representationMetadata.getProject().getId(), + representationMetadata.getDescriptionId(), + representationMetadata.getTargetObjectId(), + representationMetadata.getLabel(), + representationMetadata.getKind(), representationContentNode ); @@ -93,7 +95,7 @@ public Map exportData(Project project, ZipOutputStream outputStr .map(IEMFEditingContext.class::cast); if (optionalEditingContext.isPresent()) { var editingContext = optionalEditingContext.get(); - String targetObjectId = representationMetadata.targetObjectId(); + String targetObjectId = representationMetadata.getTargetObjectId(); for (Resource resource : editingContext.getDomain().getResourceSet().getResources()) { EObject eObject = resource.getEObject(targetObjectId); if (eObject != null) { @@ -107,16 +109,16 @@ public Map exportData(Project project, ZipOutputStream outputStr } Map representationManifest = Map.of( - "type", representationMetadata.kind(), - "descriptionURI", representationMetadata.descriptionId(), + "type", representationMetadata.getKind(), + "descriptionURI", representationMetadata.getDescriptionId(), "targetObjectURI", uriFragment ); - representationManifests.put(representationMetadata.id().toString(), representationManifest); + representationManifests.put(representationMetadata.getId().toString(), representationManifest); try { byte[] bytes = this.objectMapper.writeValueAsBytes(exportData); - String name = project.getName() + "/representations/" + representationMetadata.id() + "." + JsonResourceFactoryImpl.EXTENSION; + String name = project.getName() + "/representations/" + representationMetadata.getId() + "." + JsonResourceFactoryImpl.EXTENSION; ZipEntry zipEntry = new ZipEntry(name); zipEntry.setSize(bytes.length); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationMetadataFetcher.java similarity index 75% rename from packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationDataFetcher.java rename to packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationMetadataFetcher.java index 40dfcbdeb45..78093bb08ee 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationMetadataFetcher.java @@ -13,12 +13,12 @@ package org.eclipse.sirius.web.application.representation.controllers; import java.util.HashMap; +import java.util.List; import java.util.Map; -import java.util.Objects; import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher; import org.eclipse.sirius.components.core.RepresentationMetadata; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; +import org.eclipse.sirius.components.core.api.IRepresentationMetadataProvider; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; import org.eclipse.sirius.components.graphql.api.LocalContextConstants; @@ -31,14 +31,14 @@ * @author sbegaudeau */ @QueryDataFetcher(type = "EditingContext", field = "representation") -public class EditingContextRepresentationDataFetcher implements IDataFetcherWithFieldCoordinates> { +public class EditingContextRepresentationMetadataFetcher implements IDataFetcherWithFieldCoordinates> { private static final String REPRESENTATION_ID_ARGUMENT = "representationId"; - private final IRepresentationMetadataSearchService representationMetadataSearchService; + private final List representationMetadataProviders; - public EditingContextRepresentationDataFetcher(IRepresentationMetadataSearchService representationMetadataSearchService) { - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); + public EditingContextRepresentationMetadataFetcher(List representationMetadataProviders) { + this.representationMetadataProviders = representationMetadataProviders; } @Override @@ -48,7 +48,10 @@ public DataFetcherResult get(DataFetchingEnvironment env Map localContext = new HashMap<>(environment.getLocalContext()); localContext.put(LocalContextConstants.REPRESENTATION_ID, representationId); - var representationMetadata = this.representationMetadataSearchService.findByRepresentationId(representationId).orElse(null); + var representationMetadata = this.representationMetadataProviders.stream() + .flatMap(provider -> provider.getMetadata(representationId).stream()) + .findFirst() + .orElse(null); return DataFetcherResult.newResult() .data(representationMetadata) diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationsDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationsDataFetcher.java index 59d915133b4..0b4b0899e5d 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationsDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/EditingContextRepresentationsDataFetcher.java @@ -19,11 +19,10 @@ import java.util.Optional; import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher; -import org.eclipse.sirius.components.core.RepresentationMetadata; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; import org.eclipse.sirius.components.graphql.api.LocalContextConstants; import org.eclipse.sirius.web.application.dto.PageInfoWithCount; +import org.eclipse.sirius.web.application.representation.dto.RepresentationMetadataDTO; import org.eclipse.sirius.web.application.representation.services.api.IRepresentationApplicationService; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -46,28 +45,25 @@ * @author sbegaudeau */ @QueryDataFetcher(type = "EditingContext", field = "representations") -public class EditingContextRepresentationsDataFetcher implements IDataFetcherWithFieldCoordinates>> { +public class EditingContextRepresentationsDataFetcher implements IDataFetcherWithFieldCoordinates>> { private static final String REPRESENTATION_IDS_ARGUMENT = "representationIds"; private final IRepresentationApplicationService representationApplicationService; - private final IRepresentationMetadataSearchService representationMetadataSearchService; - - public EditingContextRepresentationsDataFetcher(IRepresentationApplicationService representationApplicationService, IRepresentationMetadataSearchService representationMetadataSearchService) { + public EditingContextRepresentationsDataFetcher(IRepresentationApplicationService representationApplicationService) { this.representationApplicationService = Objects.requireNonNull(representationApplicationService); - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); } @Override - public Connection> get(DataFetchingEnvironment environment) throws Exception { + public Connection> get(DataFetchingEnvironment environment) throws Exception { String editingContextId = environment.getSource(); - Page representationMetadataPage = Page.empty(); + Page representationMetadataPage = Page.empty(); List representationIds = environment.getArgument(REPRESENTATION_IDS_ARGUMENT); if (representationIds != null) { - List allRepresentationMetadata = representationIds.stream() - .map(this.representationMetadataSearchService::findByRepresentationId) + List allRepresentationMetadata = representationIds.stream() + .map(this.representationApplicationService::findRepresentationMetadataById) .flatMap(Optional::stream) .toList(); representationMetadataPage = new PageImpl<>(allRepresentationMetadata, Pageable.unpaged(), allRepresentationMetadata.size()); @@ -78,14 +74,14 @@ public Connection> get(DataFetchingEnv return this.toConnection(environment, representationMetadataPage); } - private Connection> toConnection(DataFetchingEnvironment environment, Page representationMetadataPage) { + private Connection> toConnection(DataFetchingEnvironment environment, Page representationMetadataPage) { var edges = representationMetadataPage.stream().map(representationMetadata -> { - var globalId = new Relay().toGlobalId("RepresentationMetadata", representationMetadata.getId()); + var globalId = new Relay().toGlobalId("RepresentationMetadata", representationMetadata.id().toString()); var cursor = new DefaultConnectionCursor(globalId); Map localContext = new HashMap<>(environment.getLocalContext()); - localContext.put(LocalContextConstants.REPRESENTATION_ID, representationMetadata.getId()); - return (Edge>) new DefaultEdge<>(DataFetcherResult.newResult() + localContext.put(LocalContextConstants.REPRESENTATION_ID, representationMetadata.id().toString()); + return (Edge>) new DefaultEdge<>(DataFetcherResult.newResult() .data(representationMetadata) .localContext(localContext) .build(), cursor); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationCreateRepresentationDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationCreateRepresentationMetadataFetcher.java similarity index 88% rename from packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationCreateRepresentationDataFetcher.java rename to packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationCreateRepresentationMetadataFetcher.java index 00aebf0d472..bb6f0688d2e 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationCreateRepresentationDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationCreateRepresentationMetadataFetcher.java @@ -31,7 +31,7 @@ * @author sbegaudeau */ @QueryDataFetcher(type = "Mutation", field = "createRepresentation") -public class MutationCreateRepresentationDataFetcher implements IDataFetcherWithFieldCoordinates> { +public class MutationCreateRepresentationMetadataFetcher implements IDataFetcherWithFieldCoordinates> { private static final String INPUT_ARGUMENT = "input"; @@ -39,7 +39,7 @@ public class MutationCreateRepresentationDataFetcher implements IDataFetcherWith private final IEditingContextDispatcher editingContextDispatcher; - public MutationCreateRepresentationDataFetcher(ObjectMapper objectMapper, IEditingContextDispatcher editingContextDispatcher) { + public MutationCreateRepresentationMetadataFetcher(ObjectMapper objectMapper, IEditingContextDispatcher editingContextDispatcher) { this.objectMapper = Objects.requireNonNull(objectMapper); this.editingContextDispatcher = Objects.requireNonNull(editingContextDispatcher); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationDeleteRepresentationDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationDeleteRepresentationMetadataFetcher.java similarity index 88% rename from packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationDeleteRepresentationDataFetcher.java rename to packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationDeleteRepresentationMetadataFetcher.java index 50c6b07173c..412376a0dd2 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationDeleteRepresentationDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationDeleteRepresentationMetadataFetcher.java @@ -35,7 +35,7 @@ * @author sbegaudeau */ @QueryDataFetcher(type = "Mutation", field = "deleteRepresentation") -public class MutationDeleteRepresentationDataFetcher implements IDataFetcherWithFieldCoordinates> { +public class MutationDeleteRepresentationMetadataFetcher implements IDataFetcherWithFieldCoordinates> { private static final String INPUT_ARGUMENT = "input"; @@ -47,7 +47,7 @@ public class MutationDeleteRepresentationDataFetcher implements IDataFetcherWith private final IMessageService messageService; - public MutationDeleteRepresentationDataFetcher(ObjectMapper objectMapper, IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry, IRepresentationApplicationService representationApplicationService, IMessageService messageService) { + public MutationDeleteRepresentationMetadataFetcher(ObjectMapper objectMapper, IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry, IRepresentationApplicationService representationApplicationService, IMessageService messageService) { this.objectMapper = Objects.requireNonNull(objectMapper); this.editingContextEventProcessorRegistry = Objects.requireNonNull(editingContextEventProcessorRegistry); this.representationApplicationService = Objects.requireNonNull(representationApplicationService); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationRenameRepresentationDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationRenameRepresentationMetadataFetcher.java similarity index 88% rename from packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationRenameRepresentationDataFetcher.java rename to packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationRenameRepresentationMetadataFetcher.java index 37fac651011..5cc7d0473b0 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationRenameRepresentationDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/MutationRenameRepresentationMetadataFetcher.java @@ -31,14 +31,14 @@ * @author sbegaudeau */ @MutationDataFetcher(type = "Mutation", field = "renameRepresentation") -public class MutationRenameRepresentationDataFetcher implements IDataFetcherWithFieldCoordinates> { +public class MutationRenameRepresentationMetadataFetcher implements IDataFetcherWithFieldCoordinates> { private static final String INPUT_ARGUMENT = "input"; private final ObjectMapper objectMapper; private final IEditingContextDispatcher editingContextDispatcher; - public MutationRenameRepresentationDataFetcher(ObjectMapper objectMapper, IEditingContextDispatcher editingContextDispatcher) { + public MutationRenameRepresentationMetadataFetcher(ObjectMapper objectMapper, IEditingContextDispatcher editingContextDispatcher) { this.objectMapper = Objects.requireNonNull(objectMapper); this.editingContextDispatcher = Objects.requireNonNull(editingContextDispatcher); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/RepresentationMetadataDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/RepresentationMetadataDataFetcher.java index 47b5cfc33ac..c1913cc2c1a 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/RepresentationMetadataDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/controllers/RepresentationMetadataDataFetcher.java @@ -15,11 +15,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher; import org.eclipse.sirius.components.core.RepresentationMetadata; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; +import org.eclipse.sirius.components.core.api.IRepresentationMetadataProvider; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; import org.eclipse.sirius.components.representations.IRepresentation; @@ -36,15 +35,14 @@ public class RepresentationMetadataDataFetcher implements IDataFetcherWithFieldCoordinates> { private static final String METADATA_FIELD = "metadata"; - private final IRepresentationMetadataSearchService representationMetadataSearchService; + private final List representationMetadataProviders; - public RepresentationMetadataDataFetcher(IRepresentationMetadataSearchService representationMetadataSearchService) { - this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); + public RepresentationMetadataDataFetcher(List representationMetadataProviders) { + this.representationMetadataProviders = representationMetadataProviders; } @Override public List getFieldCoordinates() { - // @formatter:off return List.of( FieldCoordinates.coordinates("Diagram", METADATA_FIELD), FieldCoordinates.coordinates("Form", METADATA_FIELD), @@ -58,21 +56,21 @@ public List getFieldCoordinates() { FieldCoordinates.coordinates("Deck", METADATA_FIELD), FieldCoordinates.coordinates("Portal", METADATA_FIELD) ); - // @formatter:on } @Override public DataFetcherResult get(DataFetchingEnvironment environment) throws Exception { IRepresentation representation = environment.getSource(); - var metadata = this.representationMetadataSearchService.findByRepresentationId(representation.getId()).orElse(null); + var metadata = this.representationMetadataProviders.stream() + .flatMap(provider -> provider.getMetadata(representation.getId()).stream()) + .findFirst() + .orElse(null); Map localContext = new HashMap<>(environment.getLocalContext()); - // @formatter:off return DataFetcherResult.newResult() .data(metadata) .localContext(localContext) .build(); - // @formatter:on } } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/projections/RepresentationDataContentOnly.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/dto/RepresentationMetadataDTO.java similarity index 60% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/projections/RepresentationDataContentOnly.java rename to packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/dto/RepresentationMetadataDTO.java index 003939e7aec..6130c985b90 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/projections/RepresentationDataContentOnly.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/dto/RepresentationMetadataDTO.java @@ -10,16 +10,19 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -package org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections; +package org.eclipse.sirius.web.application.representation.dto; + +import java.util.UUID; /** - * Projection used to retrieve only the content and its associated data from the representation data. + * The DTO for representation metadata. * - * @author sbegaudeau + * @author gcoutable */ -public record RepresentationDataContentOnly( +public record RepresentationMetadataDTO( + UUID id, + String label, String kind, - String content, - String lastMigrationPerformed, - String migrationVersion) { + String targetObjectId, + String descriptionId) { } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DanglingRepresentationDeletionService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DanglingRepresentationDeletionService.java index 30441d07dea..5d296fad5fb 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DanglingRepresentationDeletionService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DanglingRepresentationDeletionService.java @@ -20,9 +20,9 @@ import org.eclipse.sirius.components.core.api.IObjectSearchService; import org.eclipse.sirius.components.representations.IRepresentation; import org.eclipse.sirius.web.application.UUIDParser; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataDeletionService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataMetadataOnly; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataDeletionService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -37,14 +37,14 @@ public class DanglingRepresentationDeletionService implements IDanglingRepresent private final IObjectSearchService objectSearchService; - private final IRepresentationDataSearchService representationDataSearchService; + private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IRepresentationDataDeletionService representationDataDeletionService; + private final IRepresentationMetadataDeletionService representationMetadataDeletionService; - public DanglingRepresentationDeletionService(IObjectSearchService objectSearchService, IRepresentationDataSearchService representationDataSearchService, IRepresentationDataDeletionService representationDataDeletionService) { + public DanglingRepresentationDeletionService(IObjectSearchService objectSearchService, IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationMetadataDeletionService representationMetadataDeletionService) { this.objectSearchService = Objects.requireNonNull(objectSearchService); - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); - this.representationDataDeletionService = Objects.requireNonNull(representationDataDeletionService); + this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); + this.representationMetadataDeletionService = Objects.requireNonNull(representationMetadataDeletionService); } @Override @@ -58,10 +58,10 @@ public boolean isDangling(IEditingContext editingContext, IRepresentation repres @Transactional public void deleteDanglingRepresentations(IEditingContext editingContext) { new UUIDParser().parse(editingContext.getId()).ifPresent(projectId -> { - this.representationDataSearchService.findAllMetadataByProject(AggregateReference.to(projectId)).stream() - .filter(representationMetadata -> this.objectSearchService.getObject(editingContext, representationMetadata.targetObjectId()).isEmpty()) - .map(RepresentationDataMetadataOnly::id) - .forEach(this.representationDataDeletionService::delete); + this.representationMetadataSearchService.findAllMetadataByProject(AggregateReference.to(projectId)).stream() + .filter(representationMetadata -> this.objectSearchService.getObject(editingContext, representationMetadata.getTargetObjectId()).isEmpty()) + .map(RepresentationMetadata::getId) + .forEach(this.representationMetadataDeletionService::delete); }); } } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DeleteRepresentationEventHandler.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DeleteRepresentationEventHandler.java index ad76dcc58af..2767e193857 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DeleteRepresentationEventHandler.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DeleteRepresentationEventHandler.java @@ -25,7 +25,7 @@ import org.eclipse.sirius.components.core.api.IInput; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.web.application.UUIDParser; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataDeletionService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataDeletionService; import org.eclipse.sirius.web.domain.services.api.IMessageService; import org.springframework.stereotype.Service; @@ -41,14 +41,14 @@ @Service public class DeleteRepresentationEventHandler implements IEditingContextEventHandler { - private final IRepresentationDataDeletionService representationDataDeletionService; + private final IRepresentationMetadataDeletionService representationMetadataDeletionService; private final IMessageService messageService; private final Counter counter; - public DeleteRepresentationEventHandler(IRepresentationDataDeletionService representationDataDeletionService, IMessageService messageService, MeterRegistry meterRegistry) { - this.representationDataDeletionService = Objects.requireNonNull(representationDataDeletionService); + public DeleteRepresentationEventHandler(IRepresentationMetadataDeletionService representationMetadataDeletionService, IMessageService messageService, MeterRegistry meterRegistry) { + this.representationMetadataDeletionService = Objects.requireNonNull(representationMetadataDeletionService); this.messageService = Objects.requireNonNull(messageService); this.counter = Counter.builder(Monitoring.EVENT_HANDLER) @@ -73,7 +73,7 @@ public void handle(Sinks.One payloadSink, Sinks.Many getMetadata(String representationId) { return new UUIDParser().parse(representationId) - .flatMap(this.representationDataSearchService::findMetadataById) - .map(representation -> new RepresentationMetadata(representation.id().toString(), representation.kind(), representation.label(), representation.descriptionId())); + .flatMap(this.representationMetadataSearchService::findMetadataById) + .map(representation -> new RepresentationMetadata(representation.getId().toString(), representation.getKind(), representation.getLabel(), representation.getDescriptionId())); } } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationApplicationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationApplicationService.java index f084791a4c6..f07d9ba44f6 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationApplicationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationApplicationService.java @@ -18,12 +18,13 @@ import java.util.Optional; import java.util.UUID; -import org.eclipse.sirius.components.core.RepresentationMetadata; import org.eclipse.sirius.web.application.UUIDParser; +import org.eclipse.sirius.web.application.representation.dto.RepresentationMetadataDTO; import org.eclipse.sirius.web.application.representation.services.api.IRepresentationApplicationService; +import org.eclipse.sirius.web.application.representation.services.api.IRepresentationMetadataMapper; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataMetadataOnly; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -39,40 +40,48 @@ @Service public class RepresentationApplicationService implements IRepresentationApplicationService { - private final IRepresentationDataSearchService representationDataSearchService; + private final IRepresentationMetadataSearchService representationMetadataSearchService; - public RepresentationApplicationService(IRepresentationDataSearchService representationDataSearchService) { - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); + private final IRepresentationMetadataMapper representationMetadataMapper; + + public RepresentationApplicationService(IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationMetadataMapper representationMetadataMapper) { + this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); + this.representationMetadataMapper = Objects.requireNonNull(representationMetadataMapper); } @Override - public Page findAllByEditingContextId(String editingContextId, Pageable pageable) { - var representationData = new UUIDParser().parse(editingContextId) + @Transactional(readOnly = true) + public Page findAllByEditingContextId(String editingContextId, Pageable pageable) { + var representationMetadata = new UUIDParser().parse(editingContextId) .map(AggregateReference::to) - .map(this.representationDataSearchService::findAllMetadataByProject) + .map(this.representationMetadataSearchService::findAllMetadataByProject) .orElse(List.of()) .stream() - .sorted(Comparator.comparing(RepresentationDataMetadataOnly::label)) + .sorted(Comparator.comparing(RepresentationMetadata::getLabel)) .toList(); int startIndex = (int) pageable.getOffset() * pageable.getPageSize(); - int endIndex = Math.min(((int) pageable.getOffset() + 1) * pageable.getPageSize(), representationData.size()); - var representationMetadata = representationData.subList(startIndex, endIndex).stream() - .map(this::toRepresentationMetadata) + int endIndex = Math.min(((int) pageable.getOffset() + 1) * pageable.getPageSize(), representationMetadata.size()); + var representationMetadataDTO = representationMetadata.subList(startIndex, endIndex).stream() + .map(this.representationMetadataMapper::toDTO) .toList(); - return new PageImpl<>(representationMetadata, pageable, representationData.size()); - } - - private RepresentationMetadata toRepresentationMetadata(RepresentationDataMetadataOnly representationData) { - return new RepresentationMetadata(representationData.id().toString(), representationData.kind(), representationData.label(), representationData.descriptionId()); + return new PageImpl<>(representationMetadataDTO, pageable, representationMetadataDTO.size()); } @Override @Transactional(readOnly = true) public Optional findEditingContextIdFromRepresentationId(String representationId) { return new UUIDParser().parse(representationId) - .flatMap(this.representationDataSearchService::findProjectByRepresentationId) + .flatMap(this.representationMetadataSearchService::findProjectByRepresentationId) .map(AggregateReference::getId) .map(UUID::toString); } + + @Override + @Transactional(readOnly = true) + public Optional findRepresentationMetadataById(String representationMetadataId) { + return new UUIDParser().parse(representationMetadataId) + .flatMap(this.representationMetadataSearchService::findMetadataById) + .map(this.representationMetadataMapper::toDTO); + } } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationDataMigrationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationContentMigrationService.java similarity index 78% rename from packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationDataMigrationService.java rename to packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationContentMigrationService.java index abacca8791a..eea3d9d6ba7 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationDataMigrationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationContentMigrationService.java @@ -24,39 +24,40 @@ import org.eclipse.sirius.components.collaborative.representations.migration.IRepresentationMigrationParticipant; import org.eclipse.sirius.components.collaborative.representations.migration.RepresentationMigrationService; -import org.eclipse.sirius.web.application.representation.services.api.IRepresentationDataMigrationService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataContentOnly; +import org.eclipse.sirius.web.application.representation.services.api.IRepresentationContentMigrationService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; /** - * Used to retrieve the migrated content of the representation data. + * Used to retrieve the migrated content of the representation content. * * @author sbegaudeau */ @Service -public class RepresentationDataMigrationService implements IRepresentationDataMigrationService { +public class RepresentationContentMigrationService implements IRepresentationContentMigrationService { private final ObjectMapper objectMapper; private final List migrationParticipants; - private final Logger logger = LoggerFactory.getLogger(RepresentationDataMigrationService.class); + private final Logger logger = LoggerFactory.getLogger(RepresentationContentMigrationService.class); - public RepresentationDataMigrationService(ObjectMapper objectMapper, List migrationParticipants) { + public RepresentationContentMigrationService(ObjectMapper objectMapper, List migrationParticipants) { this.objectMapper = Objects.requireNonNull(objectMapper); this.migrationParticipants = Objects.requireNonNull(migrationParticipants); } @Override - public Optional getMigratedContent(RepresentationDataContentOnly representationData) { + public Optional getMigratedContent(RepresentationMetadata representationMetadata, RepresentationContent representationContent) { Optional optionalObjectNode = Optional.empty(); try { - JsonNode rootJsonNode = this.objectMapper.readTree(representationData.content()); + JsonNode rootJsonNode = this.objectMapper.readTree(representationContent.getContent()); if (rootJsonNode instanceof ObjectNode objectNode) { - List applicableParticipants = this.getApplicableMigrationParticipants(representationData); + List applicableParticipants = this.getApplicableMigrationParticipants(representationMetadata.getKind(), representationContent); if (!applicableParticipants.isEmpty()) { var migrationService = new RepresentationMigrationService(applicableParticipants, objectNode); migrationService.parseProperties(objectNode, this.objectMapper); @@ -71,9 +72,8 @@ public Optional getMigratedContent(RepresentationDataContentOnly rep return optionalObjectNode; } - private List getApplicableMigrationParticipants(RepresentationDataContentOnly representationData) { - var migrationVersion = representationData.migrationVersion(); - var kind = representationData.kind(); + private List getApplicableMigrationParticipants(String kind, RepresentationContent representationContent) { + var migrationVersion = representationContent.getMigrationVersion(); return this.migrationParticipants.stream() .filter(migrationParticipant -> Objects.equals(migrationParticipant.getKind(), kind)) diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataMapper.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataMapper.java new file mode 100644 index 00000000000..6cefe278570 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataMapper.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.representation.services; + +import org.eclipse.sirius.web.application.representation.dto.RepresentationMetadataDTO; +import org.eclipse.sirius.web.application.representation.services.api.IRepresentationMetadataMapper; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.springframework.stereotype.Service; + +/** + * Used to convert a representation metadata to a DTO. + * + * @author gcoutable + */ +@Service +public class RepresentationMetadataMapper implements IRepresentationMetadataMapper { + + @Override + public RepresentationMetadataDTO toDTO(RepresentationMetadata representationMetadata) { + return new RepresentationMetadataDTO(representationMetadata.getId(), representationMetadata.getLabel(), representationMetadata.getKind(), representationMetadata.getTargetObjectId(), representationMetadata.getDescriptionId()); + } +} diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataSearchService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataSearchService.java deleted file mode 100644 index bc5286dcf33..00000000000 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataSearchService.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * 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.representation.services; - -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -import org.eclipse.sirius.components.core.RepresentationMetadata; -import org.eclipse.sirius.components.core.api.IEditingContext; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataProvider; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; -import org.springframework.stereotype.Service; - -/** - * Used to find the metadata of a representation. - * - * @author sbegaudeau - */ -@Service -public class RepresentationMetadataSearchService implements IRepresentationMetadataSearchService { - - private final IRepresentationDataSearchService representationDataSearchService; - - private final List representationMetadataProviders; - - public RepresentationMetadataSearchService(IRepresentationDataSearchService representationDataSearchService, List representationMetadataProviders) { - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); - this.representationMetadataProviders = Objects.requireNonNull(representationMetadataProviders); - } - - @Override - public Optional findByRepresentationId(String representationId) { - return this.representationMetadataProviders.stream() - .flatMap(provider -> provider.getMetadata(representationId).stream()) - .findFirst(); - } - - @Override - public List findAllByTargetObjectId(IEditingContext editingContext, String targetObjectId) { - return this.representationDataSearchService.findAllMetadataByTargetObjectId(targetObjectId) - .stream() - .map(representation -> new RepresentationMetadata(representation.id().toString(), representation.kind(), representation.label(), representation.descriptionId())) - .toList(); - } -} diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationPersistenceService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationPersistenceService.java index 4a8f6d7ccc6..8e028f81937 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationPersistenceService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationPersistenceService.java @@ -18,6 +18,7 @@ import java.util.Comparator; import java.util.List; import java.util.Objects; +import java.util.UUID; import org.eclipse.sirius.components.collaborative.api.IRepresentationPersistenceService; import org.eclipse.sirius.components.collaborative.representations.migration.IRepresentationMigrationParticipant; @@ -25,10 +26,12 @@ import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.representations.IRepresentation; import org.eclipse.sirius.web.application.UUIDParser; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataCreationService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataUpdateService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentCreationService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentUpdateService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataCreationService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.jdbc.core.mapping.AggregateReference; @@ -45,11 +48,13 @@ public class RepresentationPersistenceService implements IRepresentationPersiste private static final String NONE = "none"; - private final IRepresentationDataSearchService representationDataSearchService; + private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IRepresentationDataCreationService representationDataCreationService; + private final IRepresentationMetadataCreationService representationMetadataCreationService; - private final IRepresentationDataUpdateService representationDataUpdateService; + private final IRepresentationContentCreationService representationContentCreationService; + + private final IRepresentationContentUpdateService representationContentUpdateService; private final ObjectMapper objectMapper; @@ -57,10 +62,12 @@ public class RepresentationPersistenceService implements IRepresentationPersiste private final List migrationParticipants; - public RepresentationPersistenceService(IRepresentationDataSearchService representationDataSearchService, IRepresentationDataCreationService representationDataCreationService, IRepresentationDataUpdateService representationDataUpdateService, ObjectMapper objectMapper, List migrationParticipants) { - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); - this.representationDataCreationService = Objects.requireNonNull(representationDataCreationService); - this.representationDataUpdateService = representationDataUpdateService; + public RepresentationPersistenceService(IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationMetadataCreationService representationMetadataCreationService, + IRepresentationContentCreationService representationContentCreationService, IRepresentationContentUpdateService representationContentUpdateService, ObjectMapper objectMapper, List migrationParticipants) { + this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); + this.representationMetadataCreationService = Objects.requireNonNull(representationMetadataCreationService); + this.representationContentCreationService = Objects.requireNonNull(representationContentCreationService); + this.representationContentUpdateService = Objects.requireNonNull(representationContentUpdateService); this.objectMapper = Objects.requireNonNull(objectMapper); this.migrationParticipants = migrationParticipants; } @@ -76,25 +83,30 @@ public void save(IEditingContext editingContext, IRepresentation representation) String content = this.toString(representation); - var exists = this.representationDataSearchService.existsById(representationId); + var exists = this.representationMetadataSearchService.existsById(representationId); if (exists) { var migrationData = this.getLastMigrationData(representation.getKind()); - this.representationDataUpdateService.updateContentWithMigrationData(representationId, content, migrationData.lastMigrationPerformed(), migrationData.migrationVersion()); + this.representationContentUpdateService.updateContentByRepresentationIdWithMigrationData(representationId, content, migrationData.lastMigrationPerformed(), migrationData.migrationVersion()); } else { var migrationData = this.getInitialMigrationData(representation.getKind()); - var representationData = RepresentationData.newRepresentationData(representationId) + var representationMetadata = RepresentationMetadata.newRepresentationMetadata(representationId) .project(AggregateReference.to(projectId)) .label(representation.getLabel()) .kind(representation.getKind()) .descriptionId(representation.getDescriptionId()) .targetObjectId(representation.getTargetObjectId()) + .build(); + + var representationContent = RepresentationContent.newRepresentationContent(UUID.randomUUID()) + .representationMetadata(AggregateReference.to(representationId)) .content(content) .lastMigrationPerformed(migrationData.lastMigrationPerformed()) .migrationVersion(migrationData.migrationVersion()) .build(); - this.representationDataCreationService.create(representationData); + this.representationMetadataCreationService.create(representationMetadata); + this.representationContentCreationService.create(representationContent); } } } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationSearchService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationSearchService.java index 0a343d2b09a..bcac3f8fcc7 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationSearchService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationSearchService.java @@ -22,11 +22,14 @@ import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.representations.IRepresentation; import org.eclipse.sirius.web.application.UUIDParser; -import org.eclipse.sirius.web.application.representation.services.api.IRepresentationDataMigrationService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataContentOnly; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.application.representation.services.api.IRepresentationContentMigrationService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; /** @@ -37,30 +40,38 @@ @Service public class RepresentationSearchService implements IRepresentationSearchService { - private final IRepresentationDataSearchService representationDataSearchService; + private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IRepresentationDataMigrationService representationDataMigrationService; + private final IRepresentationContentSearchService representationContentSearchService; + + private final IRepresentationContentMigrationService representationContentMigrationService; private final ObjectMapper objectMapper; private final Logger logger = LoggerFactory.getLogger(RepresentationSearchService.class); - public RepresentationSearchService(IRepresentationDataSearchService representationDataSearchService, IRepresentationDataMigrationService representationDataMigrationService, ObjectMapper objectMapper) { - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); - this.representationDataMigrationService = Objects.requireNonNull(representationDataMigrationService); + public RepresentationSearchService(IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationContentSearchService representationContentSearchService, IRepresentationContentMigrationService representationContentMigrationService, ObjectMapper objectMapper) { + this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); + this.representationContentSearchService = Objects.requireNonNull(representationContentSearchService); + this.representationContentMigrationService = Objects.requireNonNull(representationContentMigrationService); this.objectMapper = Objects.requireNonNull(objectMapper); } @Override public Optional findById(IEditingContext editingContext, String representationId, Class representationClass) { return new UUIDParser().parse(representationId) - .flatMap(this.representationDataSearchService::findContentById) - .map(this::migratedContent) - .flatMap(this::toRepresentation) + .flatMap(this.representationMetadataSearchService::findMetadataById) + .flatMap(this::getRepresentation) .filter(representationClass::isInstance) .map(representationClass::cast); } + private Optional getRepresentation(RepresentationMetadata representationMetadata) { + return this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(representationMetadata.getId())) + .map(representationContent -> this.migratedContent(representationMetadata, representationContent)) + .flatMap(this::toRepresentation); + } + private Optional toRepresentation(String content) { Optional optionalRepresentation = Optional.empty(); @@ -74,10 +85,10 @@ private Optional toRepresentation(String content) { return optionalRepresentation; } - private String migratedContent(RepresentationDataContentOnly representationData) { - return this.representationDataMigrationService.getMigratedContent(representationData) + private String migratedContent(RepresentationMetadata representationMetadata, RepresentationContent representationContent) { + return this.representationContentMigrationService.getMigratedContent(representationMetadata, representationContent) .map(Object::toString) .orElse(""); } -} \ No newline at end of file +} diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationApplicationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationApplicationService.java index 08c725dc714..bab44fe6ccb 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationApplicationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationApplicationService.java @@ -14,7 +14,7 @@ import java.util.Optional; -import org.eclipse.sirius.components.core.RepresentationMetadata; +import org.eclipse.sirius.web.application.representation.dto.RepresentationMetadataDTO; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -25,7 +25,9 @@ */ public interface IRepresentationApplicationService { - Page findAllByEditingContextId(String editingContextId, Pageable pageable); + Page findAllByEditingContextId(String editingContextId, Pageable pageable); Optional findEditingContextIdFromRepresentationId(String representationId); + + Optional findRepresentationMetadataById(String representationMetadataId); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationDataMigrationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationContentMigrationService.java similarity index 66% rename from packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationDataMigrationService.java rename to packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationContentMigrationService.java index 712b4230cf2..e4bcd5e3ae6 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationDataMigrationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationContentMigrationService.java @@ -16,14 +16,15 @@ import java.util.Optional; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataContentOnly; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; /** - * Used to retrieved the migrated content of the representation data. + * Used to retrieve the migrated content of the representation content. * * @author sbegaudeau */ -public interface IRepresentationDataMigrationService { +public interface IRepresentationContentMigrationService { - Optional getMigratedContent(RepresentationDataContentOnly representationData); + Optional getMigratedContent(RepresentationMetadata representationMetadata, RepresentationContent representationContent); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationMetadataMapper.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationMetadataMapper.java new file mode 100644 index 00000000000..05b7c829f46 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/api/IRepresentationMetadataMapper.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.representation.services.api; + +import org.eclipse.sirius.web.application.representation.dto.RepresentationMetadataDTO; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; + +/** + * Used to convert a representation metadata to a DTO. + * + * @author gcoutable + */ +public interface IRepresentationMetadataMapper { + RepresentationMetadataDTO toDTO(RepresentationMetadata representationMetadata); +} diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExpandAllTreePathProvider.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExpandAllTreePathProvider.java index e2e595ac46e..b6bfdd2521f 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExpandAllTreePathProvider.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExpandAllTreePathProvider.java @@ -30,7 +30,7 @@ import org.eclipse.sirius.components.emf.services.api.IEMFEditingContext; import org.eclipse.sirius.components.trees.Tree; import org.eclipse.sirius.web.application.views.explorer.services.api.IExplorerNavigationService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.springframework.stereotype.Service; /** @@ -49,14 +49,14 @@ public class ExpandAllTreePathProvider implements IExpandAllTreePathProvider { private final IExplorerNavigationService explorerNavigationService; - private final IRepresentationDataSearchService representationDataSearchService; + private final IRepresentationMetadataSearchService representationMetadataSearchService; - public ExpandAllTreePathProvider(IObjectSearchService objectSearchService, IIdentityService identityService, IContentService contentService, IExplorerNavigationService explorerNavigationService, IRepresentationDataSearchService representationDataSearchService) { + public ExpandAllTreePathProvider(IObjectSearchService objectSearchService, IIdentityService identityService, IContentService contentService, IExplorerNavigationService explorerNavigationService, IRepresentationMetadataSearchService representationMetadataSearchService) { this.objectSearchService = Objects.requireNonNull(objectSearchService); this.identityService = Objects.requireNonNull(identityService); this.contentService = Objects.requireNonNull(contentService); this.explorerNavigationService = Objects.requireNonNull(explorerNavigationService); - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); + this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); } @Override @@ -119,7 +119,7 @@ private int addAllContents(IEditingContext editingContext, String treeItemId, in childTreePathMaxDepth = this.addAllContents(editingContext, childId, childTreePathMaxDepth, treeItemIdsToExpand); depthConsidered = Math.max(depthConsidered, childTreePathMaxDepth); } - } else if (this.representationDataSearchService.existAnyRepresentationForTargetObjectId(treeItemId)) { + } else if (this.representationMetadataSearchService.existAnyRepresentationForTargetObjectId(treeItemId)) { treeItemIdsToExpand.add(treeItemId); depthConsidered = Math.max(depthConsidered, depth + 1); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerChildrenProvider.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerChildrenProvider.java index 7fe5d6a9371..59a732d29e2 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerChildrenProvider.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerChildrenProvider.java @@ -19,15 +19,14 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.sirius.components.core.RepresentationMetadata; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.representations.VariableManager; import org.eclipse.sirius.components.trees.renderer.TreeRenderer; import org.eclipse.sirius.web.application.views.explorer.services.api.IExplorerChildrenProvider; import org.eclipse.sirius.web.application.views.explorer.services.api.IExplorerTreeItemAlteredContentProvider; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.springframework.stereotype.Service; /** @@ -42,14 +41,11 @@ public class ExplorerChildrenProvider implements IExplorerChildrenProvider { private final IRepresentationMetadataSearchService representationMetadataSearchService; - private final IRepresentationDataSearchService representationDataSearchService; - private final List alteredContentProviders; - public ExplorerChildrenProvider(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationDataSearchService representationDataSearchService, List alteredContentProviders) { + public ExplorerChildrenProvider(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService, List alteredContentProviders) { this.objectService = Objects.requireNonNull(objectService); this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); this.alteredContentProviders = Objects.requireNonNull(alteredContentProviders); } @@ -65,7 +61,7 @@ public boolean hasChildren(VariableManager variableManager) { if (!hasChildren) { String id = this.objectService.getId(eObject); - hasChildren = this.representationDataSearchService.existAnyRepresentationForTargetObjectId(id); + hasChildren = this.representationMetadataSearchService.existAnyRepresentationForTargetObjectId(id); } } return hasChildren; @@ -113,7 +109,7 @@ private List getDefaultChildren(VariableManager variableManager) { if (self instanceof Resource resource) { result.addAll(resource.getContents()); } else if (self instanceof EObject) { - var representationMetadata = new ArrayList<>(this.representationMetadataSearchService.findAllByTargetObjectId(editingContext, id)); + var representationMetadata = new ArrayList<>(this.representationMetadataSearchService.findAllMetadataByTargetObjectId(id)); representationMetadata.sort(Comparator.comparing(RepresentationMetadata::getLabel)); result.addAll(representationMetadata); List contents = this.objectService.getContents(self); @@ -140,7 +136,7 @@ private String getTreeItemId(VariableManager variableManager) { String id = null; if (self instanceof RepresentationMetadata representationMetadata) { - id = representationMetadata.getId(); + id = representationMetadata.getId().toString(); } else if (self instanceof Resource resource) { id = resource.getURI().path().substring(1); } else if (self instanceof EObject) { diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerDescriptionProvider.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerDescriptionProvider.java index a328d89c5a8..53b52b26760 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerDescriptionProvider.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerDescriptionProvider.java @@ -23,7 +23,6 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.sirius.components.collaborative.api.IRepresentationImageProvider; import org.eclipse.sirius.components.core.CoreImageConstants; -import org.eclipse.sirius.components.core.RepresentationMetadata; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IEditingContextRepresentationDescriptionProvider; import org.eclipse.sirius.components.core.api.IObjectService; @@ -41,6 +40,7 @@ import org.eclipse.sirius.web.application.views.explorer.services.api.IExplorerChildrenProvider; import org.eclipse.sirius.web.application.views.explorer.services.api.IExplorerElementsProvider; import org.eclipse.sirius.web.application.views.explorer.services.api.IRenameTreeItemHandler; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; import org.springframework.stereotype.Service; /** @@ -137,7 +137,7 @@ private String getTreeItemId(VariableManager variableManager) { String id = null; if (self instanceof RepresentationMetadata representationMetadata) { - id = representationMetadata.getId(); + id = representationMetadata.getId().toString(); } else if (self instanceof Resource resource) { id = resource.getURI().path().substring(1); } else if (self instanceof EObject) { diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerNavigationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerNavigationService.java index 87cbd2f86ef..042cc987e55 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerNavigationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerNavigationService.java @@ -24,8 +24,8 @@ import org.eclipse.sirius.components.core.api.IObjectSearchService; import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.application.views.explorer.services.api.IExplorerNavigationService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataMetadataOnly; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.springframework.stereotype.Service; /** @@ -40,25 +40,25 @@ public class ExplorerNavigationService implements IExplorerNavigationService { private final IObjectSearchService objectSearchService; - private final IRepresentationDataSearchService representationDataSearchService; + private final IRepresentationMetadataSearchService representationMetaDataSearchService; - public ExplorerNavigationService(IIdentityService identityService, IObjectSearchService objectSearchService, IRepresentationDataSearchService representationDataSearchService) { + public ExplorerNavigationService(IIdentityService identityService, IObjectSearchService objectSearchService, IRepresentationMetadataSearchService representationMetaDataSearchService) { this.identityService = Objects.requireNonNull(identityService); this.objectSearchService = Objects.requireNonNull(objectSearchService); - this.representationDataSearchService = Objects.requireNonNull(representationDataSearchService); + this.representationMetaDataSearchService = Objects.requireNonNull(representationMetaDataSearchService); } @Override public List getAncestors(IEditingContext editingContext, String treeItemId) { List ancestorsIds = new ArrayList<>(); - var optionalRepresentationMetadata = new UUIDParser().parse(treeItemId).flatMap(this.representationDataSearchService::findMetadataById); + var optionalRepresentationMetadata = new UUIDParser().parse(treeItemId).flatMap(this.representationMetaDataSearchService::findMetadataById); var optionalSemanticObject = this.objectSearchService.getObject(editingContext, treeItemId); Optional optionalObject = Optional.empty(); if (optionalRepresentationMetadata.isPresent()) { // The first parent of a representation item is the item for its targetObject. - optionalObject = optionalRepresentationMetadata.map(RepresentationDataMetadataOnly::targetObjectId) + optionalObject = optionalRepresentationMetadata.map(RepresentationMetadata::getTargetObjectId) .flatMap(objectId -> this.objectSearchService.getObject(editingContext, objectId)); } else if (optionalSemanticObject.isPresent()) { // The first parent of a semantic object item is the item for its actual container diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/representations/services/RepresentationsFormDescriptionProvider.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/representations/services/RepresentationsFormDescriptionProvider.java index d0fb4af5bfb..536accd931a 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/representations/services/RepresentationsFormDescriptionProvider.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/representations/services/RepresentationsFormDescriptionProvider.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.UUID; import java.util.function.Function; import org.eclipse.sirius.components.collaborative.api.ChangeKind; @@ -30,11 +31,9 @@ import org.eclipse.sirius.components.collaborative.forms.api.IRepresentationsDescriptionProvider; import org.eclipse.sirius.components.collaborative.forms.variables.FormVariableProvider; import org.eclipse.sirius.components.core.CoreImageConstants; -import org.eclipse.sirius.components.core.RepresentationMetadata; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IIdentityService; import org.eclipse.sirius.components.core.api.ILabelService; -import org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.components.forms.TreeNode; import org.eclipse.sirius.components.forms.WidgetIdProvider; import org.eclipse.sirius.components.forms.components.ListComponent; @@ -53,6 +52,9 @@ import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.web.application.UUIDParser; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.springframework.stereotype.Service; /** @@ -202,17 +204,13 @@ private String getTargetObjectId(VariableManager variableManager) { private List getItems(VariableManager variableManager) { Object object = variableManager.getVariables().get(VariableManager.SELF); String id = this.identityService.getId(object); - var optionalEditingContext = variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class); - if (optionalEditingContext.isPresent() && id != null) { - IEditingContext editingContext = optionalEditingContext.get(); - return this.representationMetadataSearchService.findAllByTargetObjectId(editingContext, id); - } - return List.of(); + return this.representationMetadataSearchService.findAllMetadataByTargetObjectId(id); } private String getItemId(VariableManager variableManager) { return variableManager.get(ListComponent.CANDIDATE_VARIABLE, RepresentationMetadata.class) .map(RepresentationMetadata::getId) + .map(UUID::toString) .orElse(null); } @@ -244,6 +242,7 @@ private List getItemIconURL(VariableManager variableManager) { private IStatus deleteItem(VariableManager variableManager) { return variableManager.get(ListComponent.CANDIDATE_VARIABLE, RepresentationMetadata.class) .map(RepresentationMetadata::getId) + .map(UUID::toString) .map(this::getSuccessStatus) .orElse(new Failure("")); } @@ -262,28 +261,29 @@ private List getChildren(VariableManager variableManager) { Object object = variableManager.getVariables().get(VariableManager.SELF); String id = this.identityService.getId(object); if (object instanceof Portal portal) { - items = this.getPortalChildren(optionalEditingContext.get(), portal); + items = this.getPortalChildren(portal); } else if (id != null) { - items = this.representationMetadataSearchService.findAllByTargetObjectId(editingContext, id); + items = this.representationMetadataSearchService.findAllMetadataByTargetObjectId(id).stream().toList(); } else if (object instanceof RepresentationMetadata representationMetadata && Portal.KIND.equals(representationMetadata.getKind())) { - Optional optionalPortal = this.representationSearchService.findById(editingContext, representationMetadata.getId(), Portal.class); - items = optionalPortal.map(portal -> this.getPortalChildren(editingContext, portal)).orElse(List.of()); + Optional optionalPortal = this.representationSearchService.findById(editingContext, representationMetadata.getId().toString(), Portal.class); + items = optionalPortal.map(this::getPortalChildren).orElse(List.of()); } } return items; } - private List getPortalChildren(IEditingContext editingContext, Portal portal) { + private List getPortalChildren(Portal portal) { return portal.getViews().stream() .map(PortalView::getRepresentationId) - .flatMap(representationId -> this.representationSearchService.findById(editingContext, representationId, IRepresentation.class).stream()) - .map(representation -> new RepresentationMetadata(representation.getId(), representation.getKind(), representation.getLabel(), representation.getDescriptionId())) + .flatMap(representationId -> new UUIDParser().parse(representationId).stream()) + .flatMap(representationId -> this.representationMetadataSearchService.findMetadataById(representationId).stream()) .toList(); } private String getNodeId(VariableManager variableManager) { return variableManager.get(VariableManager.SELF, RepresentationMetadata.class) .map(RepresentationMetadata::getId) + .map(UUID::toString) .orElse(null); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationContent.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationContent.java new file mode 100644 index 00000000000..2fe331e31c0 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationContent.java @@ -0,0 +1,170 @@ +/******************************************************************************* + * 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.domain.boundedcontexts.representationdata; + +import java.time.Instant; +import java.util.Objects; +import java.util.UUID; + +import org.eclipse.sirius.web.domain.boundedcontexts.AbstractValidatingAggregateRoot; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationContentCreatedEvent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationContentUpdatedEvent; +import org.springframework.data.annotation.Id; +import org.springframework.data.annotation.Transient; +import org.springframework.data.domain.Persistable; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.Table; + +/** + * The aggregate root of the representation content bounded context. + * + * @author gcoutable + */ +@Table("representation_content") +public class RepresentationContent extends AbstractValidatingAggregateRoot implements Persistable { + + @Transient + private boolean isNew; + + @Id + private UUID id; + + @Column("representation_metadata_id") + private AggregateReference representationMetadata; + + private String content; + + private String lastMigrationPerformed; + + private String migrationVersion; + + private Instant createdOn; + + private Instant lastModifiedOn; + + @Override + public UUID getId() { + return this.id; + } + + public String getContent() { + return this.content; + } + + public Instant getCreatedOn() { + return this.createdOn; + } + + public String getLastMigrationPerformed() { + return this.lastMigrationPerformed; + } + + public String getMigrationVersion() { + return this.migrationVersion; + } + + public Instant getLastModifiedOn() { + return this.lastModifiedOn; + } + + public void updateContent(String newContent) { + if (!Objects.equals(this.content, newContent)) { + this.content = newContent; + + var now = Instant.now(); + this.lastModifiedOn = now; + + this.registerEvent(new RepresentationContentUpdatedEvent(UUID.randomUUID(), now, this)); + } + } + + public void updateMigrationData(String newLastMigrationPerformed, String newMigrationVersion) { + if (!Objects.equals(this.migrationVersion, newMigrationVersion)) { + this.lastMigrationPerformed = Objects.requireNonNull(newLastMigrationPerformed); + this.migrationVersion = Objects.requireNonNull(newMigrationVersion); + this.lastModifiedOn = Instant.now(); + } + } + + @Override + public boolean isNew() { + return this.isNew; + } + + public static Builder newRepresentationContent(UUID id) { + return new Builder(id); + } + + /** + * Used to create new representation content. + * + * @author gcoutable + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + + private final UUID id; + + private AggregateReference representationMetadata; + + private String content; + + private String lastMigrationPerformed; + + private String migrationVersion; + + public Builder(UUID id) { + this.id = Objects.requireNonNull(id); + } + + public Builder representationMetadata(AggregateReference representationMetadata) { + this.representationMetadata = Objects.requireNonNull(representationMetadata); + return this; + } + + public Builder content(String content) { + this.content = Objects.requireNonNull(content); + return this; + } + + public Builder lastMigrationPerformed(String lastMigrationPerformed) { + this.lastMigrationPerformed = Objects.requireNonNull(lastMigrationPerformed); + return this; + } + + public Builder migrationVersion(String migrationVersion) { + this.migrationVersion = Objects.requireNonNull(migrationVersion); + return this; + } + + public RepresentationContent build() { + var representationContent = new RepresentationContent(); + representationContent.isNew = true; + representationContent.id = Objects.requireNonNull(this.id); + representationContent.representationMetadata = Objects.requireNonNull(this.representationMetadata); + representationContent.content = Objects.requireNonNull(this.content); + representationContent.lastMigrationPerformed = Objects.requireNonNull(this.lastMigrationPerformed); + representationContent.migrationVersion = Objects.requireNonNull(this.migrationVersion); + + var now = Instant.now(); + representationContent.createdOn = now; + representationContent.lastModifiedOn = now; + + representationContent.registerEvent(new RepresentationContentCreatedEvent(UUID.randomUUID(), now, representationContent)); + return representationContent; + } + + } +} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationData.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationMetadata.java similarity index 51% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationData.java rename to packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationMetadata.java index 2a3326d9d22..b4b94dbf485 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationData.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationMetadata.java @@ -18,9 +18,8 @@ import org.eclipse.sirius.web.domain.boundedcontexts.AbstractValidatingAggregateRoot; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationDataContentUpdatedEvent; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationDataCreatedEvent; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationDataDeletedEvent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationMetadataCreatedEvent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationMetadataDeletedEvent; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Transient; import org.springframework.data.domain.Persistable; @@ -29,12 +28,12 @@ import org.springframework.data.relational.core.mapping.Table; /** - * The aggregate root of the representation data bounded context. + * The aggregate root of the representation metadata bounded context. * * @author sbegaudeau */ -@Table("representation_data") -public class RepresentationData extends AbstractValidatingAggregateRoot implements Persistable { +@Table("representation_metadata") +public class RepresentationMetadata extends AbstractValidatingAggregateRoot implements Persistable { @Transient private boolean isNew; @@ -53,12 +52,6 @@ public class RepresentationData extends AbstractValidatingAggregateRoot, ListCrudRepository { + + @Query(""" + SELECT representationContent.* + FROM representation_content representationContent + WHERE representationContent.representation_metadata_id = :representationMetadataId + """) + Optional findContentByRepresentationMetadataId(UUID representationMetadataId); + +} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationDataRepository.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationDataRepository.java deleted file mode 100644 index 060ac212a6f..00000000000 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationDataRepository.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * 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.domain.boundedcontexts.representationdata.repositories; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataContentOnly; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataMetadataOnly; -import org.springframework.data.jdbc.repository.query.Query; -import org.springframework.data.repository.ListCrudRepository; -import org.springframework.data.repository.ListPagingAndSortingRepository; -import org.springframework.stereotype.Repository; - -/** - * Repository used to persist the representation data aggregate. - * - * @author sbegaudeau - */ -@Repository -public interface IRepresentationDataRepository extends ListPagingAndSortingRepository, ListCrudRepository { - @Query(""" - SELECT id, label, kind, target_object_id, description_id, project_id AS project - FROM representation_data representationData - WHERE representationData.id = :id - """) - Optional findMetadataById(UUID id); - - @Query(""" - SELECT id, label, kind, target_object_id, description_id, project_id AS project - FROM representation_data representationData - WHERE representationData.project_id = :projectId - """) - List findAllMetadataByProjectId(UUID projectId); - - @Query(""" - SELECT id, label, kind, target_object_id, description_id, project_id AS project - FROM representation_data representationData - WHERE representationData.target_object_id = :targetObjectId - """) - List findAllMetadataByTargetObjectId(String targetObjectId); - - @Query(""" - SELECT kind, content, last_migration_performed, migration_version - FROM representation_data representationData - WHERE representationData.id = :id - """) - Optional findContentById(UUID id); - - @Query(""" - SELECT representationData.project_id - FROM representation_data representationData - WHERE representationData.id = :representationId - """) - Optional findProjectIdFromRepresentationId(UUID representationId); - - @Query(""" - SELECT CASE WHEN COUNT(*) > 0 THEN true ELSE false END - FROM representation_data representationData - WHERE representationData.target_object_id = :targetObjectId - """) - boolean existAnyRepresentationForTargetObjectId(String targetObjectId); -} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationMetadataRepository.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationMetadataRepository.java new file mode 100644 index 00000000000..413503b836d --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationMetadataRepository.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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.domain.boundedcontexts.representationdata.repositories; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.springframework.data.jdbc.repository.query.Query; +import org.springframework.data.repository.ListCrudRepository; +import org.springframework.data.repository.ListPagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +/** + * Repository used to persist the representation metadata aggregate. + * + * @author sbegaudeau + */ +@Repository +public interface IRepresentationMetadataRepository extends ListPagingAndSortingRepository, ListCrudRepository { + + @Query(""" + SELECT representationMetadata.* + FROM representation_metadata representationMetadata + WHERE representationMetadata.id = :id + """) + Optional findMetadataById(UUID id); + + @Query(""" + SELECT representationMetadata.* + FROM representation_metadata representationMetadata + WHERE representationMetadata.project_id = :projectId + """) + List findAllMetadataByProjectId(UUID projectId); + + @Query(""" + SELECT representationMetadata.* + FROM representation_metadata representationMetadata + WHERE representationMetadata.target_object_id = :targetObjectId + """) + List findAllMetadataByTargetObjectId(String targetObjectId); + + @Query(""" + SELECT representationMetadata.project_id + FROM representation_metadata representationMetadata + WHERE representationMetadata.id = :representationId + """) + Optional findProjectIdFromRepresentationId(UUID representationId); + + @Query(""" + SELECT CASE WHEN COUNT(*) > 0 THEN true ELSE false END + FROM representation_metadata representationMetadata + WHERE representationMetadata.target_object_id = :targetObjectId + """) + boolean existAnyRepresentationForTargetObjectId(String targetObjectId); +} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentCreationService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentCreationService.java new file mode 100644 index 00000000000..846107baf54 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentCreationService.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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.domain.boundedcontexts.representationdata.services; + +import java.util.Objects; + +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationContentRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentCreationService; +import org.eclipse.sirius.web.domain.services.IResult; +import org.eclipse.sirius.web.domain.services.Success; +import org.springframework.stereotype.Service; + +/** + * Used to create new representation content. + * + * @author gcoutable + */ +@Service +public class RepresentationContentCreationService implements IRepresentationContentCreationService { + + private final IRepresentationContentRepository representationContentRepository; + + public RepresentationContentCreationService(IRepresentationContentRepository representationContentRepository) { + this.representationContentRepository = Objects.requireNonNull(representationContentRepository); + } + + @Override + public IResult create(RepresentationContent representationContent) { + this.representationContentRepository.save(representationContent); + return new Success<>(representationContent); + } +} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentSearchService.java new file mode 100644 index 00000000000..edbeb397119 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentSearchService.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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.domain.boundedcontexts.representationdata.services; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationContentRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentSearchService; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.stereotype.Service; + +/** + * Used to find representation content. + * + * @author gcoutable + */ +@Service +public class RepresentationContentSearchService implements IRepresentationContentSearchService { + + private final IRepresentationContentRepository representationContentRepository; + + public RepresentationContentSearchService(IRepresentationContentRepository representationContentRepository) { + this.representationContentRepository = Objects.requireNonNull(representationContentRepository); + } + + @Override + public Optional findContentByRepresentationMetadata(AggregateReference representationMetadata) { + return this.representationContentRepository.findContentByRepresentationMetadataId(representationMetadata.getId()); + } +} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentUpdateService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentUpdateService.java new file mode 100644 index 00000000000..97c396f654e --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationContentUpdateService.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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.domain.boundedcontexts.representationdata.services; + +import java.util.Objects; +import java.util.UUID; + +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationContentRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentUpdateService; +import org.eclipse.sirius.web.domain.services.Failure; +import org.eclipse.sirius.web.domain.services.IResult; +import org.eclipse.sirius.web.domain.services.Success; +import org.eclipse.sirius.web.domain.services.api.IMessageService; +import org.springframework.stereotype.Service; + +/** + * Used to update representation content. + * + * @author sbegaudeau + */ +@Service +public class RepresentationContentUpdateService implements IRepresentationContentUpdateService { + + private final IRepresentationContentRepository representationContentRepository; + + private final IMessageService messageService; + + public RepresentationContentUpdateService(IRepresentationContentRepository representationContentRepository, IMessageService messageService) { + this.representationContentRepository = Objects.requireNonNull(representationContentRepository); + this.messageService = Objects.requireNonNull(messageService); + } + + @Override + public IResult updateContentByRepresentationId(UUID representationId, String content) { + IResult result = null; + + var optionalRepresentationContent = this.representationContentRepository.findContentByRepresentationMetadataId(representationId); + if (optionalRepresentationContent.isPresent()) { + var representationContent = optionalRepresentationContent.get(); + representationContent.updateContent(content); + this.representationContentRepository.save(representationContent); + + result = new Success<>(null); + } else { + result = new Failure<>(this.messageService.notFound()); + } + + return result; + } + + @Override + public IResult updateContentByRepresentationIdWithMigrationData(UUID representationId, String content, String lastMigrationPerformed, String migrationVersion) { + IResult result = null; + + var optionalRepresentationContent = this.representationContentRepository.findContentByRepresentationMetadataId(representationId); + if (optionalRepresentationContent.isPresent()) { + var representationMetadata = optionalRepresentationContent.get(); + representationMetadata.updateContent(content); + representationMetadata.updateMigrationData(lastMigrationPerformed, migrationVersion); + this.representationContentRepository.save(representationMetadata); + + result = new Success<>(null); + } else { + result = new Failure<>(this.messageService.notFound()); + } + + return result; + } +} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataSearchService.java deleted file mode 100644 index 1a981cea8ac..00000000000 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataSearchService.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * 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.domain.boundedcontexts.representationdata.services; - -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; - -import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataContentOnly; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataMetadataOnly; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; -import org.springframework.data.jdbc.core.mapping.AggregateReference; -import org.springframework.stereotype.Service; - -/** - * Used to find representation data. - * - * @author sbegaudeau - */ -@Service -public class RepresentationDataSearchService implements IRepresentationDataSearchService { - - private final IRepresentationDataRepository representationDataRepository; - - public RepresentationDataSearchService(IRepresentationDataRepository representationDataRepository) { - this.representationDataRepository = Objects.requireNonNull(representationDataRepository); - } - - @Override - public boolean existsById(UUID id) { - return this.representationDataRepository.existsById(id); - } - - @Override - public Optional findContentById(UUID id) { - return this.representationDataRepository.findContentById(id); - } - - @Override - public Optional findMetadataById(UUID id) { - return this.representationDataRepository.findMetadataById(id); - } - - @Override - public List findAllMetadataByProject(AggregateReference project) { - return this.representationDataRepository.findAllMetadataByProjectId(project.getId()); - } - - @Override - public List findAllMetadataByTargetObjectId(String targetObjectId) { - return this.representationDataRepository.findAllMetadataByTargetObjectId(targetObjectId); - } - - @Override - public boolean existAnyRepresentationForTargetObjectId(String targetObjectId) { - return this.representationDataRepository.existAnyRepresentationForTargetObjectId(targetObjectId); - } - - @Override - public Optional> findProjectByRepresentationId(UUID representationId) { - return this.representationDataRepository.findProjectIdFromRepresentationId(representationId) - .map(AggregateReference::to); - } -} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataUpdateService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataUpdateService.java deleted file mode 100644 index cb0e921e7e9..00000000000 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataUpdateService.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * 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.domain.boundedcontexts.representationdata.services; - -import java.util.Objects; -import java.util.UUID; - -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataUpdateService; -import org.eclipse.sirius.web.domain.services.Failure; -import org.eclipse.sirius.web.domain.services.IResult; -import org.eclipse.sirius.web.domain.services.Success; -import org.eclipse.sirius.web.domain.services.api.IMessageService; -import org.springframework.stereotype.Service; - -/** - * Used to update representation data. - * - * @author sbegaudeau - */ -@Service -public class RepresentationDataUpdateService implements IRepresentationDataUpdateService { - - private final IRepresentationDataRepository representationDataRepository; - - private final IMessageService messageService; - - public RepresentationDataUpdateService(IRepresentationDataRepository representationDataRepository, IMessageService messageService) { - this.representationDataRepository = Objects.requireNonNull(representationDataRepository); - this.messageService = Objects.requireNonNull(messageService); - } - - @Override - public IResult updateContent(UUID id, String content) { - IResult result = null; - - var optionalRepresentationData = this.representationDataRepository.findById(id); - if (optionalRepresentationData.isPresent()) { - var representationData = optionalRepresentationData.get(); - representationData.updateContent(content); - this.representationDataRepository.save(representationData); - - result = new Success<>(null); - } else { - result = new Failure<>(this.messageService.notFound()); - } - - return result; - } - - @Override - public IResult updateContentWithMigrationData(UUID id, String content, String lastMigrationPerformed, String migrationVersion) { - IResult result = null; - - var optionalRepresentationData = this.representationDataRepository.findById(id); - if (optionalRepresentationData.isPresent()) { - var representationData = optionalRepresentationData.get(); - representationData.updateContent(content); - representationData.updateMigrationData(lastMigrationPerformed, migrationVersion); - this.representationDataRepository.save(representationData); - - result = new Success<>(null); - } else { - result = new Failure<>(this.messageService.notFound()); - } - - return result; - } -} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataCreationService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataCreationService.java similarity index 55% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataCreationService.java rename to packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataCreationService.java index 3e096e04260..28f981382ce 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataCreationService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataCreationService.java @@ -14,30 +14,30 @@ import java.util.Objects; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataCreationService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationMetadataRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataCreationService; import org.eclipse.sirius.web.domain.services.IResult; import org.eclipse.sirius.web.domain.services.Success; import org.springframework.stereotype.Service; /** - * Used to create new representation data. + * Used to create new representation metadata. * * @author sbegaudeau */ @Service -public class RepresentationDataCreationService implements IRepresentationDataCreationService { +public class RepresentationMetadataCreationService implements IRepresentationMetadataCreationService { - private final IRepresentationDataRepository representationDataRepository; + private final IRepresentationMetadataRepository representationMetadataRepository; - public RepresentationDataCreationService(IRepresentationDataRepository representationDataRepository) { - this.representationDataRepository = Objects.requireNonNull(representationDataRepository); + public RepresentationMetadataCreationService(IRepresentationMetadataRepository representationMetadataRepository) { + this.representationMetadataRepository = Objects.requireNonNull(representationMetadataRepository); } @Override - public IResult create(RepresentationData representationData) { - this.representationDataRepository.save(representationData); - return new Success<>(representationData); + public IResult create(RepresentationMetadata representationMetadata) { + this.representationMetadataRepository.save(representationMetadata); + return new Success<>(representationMetadata); } } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataDeletionService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataDeletionService.java similarity index 57% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataDeletionService.java rename to packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataDeletionService.java index 8823161bdde..b840ed71a96 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationDataDeletionService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataDeletionService.java @@ -15,8 +15,8 @@ import java.util.Objects; import java.util.UUID; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataDeletionService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationMetadataRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataDeletionService; import org.eclipse.sirius.web.domain.services.Failure; import org.eclipse.sirius.web.domain.services.IResult; import org.eclipse.sirius.web.domain.services.Success; @@ -24,32 +24,32 @@ import org.springframework.stereotype.Service; /** - * Used to delete representation data. + * Used to delete representation metadata. * * @author sbegaudeau */ @Service -public class RepresentationDataDeletionService implements IRepresentationDataDeletionService { +public class RepresentationMetadataDeletionService implements IRepresentationMetadataDeletionService { - private final IRepresentationDataRepository representationDataRepository; + private final IRepresentationMetadataRepository representationMetadataRepository; private final IMessageService messageService; - public RepresentationDataDeletionService(IRepresentationDataRepository representationDataRepository, IMessageService messageService) { - this.representationDataRepository = Objects.requireNonNull(representationDataRepository); + public RepresentationMetadataDeletionService(IRepresentationMetadataRepository representationMetadataRepository, IMessageService messageService) { + this.representationMetadataRepository = Objects.requireNonNull(representationMetadataRepository); this.messageService = Objects.requireNonNull(messageService); } @Override - public IResult delete(UUID representationDataId) { + public IResult delete(UUID representationMetadataId) { IResult result = null; - var optionalRepresentationData = this.representationDataRepository.findById(representationDataId); - if (optionalRepresentationData.isPresent()) { - var representationData = optionalRepresentationData.get(); - representationData.dispose(); + var optionalRepresentationMetadata = this.representationMetadataRepository.findById(representationMetadataId); + if (optionalRepresentationMetadata.isPresent()) { + var representationMetadata = optionalRepresentationMetadata.get(); + representationMetadata.dispose(); - this.representationDataRepository.delete(representationData); + this.representationMetadataRepository.delete(representationMetadata); result = new Success<>(null); } else { result = new Failure<>(this.messageService.notFound()); diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataSearchService.java new file mode 100644 index 00000000000..6396c68708a --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataSearchService.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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.domain.boundedcontexts.representationdata.services; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationMetadataRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.stereotype.Service; + +/** + * Used to find representation metadata. + * + * @author sbegaudeau + */ +@Service +public class RepresentationMetadataSearchService implements IRepresentationMetadataSearchService { + + private final IRepresentationMetadataRepository representationMetadataRepository; + + public RepresentationMetadataSearchService(IRepresentationMetadataRepository representationMetadataRepository) { + this.representationMetadataRepository = Objects.requireNonNull(representationMetadataRepository); + } + + @Override + public boolean existsById(UUID id) { + return this.representationMetadataRepository.existsById(id); + } + + @Override + public Optional findMetadataById(UUID id) { + return this.representationMetadataRepository.findMetadataById(id); + } + + @Override + public List findAllMetadataByProject(AggregateReference project) { + return this.representationMetadataRepository.findAllMetadataByProjectId(project.getId()); + } + + @Override + public List findAllMetadataByTargetObjectId(String targetObjectId) { + return this.representationMetadataRepository.findAllMetadataByTargetObjectId(targetObjectId); + } + + @Override + public boolean existAnyRepresentationForTargetObjectId(String targetObjectId) { + return this.representationMetadataRepository.existAnyRepresentationForTargetObjectId(targetObjectId); + } + + @Override + public Optional> findProjectByRepresentationId(UUID representationId) { + return this.representationMetadataRepository.findProjectIdFromRepresentationId(representationId) + .map(AggregateReference::to); + } +} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentCreationService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentCreationService.java new file mode 100644 index 00000000000..7db5dc4d344 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentCreationService.java @@ -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.domain.boundedcontexts.representationdata.services.api; + +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.services.IResult; + +/** + * Used to create new representation content. + * + * @author gcoutable + */ +public interface IRepresentationContentCreationService { + IResult create(RepresentationContent representationContent); +} diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/projections/RepresentationDataMetadataOnly.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentSearchService.java similarity index 57% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/projections/RepresentationDataMetadataOnly.java rename to packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentSearchService.java index 73bdfebbc2a..115efaa8d09 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/projections/RepresentationDataMetadataOnly.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentSearchService.java @@ -10,23 +10,22 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -package org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections; +package org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api; + +import java.util.Optional; import java.util.UUID; -import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; import org.springframework.data.jdbc.core.mapping.AggregateReference; /** - * Projection used to retrieve only the representation metadata of the representation data. + * Used to find representation content. * - * @author sbegaudeau + * @author gcoutable */ -public record RepresentationDataMetadataOnly( - UUID id, - String label, - String kind, - String targetObjectId, - String descriptionId, - AggregateReference project) { +public interface IRepresentationContentSearchService { + + Optional findContentByRepresentationMetadata(AggregateReference representationMetadata); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataUpdateService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentUpdateService.java similarity index 66% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataUpdateService.java rename to packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentUpdateService.java index 47059ab2cea..dfe17e246f2 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataUpdateService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationContentUpdateService.java @@ -17,13 +17,13 @@ import org.eclipse.sirius.web.domain.services.IResult; /** - * Used to update existing representation data. + * Used to update existing representation content. * * @author sbegaudeau */ -public interface IRepresentationDataUpdateService { +public interface IRepresentationContentUpdateService { - IResult updateContent(UUID id, String content); + IResult updateContentByRepresentationId(UUID representationId, String content); - IResult updateContentWithMigrationData(UUID id, String content, String lastMigrationPerformed, String migrationVersion); + IResult updateContentByRepresentationIdWithMigrationData(UUID representationId, String content, String lastMigrationPerformed, String migrationVersion); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataCreationService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataCreationService.java similarity index 76% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataCreationService.java rename to packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataCreationService.java index f7d61fbe259..8ea04467a3a 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataCreationService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataCreationService.java @@ -12,14 +12,14 @@ *******************************************************************************/ package org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; import org.eclipse.sirius.web.domain.services.IResult; /** - * Used to create new representation data. + * Used to create new representation metadata. * * @author sbegaudeau */ -public interface IRepresentationDataCreationService { - IResult create(RepresentationData representationData); +public interface IRepresentationMetadataCreationService { + IResult create(RepresentationMetadata representationMetadata); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataDeletionService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataDeletionService.java similarity index 82% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataDeletionService.java rename to packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataDeletionService.java index b2e7c88b843..5f61e5ac333 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataDeletionService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataDeletionService.java @@ -17,10 +17,10 @@ import org.eclipse.sirius.web.domain.services.IResult; /** - * Used to delete representation data. + * Used to delete representation metadata. * * @author sbegaudeau */ -public interface IRepresentationDataDeletionService { - IResult delete(UUID representationDataId); +public interface IRepresentationMetadataDeletionService { + IResult delete(UUID representationMetadataId); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataSearchService.java similarity index 65% rename from packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataSearchService.java rename to packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataSearchService.java index 2055899db98..9e852961fb0 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationDataSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataSearchService.java @@ -17,26 +17,23 @@ import java.util.UUID; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataContentOnly; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.projections.RepresentationDataMetadataOnly; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; import org.springframework.data.jdbc.core.mapping.AggregateReference; /** - * Used to find representation data. + * Used to find representation metadata. * * @author sbegaudeau */ -public interface IRepresentationDataSearchService { +public interface IRepresentationMetadataSearchService { boolean existsById(UUID id); - Optional findContentById(UUID id); + Optional findMetadataById(UUID id); - Optional findMetadataById(UUID id); + List findAllMetadataByProject(AggregateReference project); - List findAllMetadataByProject(AggregateReference project); - - List findAllMetadataByTargetObjectId(String targetObjectId); + List findAllMetadataByTargetObjectId(String targetObjectId); boolean existAnyRepresentationForTargetObjectId(String targetObjectId); diff --git a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2024.9/01-split-representation-metadata-from-content.xml b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2024.9/01-split-representation-metadata-from-content.xml new file mode 100644 index 00000000000..b6fc44bf521 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2024.9/01-split-representation-metadata-from-content.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO representation_content ( + representation_metadata_id, + content, + last_migration_performed, + migration_version, + created_on, + last_modified_on + ) + SELECT + representationData.id, + representationData.content, + representationData.last_migration_performed, + representationData.migration_version, + representationData.created_on, + representationData.last_modified_on + FROM representation_data representationData + + + + + + + + + diff --git a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2024.9/2024.9.0.xml b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2024.9/2024.9.0.xml new file mode 100644 index 00000000000..abdd87c306c --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2024.9/2024.9.0.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/db.changelog-master.xml b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/db.changelog-master.xml index 29ed298bb8c..8652fd5f818 100644 --- a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/db.changelog-master.xml +++ b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/db.changelog-master.xml @@ -17,4 +17,5 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd"> - \ No newline at end of file + + diff --git a/packages/sirius-web/backend/sirius-web-tests/pom.xml b/packages/sirius-web/backend/sirius-web-tests/pom.xml index 0168a166a69..392c3e23b22 100644 --- a/packages/sirius-web/backend/sirius-web-tests/pom.xml +++ b/packages/sirius-web/backend/sirius-web-tests/pom.xml @@ -75,6 +75,11 @@ sirius-components-collaborative-gantt 2024.7.9 + + org.eclipse.sirius + sirius-components-portals-tests + 2024.7.9 + diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/api/IGivenCreatedPortalSubscription.java b/packages/sirius-web/backend/sirius-web-tests/src/main/java/org/eclipse/sirius/web/tests/services/api/IGivenCreatedPortalSubscription.java similarity index 94% rename from packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/api/IGivenCreatedPortalSubscription.java rename to packages/sirius-web/backend/sirius-web-tests/src/main/java/org/eclipse/sirius/web/tests/services/api/IGivenCreatedPortalSubscription.java index a6a1c0dc0a2..5a0e689bcf2 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/api/IGivenCreatedPortalSubscription.java +++ b/packages/sirius-web/backend/sirius-web-tests/src/main/java/org/eclipse/sirius/web/tests/services/api/IGivenCreatedPortalSubscription.java @@ -10,7 +10,7 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -package org.eclipse.sirius.web.services.api; +package org.eclipse.sirius.web.tests.services.api; import org.eclipse.sirius.components.collaborative.dto.CreateRepresentationInput; import org.eclipse.sirius.components.collaborative.portals.dto.PortalRefreshedEventPayload; diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/portals/GivenCreatedPortalSubscription.java b/packages/sirius-web/backend/sirius-web-tests/src/main/java/org/eclipse/sirius/web/tests/services/portals/GivenCreatedPortalSubscription.java similarity index 95% rename from packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/portals/GivenCreatedPortalSubscription.java rename to packages/sirius-web/backend/sirius-web-tests/src/main/java/org/eclipse/sirius/web/tests/services/portals/GivenCreatedPortalSubscription.java index 2caf624c23e..27102782b72 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/portals/GivenCreatedPortalSubscription.java +++ b/packages/sirius-web/backend/sirius-web-tests/src/main/java/org/eclipse/sirius/web/tests/services/portals/GivenCreatedPortalSubscription.java @@ -10,7 +10,7 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -package org.eclipse.sirius.web.services.portals; +package org.eclipse.sirius.web.tests.services.portals; import java.util.Objects; import java.util.UUID; @@ -19,8 +19,8 @@ import org.eclipse.sirius.components.collaborative.portals.dto.PortalEventInput; import org.eclipse.sirius.components.collaborative.portals.dto.PortalRefreshedEventPayload; import org.eclipse.sirius.components.portals.tests.graphql.PortalEventSubscriptionRunner; -import org.eclipse.sirius.web.services.api.IGivenCreatedPortalSubscription; import org.eclipse.sirius.web.tests.services.api.IGivenCommittedTransaction; +import org.eclipse.sirius.web.tests.services.api.IGivenCreatedPortalSubscription; import org.eclipse.sirius.web.tests.services.api.IGivenCreatedRepresentation; import org.springframework.stereotype.Service; import org.springframework.test.context.transaction.TestTransaction; diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/diagrams/DomainDiagramControllerTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/diagrams/DomainDiagramControllerTests.java index c5599a18c6c..53fea1dcd26 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/diagrams/DomainDiagramControllerTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/diagrams/DomainDiagramControllerTests.java @@ -42,8 +42,10 @@ import org.eclipse.sirius.web.AbstractIntegrationTests; import org.eclipse.sirius.web.application.studio.services.representations.api.IDomainDiagramDescriptionProvider; import org.eclipse.sirius.web.data.StudioIdentifiers; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationContentRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationMetadataRepository; import org.eclipse.sirius.web.tests.services.api.IGivenCreatedDiagramSubscription; import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; import org.junit.jupiter.api.BeforeEach; @@ -79,7 +81,10 @@ public class DomainDiagramControllerTests extends AbstractIntegrationTests { private IDomainDiagramDescriptionProvider domainDiagramDescriptionProvider; @Autowired - private IRepresentationDataRepository representationDataRepository; + private IRepresentationMetadataRepository representationMetadataRepository; + + @Autowired + private IRepresentationContentRepository representationContentRepository; @Autowired private LayoutDiagramMutationRunner layoutDiagramMutationRunner; @@ -135,7 +140,8 @@ public void givenDomainDiagramOnStudioWhenMovingNodeAndThenReloadingPreviousStat var diagramId = new AtomicReference(); var currentRevisionId = new AtomicReference(); var humanNodeId = new AtomicReference(); - var initialDiagramData = new AtomicReference(null); + var initialDiagramMetadata = new AtomicReference(null); + var initialDiagramContent = new AtomicReference(null); Consumer initialDiagramContentConsumer = payload -> Optional.of(payload) .map(diagramPayload -> { @@ -165,7 +171,12 @@ public void givenDomainDiagramOnStudioWhenMovingNodeAndThenReloadingPreviousStat assertThat(humanNodeLayout).isNotNull(); assertThat(humanNodeLayout.position()).isEqualTo(initialPosition); assertThat(humanNodeLayout.size()).isEqualTo(initialSize); - this.representationDataRepository.findById(UUID.fromString(diagramId.get())).ifPresent(initialDiagramData::set); + var optionalRepresentationMetadata = this.representationMetadataRepository.findById(UUID.fromString(diagramId.get())); + if (optionalRepresentationMetadata.isPresent()) { + var representationMetadata = optionalRepresentationMetadata.get(); + initialDiagramMetadata.set(representationMetadata); + this.representationContentRepository.findContentByRepresentationMetadataId(representationMetadata.getId()).ifPresent(initialDiagramContent::set); + } }, () -> fail(MISSING_DIAGRAM)); Runnable modifyDiagramLayout = () -> { @@ -186,9 +197,9 @@ public void givenDomainDiagramOnStudioWhenMovingNodeAndThenReloadingPreviousStat assertThat(humanNodeLayout.position()).isEqualTo(modifiedPosition); assertThat(humanNodeLayout.size()).isEqualTo(modifiedSize); - var modifiedDiagramData = this.representationDataRepository.findById(UUID.fromString(diagramId.get())).get(); - assertThat(modifiedDiagramData).isNotEqualTo(initialDiagramData.get()); - assertThat(modifiedDiagramData.getContent()).isNotEqualTo(initialDiagramData.get().getContent()); + var modifiedDiagramMetadata = this.representationMetadataRepository.findById(UUID.fromString(diagramId.get())).get(); + var modifiedDiagramContent = this.representationContentRepository.findContentByRepresentationMetadataId(modifiedDiagramMetadata.getId()).get(); + assertThat(modifiedDiagramContent.getContent()).isNotEqualTo(initialDiagramContent.get().getContent()); }, () -> fail(MISSING_DIAGRAM)); StepVerifier.create(flux) @@ -197,14 +208,15 @@ public void givenDomainDiagramOnStudioWhenMovingNodeAndThenReloadingPreviousStat .consumeNextWith(initialDiagramLayoutConsumer) .then(modifyDiagramLayout) .consumeNextWith(modifiedDiagramLayoutConsumer) - .then(() -> this.reload(diagramId.get(), initialDiagramData.get())) + .then(() -> this.reload(diagramId.get(), initialDiagramMetadata.get(), initialDiagramContent.get())) .consumeNextWith(initialDiagramLayoutConsumer) .thenCancel() .verify(Duration.ofSeconds(10)); } - private void reload(String diagramId, RepresentationData representationData) { - this.representationDataRepository.save(representationData); + private void reload(String diagramId, RepresentationMetadata representationMetadata, RepresentationContent representationContent) { + this.representationMetadataRepository.save(representationMetadata); + this.representationContentRepository.save(representationContent); TestTransaction.flagForCommit(); TestTransaction.end(); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/formdescriptioneditors/FormDescriptionEditorLifecycleControllerTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/formdescriptioneditors/FormDescriptionEditorLifecycleControllerTests.java index 550a25047be..7a6407ec61c 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/formdescriptioneditors/FormDescriptionEditorLifecycleControllerTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/formdescriptioneditors/FormDescriptionEditorLifecycleControllerTests.java @@ -36,8 +36,8 @@ import org.eclipse.sirius.web.AbstractIntegrationTests; import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.data.StudioIdentifiers; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationMetadataRepository; import org.eclipse.sirius.web.tests.services.api.IGivenCreatedFormDescriptionEditorSubscription; import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; import org.eclipse.sirius.web.tests.services.formdescriptioneditors.AddWidgetMutationRunner; @@ -79,7 +79,7 @@ public class FormDescriptionEditorLifecycleControllerTests extends AbstractInteg private IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry; @Autowired - private IRepresentationDataRepository representationDataRepository; + private IRepresentationMetadataRepository representationMetadataRepository; @BeforeEach public void beforeEach() { @@ -101,7 +101,7 @@ public void givenFormDescriptionEditorRepresentationWhenWeReloadItThenTheNewVers var flux = this.givenCreatedFormDescriptionEditorSubscription.createAndSubscribe(input); var formDescriptionEditorId = new AtomicReference(); - var representationData = new AtomicReference(); + var representationMetadata = new AtomicReference(); var newWidgetId = new AtomicReference(); Consumer initialFormDescriptionEditorContentConsumer = payload -> Optional.of(payload) @@ -112,8 +112,8 @@ public void givenFormDescriptionEditorRepresentationWhenWeReloadItThenTheNewVers assertThat(firstGroup.getWidgets()).hasSize(4); var representationId = new UUIDParser().parse(formDescriptionEditor.getId()).orElseThrow(() -> new IllegalArgumentException("Invalid identifier")); - this.representationDataRepository.findById(representationId) - .ifPresentOrElse(representationData::set, () -> fail("Missing representation data")); + this.representationMetadataRepository.findById(representationId) + .ifPresentOrElse(representationMetadata::set, () -> fail("Missing representation data")); }, () -> fail("Missing form description editor")); Runnable addWidget = () -> { @@ -154,7 +154,7 @@ public void givenFormDescriptionEditorRepresentationWhenWeReloadItThenTheNewVers TestTransaction.start(); // Ask the FormDescriptionEditor to reload (and thus refresh on the restored FormDescription state) - this.representationDataRepository.save(representationData.get()); + this.representationMetadataRepository.save(representationMetadata.get()); TestTransaction.flagForCommit(); TestTransaction.end(); TestTransaction.start(); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/forms/FormControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/forms/FormControllerIntegrationTests.java index 88999a91ccb..faa29fcc965 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/forms/FormControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/forms/FormControllerIntegrationTests.java @@ -42,8 +42,8 @@ import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.data.StudioIdentifiers; import org.eclipse.sirius.web.data.TestIdentifiers; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationMetadataRepository; import org.eclipse.sirius.web.services.forms.FormVariableViewPreEditingContextProcessor; import org.eclipse.sirius.web.services.forms.MasterDetailsFormDescriptionProvider; import org.eclipse.sirius.web.tests.services.api.IGivenCreatedFormSubscription; @@ -86,7 +86,7 @@ public class FormControllerIntegrationTests extends AbstractIntegrationTests { private IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry; @Autowired - private IRepresentationDataRepository representationDataRepository; + private IRepresentationMetadataRepository representationMetadataRepository; @BeforeEach public void beforeEach() { @@ -197,7 +197,7 @@ public void givenViewBasedFormWhenReloadTriggeredThenFormIsRefreshed() { var flux = this.givenCreatedFormSubscription.createAndSubscribe(input); var formId = new AtomicReference(); - var representationData = new AtomicReference(); + var representationMetadata = new AtomicReference(); Consumer initialFormContentConsumer = payload -> Optional.of(payload) .map(FormRefreshedEventPayload::form) @@ -211,12 +211,12 @@ public void givenViewBasedFormWhenReloadTriggeredThenFormIsRefreshed() { var representationId = new UUIDParser().parse(form.getId()).orElseThrow(() -> new IllegalArgumentException("Invalid identifier")); formId.set(form.getId()); - this.representationDataRepository.findById(representationId).ifPresentOrElse(representationData::set, () -> fail("Missing representation data")); + this.representationMetadataRepository.findById(representationId).ifPresentOrElse(representationMetadata::set, () -> fail("Missing representation data")); }, () -> fail("Missing form")); Runnable reloadForm = () -> { // Ask the Form to reload (and thus to refresh) - this.representationDataRepository.save(representationData.get()); + this.representationMetadataRepository.save(representationMetadata.get()); TestTransaction.flagForCommit(); TestTransaction.end(); TestTransaction.start(); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/gantt/GanttLifecycleControllerTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/gantt/GanttLifecycleControllerTests.java index 253895dec38..6a95d9b742e 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/gantt/GanttLifecycleControllerTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/gantt/GanttLifecycleControllerTests.java @@ -37,8 +37,8 @@ import org.eclipse.sirius.web.AbstractIntegrationTests; import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.data.PapayaIdentifiers; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationContentRepository; import org.eclipse.sirius.web.services.gantt.PapayaGanttDescriptionProvider; import org.eclipse.sirius.web.tests.services.api.IGivenCreatedGanttSubscription; import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; @@ -80,7 +80,7 @@ public class GanttLifecycleControllerTests extends AbstractIntegrationTests { private IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry; @Autowired - private IRepresentationDataRepository representationDataRepository; + private IRepresentationContentRepository representationContentRepository; @BeforeEach public void beforeEach() { @@ -109,7 +109,7 @@ public void givenGanttRepresentationWhenWeReloadItThenTheNewVersionIsSent() { var ganttId = new AtomicReference(); var taskId = new AtomicReference(); - var representationData = new AtomicReference(); + var representationContent = new AtomicReference(); Consumer initialGanttContentConsumer = payload -> Optional.of(payload) .map(GanttRefreshedEventPayload::gantt) @@ -121,8 +121,8 @@ public void givenGanttRepresentationWhenWeReloadItThenTheNewVersionIsSent() { taskId.set(task.id()); var representationId = new UUIDParser().parse(gantt.getId()).orElseThrow(() -> new IllegalArgumentException("Invalid identifier")); - this.representationDataRepository.findById(representationId) - .ifPresentOrElse(representationData::set, () -> fail("Missing representation data")); + this.representationContentRepository.findContentByRepresentationMetadataId(representationId) + .ifPresentOrElse(representationContent::set, () -> fail("Missing representation data")); }, () -> fail("Missing gantt")); @@ -146,7 +146,7 @@ public void givenGanttRepresentationWhenWeReloadItThenTheNewVersionIsSent() { }, () -> fail("Missing gantt")); Runnable reloadGantt = () -> { - this.representationDataRepository.save(representationData.get()); + this.representationContentRepository.save(representationContent.get()); TestTransaction.flagForCommit(); TestTransaction.end(); TestTransaction.start(); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/portal/PortalControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/portal/PortalControllerIntegrationTests.java index 39355151908..43ad4eb82ca 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/portal/PortalControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/portal/PortalControllerIntegrationTests.java @@ -15,6 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +import com.jayway.jsonpath.JsonPath; + import java.time.Duration; import java.util.List; import java.util.Optional; @@ -28,21 +30,24 @@ import org.eclipse.sirius.components.collaborative.api.IEditingContextEventProcessor; import org.eclipse.sirius.components.collaborative.api.IEditingContextEventProcessorRegistry; import org.eclipse.sirius.components.collaborative.dto.CreateRepresentationInput; +import org.eclipse.sirius.components.collaborative.portals.dto.AddPortalViewInput; import org.eclipse.sirius.components.collaborative.portals.dto.LayoutPortalInput; import org.eclipse.sirius.components.collaborative.portals.dto.PortalEventInput; import org.eclipse.sirius.components.collaborative.portals.dto.PortalRefreshedEventPayload; import org.eclipse.sirius.components.collaborative.portals.dto.PortalViewLayoutDataInput; import org.eclipse.sirius.components.core.api.IInput; +import org.eclipse.sirius.components.core.api.SuccessPayload; import org.eclipse.sirius.components.portals.Portal; +import org.eclipse.sirius.components.portals.tests.graphql.AddPortalViewMutationRunner; +import org.eclipse.sirius.components.portals.tests.graphql.LayoutPortalMutationRunner; import org.eclipse.sirius.components.portals.tests.graphql.PortalEventSubscriptionRunner; import org.eclipse.sirius.web.AbstractIntegrationTests; import org.eclipse.sirius.web.application.portal.services.PortalDescriptionProvider; import org.eclipse.sirius.web.data.TestIdentifiers; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationData; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; -import org.eclipse.sirius.web.services.portals.GivenCreatedPortalSubscription; -import org.eclipse.sirius.web.services.portals.LayoutPortalMutationRunner; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationContent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationContentRepository; import org.eclipse.sirius.web.tests.services.api.IGivenCommittedTransaction; +import org.eclipse.sirius.web.tests.services.portals.GivenCreatedPortalSubscription; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -63,6 +68,7 @@ */ @Transactional @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SuppressWarnings("checkstyle:MultipleStringLiterals") public class PortalControllerIntegrationTests extends AbstractIntegrationTests { private static final String SAMPLE_PORTAL = "Sample Portal"; @@ -80,11 +86,14 @@ public class PortalControllerIntegrationTests extends AbstractIntegrationTests { private IGivenCommittedTransaction givenCommittedTransaction; @Autowired - private IRepresentationDataRepository representationDataRepository; + private IRepresentationContentRepository representationContentRepository; @Autowired private LayoutPortalMutationRunner layoutPortalMutationRunner; + @Autowired + private AddPortalViewMutationRunner addPortalViewMutationRunner; + @BeforeEach public void beforeEach() { this.editingContextEventProcessorRegistry.getEditingContextEventProcessors().stream().map(IEditingContextEventProcessor::getEditingContextId) @@ -111,6 +120,57 @@ public void givenPortalWhenWeSubscribeToPortalEventsThenCurrentStateOfThePortalI .verify(Duration.ofSeconds(10)); } + @Test + @DisplayName("Given a portal, when we add a representation to the portal, then the new state is sent with the new representation") + @Sql(scripts = { "/scripts/initialize.sql" }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) + @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + public void addRepresentationToNewCreatedPortal() { + var createRepresentationInput = new CreateRepresentationInput(UUID.randomUUID(), TestIdentifiers.ECORE_SAMPLE_PROJECT.toString(), PortalDescriptionProvider.DESCRIPTION_ID, + TestIdentifiers.EPACKAGE_OBJECT.toString(), SAMPLE_PORTAL); + var flux = this.givenCreatedPortalSubscription.createAndSubscribe(createRepresentationInput); + + var portalId = new AtomicReference(); + + Consumer initialPortalContentConsumer = payload -> Optional.of(payload) + .map(PortalRefreshedEventPayload::portal) + .ifPresentOrElse(portal -> { + assertThat(portal.getLabel()).isEqualTo(SAMPLE_PORTAL); + assertThat(portal.getViews()).isEmpty(); + assertThat(portal.getLayoutData()).isEmpty(); + portalId.set(portal.getId()); + }, () -> fail("Missing portal")); + + Runnable addEmptyPortal = () -> { + var addPortalViewInput = new AddPortalViewInput(UUID.randomUUID(), TestIdentifiers.ECORE_SAMPLE_PROJECT.toString(), portalId.get(), + TestIdentifiers.EPACKAGE_EMPTY_PORTAL_REPRESENTATION.toString(), 0, 0, 200, 300); + var result = this.addPortalViewMutationRunner.run(addPortalViewInput); + + String typename = JsonPath.read(result, "$.data.addPortalView.__typename"); + assertThat(typename).isEqualTo(SuccessPayload.class.getSimpleName()); + }; + + Consumer updatedPortalContentConsumer = payload -> Optional.of(payload) + .map(PortalRefreshedEventPayload::portal) + .ifPresent(portal -> { + assertThat(portal.getViews()).isNotEmpty(); + var portalView = portal.getViews().get(0); + assertThat(portalView.getRepresentationId()).isEqualTo(TestIdentifiers.EPACKAGE_EMPTY_PORTAL_REPRESENTATION.toString()); + assertThat(portal.getLayoutData()).isNotEmpty(); + var portalViewLayoutData = portal.getLayoutData().get(0); + assertThat(portalViewLayoutData.getX()).isEqualTo(0); + assertThat(portalViewLayoutData.getY()).isEqualTo(0); + assertThat(portalViewLayoutData.getWidth()).isEqualTo(200); + assertThat(portalViewLayoutData.getHeight()).isEqualTo(300); + }); + + StepVerifier.create(flux) + .consumeNextWith(initialPortalContentConsumer) + .then(addEmptyPortal) + .consumeNextWith(updatedPortalContentConsumer) + .thenCancel() + .verify(Duration.ofSeconds(10)); + } + @Test @DisplayName("Given an arbitrary semantic element, when creating portal on it, then an empty portal is created") @Sql(scripts = { "/scripts/initialize.sql" }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) @@ -147,8 +207,7 @@ public void givenAPortalWhenReloadingPreviousSateAfterLayoutChangeThenPortalLayo TestTransaction.start(); var subPortalViewId = "9e277e97-7f71-4bdd-99af-9eeb8bd7f2df"; - AtomicReference initialPortalState = new AtomicReference<>(null); - AtomicReference layoutedPortalState = new AtomicReference<>(null); + AtomicReference initialPortalState = new AtomicReference<>(null); Consumer initialPortalContentConsumer = this.portalRefreshedConsumer(portal -> { assertThat(portal.getLayoutData()).hasSize(1); @@ -158,9 +217,9 @@ public void givenAPortalWhenReloadingPreviousSateAfterLayoutChangeThenPortalLayo assertThat(layoutData.getY()).isZero(); assertThat(layoutData.getWidth()).isEqualTo(500); assertThat(layoutData.getHeight()).isEqualTo(200); - var optionalRepresentationData = this.representationDataRepository.findById(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION); - assertThat(optionalRepresentationData).isPresent(); - initialPortalState.set(optionalRepresentationData.get()); + var optionalRepresentationMetadata = this.representationContentRepository.findContentByRepresentationMetadataId(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION); + assertThat(optionalRepresentationMetadata).isPresent(); + initialPortalState.set(optionalRepresentationMetadata.get()); }); Runnable layoutSubPortal = () -> { @@ -177,13 +236,12 @@ public void givenAPortalWhenReloadingPreviousSateAfterLayoutChangeThenPortalLayo assertThat(layoutData.getY()).isEqualTo(50); assertThat(layoutData.getWidth()).isEqualTo(300); assertThat(layoutData.getHeight()).isEqualTo(300); - var optionalRepresentationData = this.representationDataRepository.findById(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION); - assertThat(optionalRepresentationData).isPresent(); - layoutedPortalState.set(optionalRepresentationData.get()); + var optionalRepresentationMetadata = this.representationContentRepository.findContentByRepresentationMetadataId(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION); + assertThat(optionalRepresentationMetadata).isPresent(); }); Runnable reloadInitialPortalState = () -> { - this.representationDataRepository.save(initialPortalState.get()); + this.representationContentRepository.save(initialPortalState.get()); TestTransaction.flagForCommit(); TestTransaction.end(); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/projects/ProjectDownloadControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/projects/ProjectDownloadControllerIntegrationTests.java index d8dd8bf8a5c..aede9b4b7cf 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/projects/ProjectDownloadControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/projects/ProjectDownloadControllerIntegrationTests.java @@ -166,7 +166,7 @@ public void givenProjectWhenTheDownloadOfProjectIsRequestedThenTheRepresentation String representationContent = new String(zipEntries.get(representationPath).toByteArray(), StandardCharsets.UTF_8); var objectMapper = new ObjectMapper(); - assertThat(objectMapper.readTree(representationContentExpected)).isEqualTo(objectMapper.readTree(representationContent)); + assertThat(objectMapper.readTree(representationContent)).isEqualTo(objectMapper.readTree(representationContentExpected)); } catch (IOException exception) { fail(exception.getMessage()); } diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/representations/RepresentationLifecycleControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/representations/RepresentationLifecycleControllerIntegrationTests.java index 71766814ebe..09b298788d5 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/representations/RepresentationLifecycleControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/representations/RepresentationLifecycleControllerIntegrationTests.java @@ -31,10 +31,12 @@ import org.eclipse.sirius.components.portals.tests.graphql.PortalEventSubscriptionRunner; import org.eclipse.sirius.web.AbstractIntegrationTests; import org.eclipse.sirius.web.data.TestIdentifiers; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationDataContentUpdatedEvent; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationDataCreatedEvent; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationDataDeletedEvent; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationContentCreatedEvent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationContentUpdatedEvent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationMetadataCreatedEvent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationMetadataDeletedEvent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.eclipse.sirius.web.services.TestRepresentationDescription; import org.eclipse.sirius.web.services.api.IDomainEventCollector; import org.eclipse.sirius.web.tests.services.api.IGivenCommittedTransaction; @@ -44,6 +46,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.test.context.transaction.TestTransaction; @@ -77,7 +80,10 @@ public class RepresentationLifecycleControllerIntegrationTests extends AbstractI private DeleteRepresentationMutationRunner deleteRepresentationMutationRunner; @Autowired - private IRepresentationDataSearchService representationDataSearchService; + private IRepresentationMetadataSearchService representationMetadataSearchService; + + @Autowired + private IRepresentationContentSearchService representationContentSearchService; @Autowired private PortalEventSubscriptionRunner portalEventSubscriptionRunner; @@ -116,11 +122,12 @@ public void givenRepresentationToCreateWhenMutationIsPerformedThenTheRepresentat String representationId = JsonPath.read(result, "$.data.createRepresentation.representation.id"); assertThat(representationId).isNotNull(); - assertThat(this.domainEventCollector.getDomainEvents()).hasSize(1); - var event = this.domainEventCollector.getDomainEvents().get(0); - assertThat(event).isInstanceOf(RepresentationDataCreatedEvent.class); - - assertThat(this.representationDataSearchService.existsById(UUID.fromString(representationId))).isTrue(); + assertThat(this.domainEventCollector.getDomainEvents()) + .hasSize(2) + .satisfiesExactlyInAnyOrder(event -> assertThat(event).isInstanceOf(RepresentationMetadataCreatedEvent.class), event -> assertThat(event).isInstanceOf(RepresentationContentCreatedEvent.class)); + var representationUUID = UUID.fromString(representationId); + assertThat(this.representationMetadataSearchService.existsById(representationUUID)).isTrue(); + assertThat(this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(representationUUID))).isPresent(); } @Test @@ -143,7 +150,7 @@ public void givenRepresentationToRenameWhenMutationIsPerformedThenTheRepresentat assertThat(typename).isEqualTo(RenameRepresentationSuccessPayload.class.getSimpleName()); assertThat(this.domainEventCollector.getDomainEvents()).hasSize(1); - assertThat(this.domainEventCollector.getDomainEvents()).anyMatch(RepresentationDataContentUpdatedEvent.class::isInstance); + assertThat(this.domainEventCollector.getDomainEvents()).anyMatch(RepresentationContentUpdatedEvent.class::isInstance); }; StepVerifier.create(flux) @@ -159,7 +166,7 @@ public void givenRepresentationToRenameWhenMutationIsPerformedThenTheRepresentat public void givenRepresentationToDeleteWhenMutationIsPerformedThenTheRepresentationHasBeenDeleted() { this.givenCommittedTransaction.commit(); - assertThat(this.representationDataSearchService.existsById(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION)).isTrue(); + assertThat(this.representationMetadataSearchService.existsById(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION)).isTrue(); var input = new DeleteRepresentationInput(UUID.randomUUID(), TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION.toString()); var result = this.deleteRepresentationMutationRunner.run(input); @@ -170,10 +177,10 @@ public void givenRepresentationToDeleteWhenMutationIsPerformedThenTheRepresentat String typename = JsonPath.read(result, "$.data.deleteRepresentation.__typename"); assertThat(typename).isEqualTo(DeleteRepresentationSuccessPayload.class.getSimpleName()); - assertThat(this.representationDataSearchService.existsById(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION)).isFalse(); + assertThat(this.representationMetadataSearchService.existsById(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION)).isFalse(); assertThat(this.domainEventCollector.getDomainEvents()).hasSize(1); var event = this.domainEventCollector.getDomainEvents().get(0); - assertThat(event).isInstanceOf(RepresentationDataDeletedEvent.class); + assertThat(event).isInstanceOf(RepresentationMetadataDeletedEvent.class); } } diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/domain/DomainEventsTest.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/domain/DomainEventsTest.java index e9730529e3f..30450ab53b3 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/domain/DomainEventsTest.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/domain/DomainEventsTest.java @@ -24,9 +24,9 @@ import org.eclipse.sirius.web.domain.boundedcontexts.project.events.ProjectNameUpdatedEvent; import org.eclipse.sirius.web.domain.boundedcontexts.project.services.api.IProjectSearchService; import org.eclipse.sirius.web.domain.boundedcontexts.project.services.api.IProjectUpdateService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationDataContentUpdatedEvent; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataUpdateService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.events.RepresentationContentUpdatedEvent; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentUpdateService; import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.Document; import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.SemanticDataDomain; import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.events.SemanticDataUpdatedEvent; @@ -69,10 +69,10 @@ public class DomainEventsTest extends AbstractIntegrationTests { private ISemanticDataUpdateService semanticDataUpdateService; @Autowired - private IRepresentationDataSearchService representationDataSearchService; + private IRepresentationContentSearchService representationContentSearchService; @Autowired - private IRepresentationDataUpdateService representationDataUpdateService; + private IRepresentationContentUpdateService representationContentUpdateService; @BeforeEach public void beforeEach() { @@ -202,21 +202,21 @@ public void givenDocumentWhenContentModifiedDomainEventPublished() { @Sql(scripts = {"/scripts/cleanup.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void givenRepresentationWhenContentModifiedDomainEventPublished() { assertThat(this.domainEventCollector.getDomainEvents()).isEmpty(); - var optionalRepresentationData = this.representationDataSearchService.findContentById(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION); - assertThat(optionalRepresentationData).isPresent(); + var optionalRepresentationContent = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION)); + assertThat(optionalRepresentationContent).isPresent(); - var representationData = optionalRepresentationData.get(); + var representationContent = optionalRepresentationContent.get(); - var originalContent = representationData.content(); + var originalContent = representationContent.getContent(); var newContent = originalContent + "modified"; - this.representationDataUpdateService.updateContent(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION, newContent); + this.representationContentUpdateService.updateContentByRepresentationId(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION, newContent); TestTransaction.flagForCommit(); TestTransaction.end(); assertThat(this.domainEventCollector.getDomainEvents()).hasSize(1); var event = this.domainEventCollector.getDomainEvents().get(0); - assertThat(event instanceof RepresentationDataContentUpdatedEvent represnetationDataContentUpdateEvent && represnetationDataContentUpdateEvent.representationData().getContent().equals(newContent)).isTrue(); + assertThat(event instanceof RepresentationContentUpdatedEvent representationDataContentUpdateEvent && representationDataContentUpdateEvent.representationContent().getContent().equals(newContent)).isTrue(); } @Test @@ -225,13 +225,13 @@ public void givenRepresentationWhenContentModifiedDomainEventPublished() { @Sql(scripts = {"/scripts/cleanup.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void givenRepresentationWhenContentNotModifiedNoDomainEventPublished() { assertThat(this.domainEventCollector.getDomainEvents()).isEmpty(); - var optionalRepresentationData = this.representationDataSearchService.findContentById(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION); - assertThat(optionalRepresentationData).isPresent(); + var optionalRepresentationContent = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION)); + assertThat(optionalRepresentationContent).isPresent(); - var representationData = optionalRepresentationData.get(); + var representationContent = optionalRepresentationContent.get(); - var newContent = representationData.content(); - this.representationDataUpdateService.updateContent(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION, newContent); + var newContent = representationContent.getContent(); + this.representationContentUpdateService.updateContentByRepresentationId(TestIdentifiers.EPACKAGE_PORTAL_REPRESENTATION, newContent); TestTransaction.flagForCommit(); TestTransaction.end(); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/migration/MigrationParticipantOrderTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/migration/MigrationParticipantOrderTests.java index 1ef783b2753..14bb7c0f171 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/migration/MigrationParticipantOrderTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/migration/MigrationParticipantOrderTests.java @@ -25,12 +25,14 @@ import org.eclipse.sirius.web.AbstractIntegrationTests; import org.eclipse.sirius.web.application.editingcontext.EditingContext; import org.eclipse.sirius.web.data.MigrationIdentifiers; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; +import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.transaction.annotation.Transactional; @@ -49,7 +51,10 @@ public class MigrationParticipantOrderTests extends AbstractIntegrationTests { private IEditingContextSearchService editingContextSearchService; @Autowired - private IRepresentationDataSearchService representationDataSearchService; + private IRepresentationMetadataSearchService representationMetadataSearchService; + + @Autowired + private IRepresentationContentSearchService representationContentSearchService; @Autowired private IRepresentationSearchService representationSearchService; @@ -73,14 +78,14 @@ public void testRepresentationMigrationParticipantExecutionOrder() { this.representationPersistenceService.save(optionalEditingContext.get(), optionalRepresentation.get()); - var optionalUpdatedRepresentationData = this.representationDataSearchService.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM_HIERARCHY); - assertThat(optionalUpdatedRepresentationData).isPresent(); + var optionalUpdatedRepresentationContent = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM_HIERARCHY)); + assertThat(optionalUpdatedRepresentationContent).isPresent(); - var updatedRepresentationData = optionalUpdatedRepresentationData.get(); + var updatedRepresentationContent = optionalUpdatedRepresentationContent.get(); - assertThat(updatedRepresentationData.migrationVersion()).isEqualTo("9999.12.99-300012310900"); + assertThat(updatedRepresentationContent.getMigrationVersion()).isEqualTo("9999.12.99-300012310900"); // The name is empty because we registered an anonymous representation migration participant. - assertThat(updatedRepresentationData.lastMigrationPerformed()).isEqualTo(""); + assertThat(updatedRepresentationContent.getLastMigrationPerformed()).isEqualTo(""); } @Test @@ -98,13 +103,13 @@ public void testRepresentationMigrationParticipantOnCreatedRepresentation() { this.representationPersistenceService.save(optionalEditingContext.get(), newHierarchy); - var optionalUpdatedRepresentationData = this.representationDataSearchService.findContentById(UUID.fromString(newHierarchy.getId())); - assertThat(optionalUpdatedRepresentationData).isPresent(); - var updatedRepresentationData = optionalUpdatedRepresentationData.get(); + var optionalUpdatedRepresentationContent = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(UUID.fromString(newHierarchy.getId()))); + assertThat(optionalUpdatedRepresentationContent).isPresent(); + var updatedRepresentationContent = optionalUpdatedRepresentationContent.get(); - assertThat(updatedRepresentationData.migrationVersion()).isEqualTo("9999.12.99-300012310900"); + assertThat(updatedRepresentationContent.getMigrationVersion()).isEqualTo("9999.12.99-300012310900"); // The name is not empty because the initial representation migration participant is initialized with "none" - assertThat(updatedRepresentationData.lastMigrationPerformed()).isEqualTo("none"); + assertThat(updatedRepresentationContent.getLastMigrationPerformed()).isEqualTo("none"); } @Test diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/migration/RepresentationMigrationParticipantTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/migration/RepresentationMigrationParticipantTests.java index b3515ac7643..b4a1e4ff3a1 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/migration/RepresentationMigrationParticipantTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/migration/RepresentationMigrationParticipantTests.java @@ -27,14 +27,16 @@ import org.eclipse.sirius.components.diagrams.Diagram; import org.eclipse.sirius.web.AbstractIntegrationTests; import org.eclipse.sirius.web.data.MigrationIdentifiers; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationDataRepository; -import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationDataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.repositories.IRepresentationMetadataRepository; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationContentSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.transaction.annotation.Transactional; @@ -50,13 +52,16 @@ public class RepresentationMigrationParticipantTests extends AbstractIntegrationTests { @Autowired - private IRepresentationDataRepository representationDataRepository; + private IRepresentationMetadataRepository representationMetadataRepository; @Autowired private IEditingContextSearchService editingContextSearchService; @Autowired - private IRepresentationDataSearchService representationDataSearchService; + private IRepresentationMetadataSearchService representationMetadataSearchService; + + @Autowired + private IRepresentationContentSearchService representationContentSearchService; @Autowired private IRepresentationSearchService representationSearchService; @@ -69,12 +74,12 @@ public class RepresentationMigrationParticipantTests extends AbstractIntegration @Sql(scripts = {"/scripts/migration.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) @Sql(scripts = {"/scripts/cleanup.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void givenProjectWithAnOldHierarchyRepresentationWhenTheRepresentationIsLoadedThenItsChildNodesAreMigratedCorrectly() { - var representationBeforeMigration = representationDataRepository.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM_HIERARCHY); - assertThat(representationBeforeMigration).isPresent(); + var representationContentBeforeMigration = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM_HIERARCHY)); + assertThat(representationContentBeforeMigration).isPresent(); // Returns output path to access to attribute value instead of returning the value var parseContext = JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.AS_PATH_LIST)); - List outputPaths = parseContext.parse(representationBeforeMigration.get().content()).read("$..children"); + List outputPaths = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$..children"); assertThat(outputPaths).size().isGreaterThan(0); var optionalEditingContext = this.editingContextSearchService.findById(MigrationIdentifiers.MIGRATION_NODE_DESCRIPTION_LABEL_EXPRESSION_STUDIO.toString()); @@ -88,15 +93,15 @@ public void givenProjectWithAnOldHierarchyRepresentationWhenTheRepresentationIsL this.representationPersistenceService.save(optionalEditingContext.get(), optionalRepresentation.get()); - var optionalUpdatedRepresentationData = this.representationDataSearchService.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM_HIERARCHY); - assertThat(optionalUpdatedRepresentationData).isPresent(); + var optionalUpdatedRepresentationContent = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM_HIERARCHY)); + assertThat(optionalUpdatedRepresentationContent).isPresent(); - var updatedRepresentationData = optionalUpdatedRepresentationData.get(); - List updatedChildren = JsonPath.read(updatedRepresentationData.content(), "$..children"); + var updatedRepresentationContent = optionalUpdatedRepresentationContent.get(); + List updatedChildren = JsonPath.read(updatedRepresentationContent.getContent(), "$..children"); assertThat(updatedChildren).size().isEqualTo(0); var expectedUpdatedOutputPath = outputPaths.stream().map(outputPath -> outputPath.replace("children", "childNodes")).toList(); - List actualUpdatedOutputPath = parseContext.parse(updatedRepresentationData.content()).read("$..childNodes"); + List actualUpdatedOutputPath = parseContext.parse(updatedRepresentationContent.getContent()).read("$..childNodes"); assertThat(actualUpdatedOutputPath).isEqualTo(expectedUpdatedOutputPath); } @@ -105,22 +110,22 @@ public void givenProjectWithAnOldHierarchyRepresentationWhenTheRepresentationIsL @Sql(scripts = {"/scripts/migration.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) @Sql(scripts = {"/scripts/cleanup.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void testRemovePositionFromDiagramPresentOnDiagramAndNodesAndEdges() { - var representationContentBeforeMigration = this.representationDataRepository.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM); + var representationContentBeforeMigration = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM)); assertThat(representationContentBeforeMigration).isPresent(); // Returns output path to access to attribute value instead of returning the value and prevent exception to be thrown when the path does not match. var parseContext = JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.AS_PATH_LIST, Option.SUPPRESS_EXCEPTIONS)); - List rootPositionBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.position"); + List rootPositionBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.position"); assertThat(rootPositionBeforeMigration).size().isEqualTo(1); - List nodesPositionBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.nodes..position"); + List nodesPositionBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.nodes..position"); assertThat(nodesPositionBeforeMigration).size().isGreaterThan(0); - List edgesPositionBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.edges..position"); + List edgesPositionBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.edges..position"); assertThat(edgesPositionBeforeMigration).size().isGreaterThan(0); - List layoutDataPositionBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.layoutData..position"); + List layoutDataPositionBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.layoutData..position"); assertThat(layoutDataPositionBeforeMigration).size().isGreaterThan(0); var optionalEditingContext = this.editingContextSearchService.findById(MigrationIdentifiers.MIGRATION_NODE_DESCRIPTION_USER_RESIZABLE_STUDIO.toString()); @@ -131,21 +136,21 @@ public void testRemovePositionFromDiagramPresentOnDiagramAndNodesAndEdges() { this.representationPersistenceService.save(optionalEditingContext.get(), optionalRepresentation.get()); - var optionalUpdatedRepresentationData = this.representationDataSearchService.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM); - assertThat(optionalUpdatedRepresentationData).isPresent(); + var optionalUpdatedRepresentationContent = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM)); + assertThat(optionalUpdatedRepresentationContent).isPresent(); - var updatedRepresentationData = optionalUpdatedRepresentationData.get(); + var updatedRepresentationContent = optionalUpdatedRepresentationContent.get(); - List updatedRootPosition = parseContext.parse(updatedRepresentationData.content()).read("$.position"); + List updatedRootPosition = parseContext.parse(updatedRepresentationContent.getContent()).read("$.position"); assertThat(updatedRootPosition).size().isEqualTo(0); - List updatedNodesPosition = parseContext.parse(updatedRepresentationData.content()).read("$.nodes..position"); + List updatedNodesPosition = parseContext.parse(updatedRepresentationContent.getContent()).read("$.nodes..position"); assertThat(updatedNodesPosition).size().isEqualTo(0); - List updatedEdgesPosition = parseContext.parse(updatedRepresentationData.content()).read("$.edges..position"); + List updatedEdgesPosition = parseContext.parse(updatedRepresentationContent.getContent()).read("$.edges..position"); assertThat(updatedEdgesPosition).size().isEqualTo(0); - List updatedLayoutDataPosition = parseContext.parse(updatedRepresentationData.content()).read("$.layoutData..position"); + List updatedLayoutDataPosition = parseContext.parse(updatedRepresentationContent.getContent()).read("$.layoutData..position"); assertThat(updatedLayoutDataPosition).size().isGreaterThan(0); assertThat(updatedLayoutDataPosition).isEqualTo(layoutDataPositionBeforeMigration); } @@ -155,22 +160,22 @@ public void testRemovePositionFromDiagramPresentOnDiagramAndNodesAndEdges() { @Sql(scripts = {"/scripts/migration.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) @Sql(scripts = {"/scripts/cleanup.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void testRemoveSizeFromDiagramPresentOnDiagramAndNodesAndEdges() { - var representationContentBeforeMigration = this.representationDataRepository.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM); + var representationContentBeforeMigration = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM)); assertThat(representationContentBeforeMigration).isPresent(); // Returns output path to access to attribute value instead of returning the value and prevent exception to be thrown when the path does not match. var parseContext = JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.AS_PATH_LIST, Option.SUPPRESS_EXCEPTIONS)); - List rootSizeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.size"); + List rootSizeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.size"); assertThat(rootSizeBeforeMigration).size().isEqualTo(1); - List nodesSizeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.nodes..size"); + List nodesSizeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.nodes..size"); assertThat(nodesSizeBeforeMigration).size().isGreaterThan(0); - List edgesSizeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.edges..size"); + List edgesSizeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.edges..size"); assertThat(edgesSizeBeforeMigration).size().isGreaterThan(0); - List layoutDataSizeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.layoutData..size"); + List layoutDataSizeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.layoutData..size"); assertThat(layoutDataSizeBeforeMigration).size().isGreaterThan(0); var optionalEditingContext = this.editingContextSearchService.findById(MigrationIdentifiers.MIGRATION_NODE_DESCRIPTION_USER_RESIZABLE_STUDIO.toString()); @@ -181,21 +186,21 @@ public void testRemoveSizeFromDiagramPresentOnDiagramAndNodesAndEdges() { this.representationPersistenceService.save(optionalEditingContext.get(), optionalRepresentation.get()); - var optionalUpdatedRepresentationData = this.representationDataSearchService.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM); - assertThat(optionalUpdatedRepresentationData).isPresent(); + var optionalUpdatedRepresentationContent = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM)); + assertThat(optionalUpdatedRepresentationContent).isPresent(); - var updatedRepresentationData = optionalUpdatedRepresentationData.get(); + var updatedRepresentationContent = optionalUpdatedRepresentationContent.get(); - List updatedRootSize = parseContext.parse(updatedRepresentationData.content()).read("$.size"); + List updatedRootSize = parseContext.parse(updatedRepresentationContent.getContent()).read("$.size"); assertThat(updatedRootSize).size().isEqualTo(0); - List updatedNodesSize = parseContext.parse(updatedRepresentationData.content()).read("$.nodes..size"); + List updatedNodesSize = parseContext.parse(updatedRepresentationContent.getContent()).read("$.nodes..size"); assertThat(updatedNodesSize).size().isEqualTo(0); - List updatedEdgesSize = parseContext.parse(updatedRepresentationData.content()).read("$.edges..size"); + List updatedEdgesSize = parseContext.parse(updatedRepresentationContent.getContent()).read("$.edges..size"); assertThat(updatedEdgesSize).size().isGreaterThan(0); - List updatedLayoutDataSize = parseContext.parse(updatedRepresentationData.content()).read("$.layoutData..size"); + List updatedLayoutDataSize = parseContext.parse(updatedRepresentationContent.getContent()).read("$.layoutData..size"); assertThat(updatedLayoutDataSize).size().isGreaterThan(0); assertThat(updatedLayoutDataSize).isEqualTo(layoutDataSizeBeforeMigration); } @@ -206,13 +211,13 @@ public void testRemoveSizeFromDiagramPresentOnDiagramAndNodesAndEdges() { @Sql(scripts = {"/scripts/migration.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) @Sql(scripts = {"/scripts/cleanup.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void testRemoveAttributeFromDiagramContent(String attribute) { - var representationContentBeforeMigration = this.representationDataRepository.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM); + var representationContentBeforeMigration = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM)); assertThat(representationContentBeforeMigration).isPresent(); // Returns output path to access to attribute value instead of returning the value and prevent exception to be thrown when the path does not match. var parseContext = JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.AS_PATH_LIST, Option.SUPPRESS_EXCEPTIONS)); - List attributeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().content()).read("$.." + attribute); + List attributeBeforeMigration = parseContext.parse(representationContentBeforeMigration.get().getContent()).read("$.." + attribute); assertThat(attributeBeforeMigration).size().isGreaterThan(0); var optionalEditingContext = this.editingContextSearchService.findById(MigrationIdentifiers.MIGRATION_NODE_DESCRIPTION_USER_RESIZABLE_STUDIO.toString()); @@ -223,12 +228,12 @@ public void testRemoveAttributeFromDiagramContent(String attribute) { this.representationPersistenceService.save(optionalEditingContext.get(), optionalRepresentation.get()); - var optionalUpdatedRepresentationData = this.representationDataSearchService.findContentById(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM); - assertThat(optionalUpdatedRepresentationData).isPresent(); + var optionalUpdatedRepresentationContent = this.representationContentSearchService.findContentByRepresentationMetadata(AggregateReference.to(MigrationIdentifiers.MIGRATION_STUDIO_DIAGRAM)); + assertThat(optionalUpdatedRepresentationContent).isPresent(); - var updatedRepresentationData = optionalUpdatedRepresentationData.get(); + var updatedRepresentationContent = optionalUpdatedRepresentationContent.get(); - List updatedNodesAttribute = parseContext.parse(updatedRepresentationData.content()).read("$.." + attribute); + List updatedNodesAttribute = parseContext.parse(updatedRepresentationContent.getContent()).read("$.." + attribute); assertThat(updatedNodesAttribute).size().isEqualTo(0); } } diff --git a/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/cleanup.sql b/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/cleanup.sql index 2d904c7da12..0dd5fd500c2 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/cleanup.sql +++ b/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/cleanup.sql @@ -1,7 +1,8 @@ DELETE FROM document; DELETE FROM semantic_data_domain; DELETE FROM semantic_data; -DELETE FROM representation_data; +DELETE FROM representation_content; +DELETE FROM representation_metadata; DELETE FROM image; DELETE FROM nature; -DELETE FROM project; \ No newline at end of file +DELETE FROM project; diff --git a/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/initialize.sql b/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/initialize.sql index c4857899abf..cc251b525ef 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/initialize.sql +++ b/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/initialize.sql @@ -130,18 +130,15 @@ INSERT INTO document ( '2024-01-01 9:42:0.000', '2024-01-02 9:42:0.000' ); -INSERT INTO representation_data ( +INSERT INTO representation_metadata ( id, project_id, target_object_id, description_id, label, kind, - content, created_on, - last_modified_on, - last_migration_performed, - migration_version + last_modified_on ) VALUES ( 'e81eec5c-42d6-491c-8bcc-9beb951356f8', '99d336a2-3049-439a-8853-b104ffb22653', @@ -149,24 +146,35 @@ INSERT INTO representation_data ( '69030a1b-0b5f-3c1d-8399-8ca260e4a672', 'Portal', 'siriusComponents://representation?type=Portal', + '2024-01-01 9:42:0.000', + '2024-01-02 9:42:0.000' +); +INSERT INTO representation_content ( + id, + representation_metadata_id, + content, + created_on, + last_modified_on, + last_migration_performed, + migration_version +) VALUES ( + 'd20f29ce-85a9-4013-9337-aeb9814b2856', + 'e81eec5c-42d6-491c-8bcc-9beb951356f8', '{"id":"e81eec5c-42d6-491c-8bcc-9beb951356f8","kind":"siriusComponents://representation?type=Portal","descriptionId":"69030a1b-0b5f-3c1d-8399-8ca260e4a672","label":"Portal","targetObjectId":"3237b215-ae23-48d7-861e-f542a4b9a4b8","views":[{"id":"9e277e97-7f71-4bdd-99af-9eeb8bd7f2df","representationId":"05e44ccc-9363-443f-a816-25fc73e3e7f7"}],"layoutData":[{"portalViewId":"9e277e97-7f71-4bdd-99af-9eeb8bd7f2df","x":0,"y":0,"width":500,"height":200}]}', '2024-01-01 9:42:0.000', '2024-01-02 9:42:0.000', 'none', '0' ); -INSERT INTO representation_data ( +INSERT INTO representation_metadata ( id, project_id, target_object_id, description_id, label, kind, - content, created_on, - last_modified_on, - last_migration_performed, - migration_version + last_modified_on ) VALUES ( '05e44ccc-9363-443f-a816-25fc73e3e7f7', '99d336a2-3049-439a-8853-b104ffb22653', @@ -174,6 +182,20 @@ INSERT INTO representation_data ( '69030a1b-0b5f-3c1d-8399-8ca260e4a672', 'Portal', 'siriusComponents://representation?type=Portal', + '2024-01-01 9:42:0.000', + '2024-01-02 9:42:0.000' +); +INSERT INTO representation_content ( + id, + representation_metadata_id, + content, + created_on, + last_modified_on, + last_migration_performed, + migration_version +) VALUES ( + '6100fa08-668c-4d4a-a485-d65df22da942', + '05e44ccc-9363-443f-a816-25fc73e3e7f7', '{"id":"05e44ccc-9363-443f-a816-25fc73e3e7f7","kind":"siriusComponents://representation?type=Portal","descriptionId":"69030a1b-0b5f-3c1d-8399-8ca260e4a672","label":"Child Portal","targetObjectId":"3237b215-ae23-48d7-861e-f542a4b9a4b8","views":[],"layoutData":[]}', '2024-01-01 9:42:0.000', '2024-01-02 9:42:0.000', diff --git a/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/migration.sql b/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/migration.sql index 73d4cbd7544..667cfe1ed4d 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/migration.sql +++ b/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/migration.sql @@ -1,15 +1,3 @@ -/******************************************************************************* - * 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 - *******************************************************************************/ -- Sample migration project INSERT INTO project ( id, @@ -275,18 +263,15 @@ INSERT INTO document ( '2024-05-06 15:00:0.000' ); -INSERT INTO representation_data ( +INSERT INTO representation_metadata ( id, project_id, target_object_id, description_id, label, kind, - content, created_on, - last_modified_on, - last_migration_performed, - migration_version + last_modified_on ) VALUES ( '35f1cd7b-e5bb-443d-95ef-bab372a92b0f', 'a3b86086-23f5-41cb-97b9-5ac7234a98af', @@ -294,6 +279,20 @@ INSERT INTO representation_data ( 'siriusComponents://representationDescription?kind=TreeMap', 'Hierarchy Migration', 'siriusComponents://representation?type=TreeMap', + '2024-01-01 9:42:0.000', + '2024-01-02 9:42:0.000' +); +INSERT INTO representation_content ( + id, + representation_metadata_id, + content, + created_on, + last_modified_on, + last_migration_performed, + migration_version +) VALUES ( + '8ad82a59-2fca-4024-92a2-11331a2bfbd1', + '35f1cd7b-e5bb-443d-95ef-bab372a92b0f', '{ "id": "35f1cd7b-e5bb-443d-95ef-bab372a92b0f", "descriptionId": "siriusComponents://representation?type=TreeMap", @@ -457,18 +456,15 @@ INSERT INTO document ( '2024-01-02 9:42:0.000' ); -INSERT INTO representation_data ( +INSERT INTO representation_metadata ( id, project_id, target_object_id, description_id, label, kind, - content, created_on, - last_modified_on, - last_migration_performed, - migration_version + last_modified_on ) VALUES ( '9698833e-ffd4-435a-9aec-765622ce524e', 'a5441b64-83a5-4754-8794-57227bf8a322', @@ -476,6 +472,20 @@ INSERT INTO representation_data ( 'siriusComponents://representationDescription?kind=diagramDescription&sourceKind=view&sourceId=c5857f07-7382-3215-8c53-b690ca983655&sourceElementId=e932123d-b916-3537-84d2-86a4f5873d93', 'Diagram UserResizable Migration', 'siriusComponents://representation?type=Diagram', + '2024-07-04 9:42:0.000', + '2024-07-04 9:42:0.000' +); +INSERT INTO representation_content ( + id, + representation_metadata_id, + content, + created_on, + last_modified_on, + last_migration_performed, + migration_version +) VALUES ( + '4682cc9d-f9a5-4364-9c5d-15f3cf25b225', + '9698833e-ffd4-435a-9aec-765622ce524e', '{ "descriptionId": "siriusComponents://representationDescription?kind=diagramDescription&sourceKind=view&sourceId=c5857f07-7382-3215-8c53-b690ca983655&sourceElementId=e932123d-b916-3537-84d2-86a4f5873d93", "edges": [