diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 30ae9c288d..b6da60f80b 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -24,6 +24,7 @@ === Breaking changes +- https://github.com/eclipse-sirius/sirius-web/issues/4372[#4372] [sirius-web] The editing context id is now the semantic_data_id instead of the project_id === Dependency update @@ -54,6 +55,8 @@ Specifiers can contribute dedicated AQL services for this feature using implemen - [charts] Make the npm package `sirius-components-charts` use the strict version of our TypeScript configuration - [trees] Make the npm package `sirius-components-trees` use the strict version of our TypeScript configuration - https://github.com/eclipse-sirius/sirius-web/issues/1047[#1047] [sirius-web] In the _Domain_ diagram, when using direct-edit on a relatin edge, the initial text now only includes the name of the relation (without the cardinality) +- https://github.com/eclipse-sirius/sirius-web/issues/4372[#4372] [sirius-web] Lower the coupling between project and editing context, the editing context id is now the semantic_data_id instead of the project_id + == v2025.1.0 diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/controllers/ProjectCurrentEditingContextDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/controllers/ProjectCurrentEditingContextDataFetcher.java index 73ca7a3497..2b750634f5 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/controllers/ProjectCurrentEditingContextDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/controllers/ProjectCurrentEditingContextDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ import graphql.execution.DataFetcherResult; import graphql.schema.DataFetchingEnvironment; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; /** * Data fetcher for the field Project#currentEditingContext. @@ -30,10 +31,17 @@ */ @QueryDataFetcher(type = "Project", field = "currentEditingContext") public class ProjectCurrentEditingContextDataFetcher implements IDataFetcherWithFieldCoordinates> { + + private final ISemanticDataSearchService semanticDataSearchService; + + public ProjectCurrentEditingContextDataFetcher(ISemanticDataSearchService semanticDataSearchService) { + this.semanticDataSearchService = semanticDataSearchService; + } + @Override public DataFetcherResult get(DataFetchingEnvironment environment) throws Exception { ProjectDTO project = environment.getSource(); - String editingContextId = project.id().toString(); + String editingContextId = this.semanticDataSearchService.findByProjectId(project.id()).map(semanticData -> semanticData.getId().toString()).orElse(""); Map localContext = new HashMap<>(); localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, editingContextId); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextApplicationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextApplicationService.java index dbbc3e6985..8bbe7d7d7a 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextApplicationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextApplicationService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -12,14 +12,14 @@ *******************************************************************************/ package org.eclipse.sirius.web.application.editingcontext.services; -import java.util.Objects; - import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.application.editingcontext.services.api.IEditingContextApplicationService; -import org.eclipse.sirius.web.domain.boundedcontexts.project.services.api.IProjectSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Objects; + /** * Used to interact with editing contexts. * @@ -28,17 +28,17 @@ @Service public class EditingContextApplicationService implements IEditingContextApplicationService { - private final IProjectSearchService projectSearchService; + private final ISemanticDataSearchService semanticDataSearchService; - public EditingContextApplicationService(IProjectSearchService projectSearchService) { - this.projectSearchService = Objects.requireNonNull(projectSearchService); + public EditingContextApplicationService(ISemanticDataSearchService semanticDataSearchService) { + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override @Transactional(readOnly = true) public boolean existsById(String editingContextId) { return new UUIDParser().parse(editingContextId) - .map(this.projectSearchService::existsById) + .map(this.semanticDataSearchService::existsById) .orElse(false); } } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextLoader.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextLoader.java index 00a1e19dc0..0d85da03c8 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextLoader.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextLoader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -63,7 +63,7 @@ public EditingContextLoader(ISemanticDataSearchService semanticDataSearchService public void load(EditingContext editingContext, UUID projectId) { this.editingContextProcessors.forEach(processor -> processor.preProcess(editingContext)); - this.semanticDataSearchService.findByProject(AggregateReference.to(projectId)) + this.semanticDataSearchService.findById(UUID.fromString(editingContext.getId())) .ifPresent(semanticData -> this.loadSemanticData(editingContext, semanticData)); this.representationDescriptionProviders.forEach(representationDescriptionProvider -> { diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java index 4cb0049268..799ce706bf 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -30,6 +30,7 @@ import org.eclipse.sirius.web.application.editingcontext.services.api.IEditingDomainFactory; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.eclipse.sirius.web.domain.boundedcontexts.project.services.api.IProjectSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -50,6 +51,8 @@ public class EditingContextSearchService implements IEditingContextSearchService private final Logger logger = LoggerFactory.getLogger(EditingContextSearchService.class); + private final ISemanticDataSearchService semanticDataSearchService; + private final IProjectSearchService projectSearchService; private final IEditingDomainFactory editingDomainFactory; @@ -58,7 +61,8 @@ public class EditingContextSearchService implements IEditingContextSearchService private final Timer timer; - public EditingContextSearchService(IProjectSearchService projectSearchService, IEditingDomainFactory editingDomainFactory, IEditingContextLoader editingContextLoader, MeterRegistry meterRegistry) { + public EditingContextSearchService(ISemanticDataSearchService semanticDataSearchService, IProjectSearchService projectSearchService, IEditingDomainFactory editingDomainFactory, IEditingContextLoader editingContextLoader, MeterRegistry meterRegistry) { + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); this.projectSearchService = Objects.requireNonNull(projectSearchService); this.editingDomainFactory = Objects.requireNonNull(editingDomainFactory); this.editingContextLoader = Objects.requireNonNull(editingContextLoader); @@ -69,25 +73,31 @@ public EditingContextSearchService(IProjectSearchService projectSearchService, I @Transactional(readOnly = true) public boolean existsById(String editingContextId) { return new UUIDParser().parse(editingContextId) - .map(this.projectSearchService::existsById) + .map(this.semanticDataSearchService::existsById) .orElse(false); } @Override @Transactional(readOnly = true) public Optional findById(String editingContextId) { - return new UUIDParser().parse(editingContextId) - .flatMap(this.projectSearchService::findById) - .map(this::toEditingContext); + var optionalUUID = new UUIDParser().parse(editingContextId); + if (optionalUUID.isPresent()) { + var optionalSemanticData = this.semanticDataSearchService.findById(optionalUUID.get()); + if (optionalSemanticData.isPresent() && optionalSemanticData.get().getId() != null) { + return this.projectSearchService.findById(optionalSemanticData.get().getProject().getId()) + .map(project -> this.toEditingContext(project, optionalSemanticData.get().getId().toString())); + } + } + return Optional.empty(); } - private IEditingContext toEditingContext(Project project) { + private IEditingContext toEditingContext(Project project, String semanticDataId) { long start = System.currentTimeMillis(); this.logger.debug("Loading the editing context {}", project.getId()); AdapterFactoryEditingDomain editingDomain = this.editingDomainFactory.createEditingDomain(project); - EditingContext editingContext = new EditingContext(project.getId().toString(), editingDomain, new HashMap<>(), new ArrayList<>()); + EditingContext editingContext = new EditingContext(semanticDataId, editingDomain, new HashMap<>(), new ArrayList<>()); this.editingContextLoader.load(editingContext, project.getId()); long end = System.currentTimeMillis(); 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 f07d9ba44f..4e5f855c9b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -25,6 +25,7 @@ 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.services.api.IRepresentationMetadataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -44,15 +45,20 @@ public class RepresentationApplicationService implements IRepresentationApplicat private final IRepresentationMetadataMapper representationMetadataMapper; - public RepresentationApplicationService(IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationMetadataMapper representationMetadataMapper) { + private final ISemanticDataSearchService semanticDataSearchService; + + public RepresentationApplicationService(IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationMetadataMapper representationMetadataMapper, ISemanticDataSearchService semanticDataSearchService) { this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.representationMetadataMapper = Objects.requireNonNull(representationMetadataMapper); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override @Transactional(readOnly = true) public Page findAllByEditingContextId(String editingContextId, Pageable pageable) { var representationMetadata = new UUIDParser().parse(editingContextId) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()) .map(AggregateReference::to) .map(this.representationMetadataSearchService::findAllMetadataByProject) .orElse(List.of()) diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataSearchService.java index c6fba1281f..d1c09eb5f9 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataSearchService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -43,8 +43,23 @@ public Optional findByProject(AggregateReference pr return this.semanticDataRepository.findByProjectId(project.getId()); } + @Override + public Optional findByProjectId(UUID projectId) { + return this.semanticDataRepository.findByProjectId(projectId); + } + + @Override + public Optional findById(UUID semanticDataId) { + return this.semanticDataRepository.findById(semanticDataId); + } + @Override public List findAllByDomains(List domainUris) { return this.semanticDataRepository.findAllByDomains(domainUris); } + + @Override + public boolean existsById(UUID semanticDataId) { + return this.semanticDataRepository.existsById(semanticDataId); + } } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataSearchService.java index 1b4200ce67..14c593b343 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataSearchService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -27,7 +27,13 @@ */ public interface ISemanticDataSearchService { + Optional findById(UUID semanticDataId); + Optional findByProject(AggregateReference project); + Optional findByProjectId(UUID projectId); + List findAllByDomains(List domainUris); + + boolean existsById(UUID semanticDataId); } diff --git a/packages/sirius-web/backend/sirius-web-table/src/main/java/org/eclipse/sirius/web/table/services/CreateForkedStudioService.java b/packages/sirius-web/backend/sirius-web-table/src/main/java/org/eclipse/sirius/web/table/services/CreateForkedStudioService.java index 149e271edb..ea81365d5d 100644 --- a/packages/sirius-web/backend/sirius-web-table/src/main/java/org/eclipse/sirius/web/table/services/CreateForkedStudioService.java +++ b/packages/sirius-web/backend/sirius-web-table/src/main/java/org/eclipse/sirius/web/table/services/CreateForkedStudioService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 CEA LIST. + * Copyright (c) 2024, 2025 CEA LIST. * 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 @@ -153,7 +153,7 @@ private Optional createProject(IRepresentationInput representationInput var viewToSerialize = getViewDescriptionAsString(representationDescription.get(), sourceElementId); if (viewToSerialize.isPresent() && project.isPresent() && project.get().getId() != null) { - var semanticData = this.semanticDataSearchService.findByProject(AggregateReference.to(project.get().getId())); + /*var semanticData = this.semanticDataSearchService.findByProject(AggregateReference.to(project.get().getId())); if (semanticData.isPresent() && semanticData.get().getId() != null) { String semanticProjectId = semanticData.get().getId().toString(); @@ -180,7 +180,7 @@ private Optional createProject(IRepresentationInput representationInput this.jdbcClient.updateRepresentationContentDescriptionId(representationInput, representationDescriptionId, newDescriptionId, sourceId, documentId.toString()); return project; - } + }*/ } } return Optional.empty(); diff --git a/packages/starters/backend/sirius-components-flow-starter/src/main/java/org/eclipse/sirius/components/flow/starter/services/FlowEditingContextInitializer.java b/packages/starters/backend/sirius-components-flow-starter/src/main/java/org/eclipse/sirius/components/flow/starter/services/FlowEditingContextInitializer.java index eea4ae1756..beb29d7bba 100644 --- a/packages/starters/backend/sirius-components-flow-starter/src/main/java/org/eclipse/sirius/components/flow/starter/services/FlowEditingContextInitializer.java +++ b/packages/starters/backend/sirius-components-flow-starter/src/main/java/org/eclipse/sirius/components/flow/starter/services/FlowEditingContextInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -38,6 +38,8 @@ import org.eclipse.sirius.web.application.editingcontext.EditingContext; import org.eclipse.sirius.web.domain.boundedcontexts.project.Nature; import org.eclipse.sirius.web.domain.boundedcontexts.project.services.api.IProjectSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.SemanticData; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.springframework.stereotype.Service; /** @@ -50,13 +52,19 @@ public class FlowEditingContextInitializer implements IEditingContextProcessor { private final IProjectSearchService projectSearchService; - public FlowEditingContextInitializer(IProjectSearchService projectSearchService) { + private final ISemanticDataSearchService semanticDataSearchService; + + public FlowEditingContextInitializer(IProjectSearchService projectSearchService, ISemanticDataSearchService semanticDataSearchService) { this.projectSearchService = Objects.requireNonNull(projectSearchService); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override public void preProcess(IEditingContext editingContext) { + //TODO modify all xxxContextInitializer var isFlowProject = new UUIDParser().parse(editingContext.getId()) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()) .flatMap(this.projectSearchService::findById) .filter(project -> project.getNatures().stream() .map(Nature::name)