Skip to content

Commit

Permalink
[3679] Split representation metadata from content
Browse files Browse the repository at this point in the history
Bug: #3679
Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
  • Loading branch information
gcoutable authored and sbegaudeau committed Oct 25, 2024
1 parent ed14f43 commit b4bfc23
Show file tree
Hide file tree
Showing 134 changed files with 2,038 additions and 1,332 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ This allows an error to be displayed when there is a problem during uploading
- https://github.com/eclipse-sirius/sirius-web/issues/3840[#3840] [diagram] Migrate to ReactFlow 12, if you have components that uses the library then you'll need to update them.
- https://github.com/eclipse-sirius/sirius-web/issues/2399[#2399] [core] When executing successive model operations inside a tool, the execution context (variables, in particular `self`) of all sibling operations now stays the same.
This is much more natural and closer to the behavior of usual languages, but change the behavior.
- 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`.
- https://github.com/eclipse-sirius/sirius-web/issues/3679[#3679] [sirius-web] The service `hasChildren` requires the editing context like the aql service `getChildren`.


=== Dependency update
Expand All @@ -57,6 +61,7 @@ This is much more natural and closer to the behavior of usual languages, but cha
- [releng] Switch to the final release version of AQL 8.0.2
- https://github.com/eclipse-sirius/sirius-web/issues/3836[#3836] [gantt] Switch to @ObeoNetwork/gantt-task-react 0.6.1 to benefit for enhancements


=== Bug fixes

- https://github.com/eclipse-sirius/sirius-web/issues/3954[#3954] [diagram] Ensure separator bar is displayed immediately after dynamically adding list child
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.sirius.components.collaborative.api.ChangeDescription;
import org.eclipse.sirius.components.collaborative.api.ChangeKind;
import org.eclipse.sirius.components.collaborative.api.IEditingContextEventHandler;
import org.eclipse.sirius.components.collaborative.api.IRepresentationMetadataPersistenceService;
import org.eclipse.sirius.components.collaborative.api.IRepresentationPersistenceService;
import org.eclipse.sirius.components.collaborative.api.Monitoring;
import org.eclipse.sirius.components.collaborative.charts.messages.ICollaborativeChartsMessageService;
Expand Down Expand Up @@ -49,6 +50,8 @@ public class CreateHierarchyEventHandler implements IEditingContextEventHandler

private final IRepresentationDescriptionSearchService representationDescriptionSearchService;

private final IRepresentationMetadataPersistenceService representationMetadataPersistenceService;

private final IRepresentationPersistenceService representationPersistenceService;

private final IObjectService objectService;
Expand All @@ -59,10 +62,12 @@ public class CreateHierarchyEventHandler implements IEditingContextEventHandler

private final Counter counter;

public CreateHierarchyEventHandler(IRepresentationDescriptionSearchService representationDescriptionSearchService, IRepresentationPersistenceService representationPersistenceService,
IObjectService objectService, ICollaborativeChartsMessageService messageService, HierarchyCreationService hierarchyCreationService, MeterRegistry meterRegistry) {
public CreateHierarchyEventHandler(IRepresentationDescriptionSearchService representationDescriptionSearchService, IRepresentationMetadataPersistenceService representationMetadataPersistenceService,
IRepresentationPersistenceService representationPersistenceService, IObjectService objectService, ICollaborativeChartsMessageService messageService,
HierarchyCreationService hierarchyCreationService, MeterRegistry meterRegistry) {
this.representationDescriptionSearchService = Objects.requireNonNull(representationDescriptionSearchService);
this.representationPersistenceService = Objects.requireNonNull(representationPersistenceService);
this.representationMetadataPersistenceService = Objects.requireNonNull(representationMetadataPersistenceService);
this.objectService = Objects.requireNonNull(objectService);
this.messageService = Objects.requireNonNull(messageService);
this.hierarchyCreationService = Objects.requireNonNull(hierarchyCreationService);
Expand Down Expand Up @@ -102,9 +107,10 @@ public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDesc
HierarchyDescription representationDescription = optionalHierarchyDescription.get();

Hierarchy hierarchy = this.hierarchyCreationService.create(createRepresentationInput, createRepresentationInput.representationName(), object, representationDescription, editingContext);
var representationMetadata = new RepresentationMetadata(hierarchy.getId(), hierarchy.getKind(), hierarchy.getLabel(), hierarchy.getDescriptionId());
this.representationMetadataPersistenceService.save(createRepresentationInput, editingContext, representationMetadata, hierarchy.getTargetObjectId());
this.representationPersistenceService.save(createRepresentationInput, editingContext, hierarchy);

var representationMetadata = new RepresentationMetadata(hierarchy.getId(), hierarchy.getKind(), hierarchy.getLabel(), hierarchy.getDescriptionId());
payload = new CreateRepresentationSuccessPayload(input.id(), representationMetadata);
changeDescription = new ChangeDescription(ChangeKind.REPRESENTATION_CREATION, editingContext.getId(), input);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ private Hierarchy doRender(ICause cause, String label, Object targetObject, IEdi

Hierarchy newHierarchy = new HierarchyRenderer().render(element);

this.representationPersistenceService.save(null, editingContext, newHierarchy);

long end = System.currentTimeMillis();
this.timer.record(end - start, TimeUnit.MILLISECONDS);
return newHierarchy;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

Expand All @@ -46,9 +45,9 @@ public ICanCreateDiagramPredicateFactory canCreateDiagramPredicateFactory() {
}

@Bean
public IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider(IObjectService objectService, IRepresentationMetadataSearchService representationMetadataSearchService,
public IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider(IObjectService objectService,
IIdentifierProvider identifierProvider, List<IExternalJavaActionProvider> externalJavaActionProviders) {
return (interpreter) -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, externalJavaActionProviders, interpreter);
return (interpreter) -> new ModelOperationHandlerSwitch(objectService, identifierProvider, externalJavaActionProviders, interpreter);
}

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -67,7 +63,7 @@ public IStatus handle(Map<String, Object> variables) {
}

List<ModelOperation> 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);
}

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -42,12 +41,12 @@ public ChildModelOperationHandler(List<IExternalJavaActionProvider> 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<String, Object> variables, List<ModelOperation> 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<IModelOperationHandler> optionalModelOperationHandler = modelOperationHandlerSwitch.apply(modelOperation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -133,6 +129,6 @@ public IStatus handle(Map<String, Object> variables) {
}

List<ModelOperation> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -77,11 +73,9 @@ public IStatus handle(Map<String, Object> variables) {
var optionalParentElement = this.interpreter.evaluateExpression(variables, containerViewExpression).asObject();
var optionalParentElementId = optionalParentElement.flatMap(parentElement -> {
Optional<String> 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;
Expand Down Expand Up @@ -119,7 +113,7 @@ public IStatus handle(Map<String, Object> variables) {

Map<String, Object> childVariables = new HashMap<>(variables);
List<ModelOperation> 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);
}

}
Loading

0 comments on commit b4bfc23

Please sign in to comment.