From 703f1ed1484ea54913986648836e6a5cb0599904 Mon Sep 17 00:00:00 2001 From: Michael Charfadi Date: Thu, 9 Jan 2025 10:01:23 +0100 Subject: [PATCH] [4372] Use semantic_data_id as editing context id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-web/issues/4372 Signed-off-by: Michaƫl Charfadi --- CHANGELOG.adoc | 3 +++ ...ojectCurrentEditingContextDataFetcher.java | 12 +++++++-- .../EditingContextApplicationService.java | 16 ++++++------ .../services/EditingContextLoader.java | 5 ++-- .../services/EditingContextSearchService.java | 26 +++++++++++++------ .../RepresentationApplicationService.java | 10 +++++-- ...resentationMetadataPersistenceService.java | 14 +++++++--- .../StudioCapableEditingContextPredicate.java | 10 +++++-- .../services/SemanticDataSearchService.java | 17 +++++++++++- .../api/ISemanticDataSearchService.java | 8 +++++- .../PapayaEditingContextInitializer.java | 10 +++++-- .../services/CreateForkedStudioService.java | 7 +++-- .../sirius/web/data/MigrationIdentifiers.java | 8 +++--- .../sirius/web/data/PapayaIdentifiers.java | 4 +-- .../sirius/web/data/StudioIdentifiers.java | 6 ++--- .../sirius/web/data/TestIdentifiers.java | 8 +++--- .../FlowEditingContextInitializer.java | 10 +++++-- .../services/FlowStereotypeProvider.java | 10 +++++-- .../TaskEditingContextInitializer.java | 10 +++++-- 19 files changed, 139 insertions(+), 55 deletions(-) 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..132da9f7cc 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 @@ -29,7 +29,6 @@ import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; /** @@ -63,7 +62,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-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataPersistenceService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataPersistenceService.java index 883779cb73..5ef69ca7ea 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataPersistenceService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/RepresentationMetadataPersistenceService.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 @@ -21,6 +21,7 @@ import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationIconURL; import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataCreationService; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -35,14 +36,21 @@ public class RepresentationMetadataPersistenceService implements IRepresentation private final IRepresentationMetadataCreationService representationMetadataCreationService; - public RepresentationMetadataPersistenceService(IRepresentationMetadataCreationService representationMetadataCreationService) { + private final ISemanticDataSearchService semanticDataSearchService; + + + public RepresentationMetadataPersistenceService(IRepresentationMetadataCreationService representationMetadataCreationService, ISemanticDataSearchService semanticDataSearchService) { this.representationMetadataCreationService = Objects.requireNonNull(representationMetadataCreationService); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override @Transactional public void save(ICause cause, IEditingContext editingContext, org.eclipse.sirius.components.core.RepresentationMetadata representationMetadata, String targetObjectId) { - var optionalProjectId = new UUIDParser().parse(editingContext.getId()); + var optionalProjectId = new UUIDParser().parse(editingContext.getId()) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()); + var optionalRepresentationId = new UUIDParser().parse(representationMetadata.id()); if (optionalProjectId.isPresent() && optionalRepresentationId.isPresent()) { diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/StudioCapableEditingContextPredicate.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/StudioCapableEditingContextPredicate.java index a599a6d59c..191580ad1b 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/StudioCapableEditingContextPredicate.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/StudioCapableEditingContextPredicate.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 @@ -20,6 +20,7 @@ import org.eclipse.sirius.web.domain.boundedcontexts.project.Nature; 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.springframework.stereotype.Service; /** @@ -32,13 +33,18 @@ public class StudioCapableEditingContextPredicate implements IStudioCapableEditi private final IProjectSearchService projectSearchService; - public StudioCapableEditingContextPredicate(IProjectSearchService projectSearchService) { + private final ISemanticDataSearchService semanticDataSearchService; + + public StudioCapableEditingContextPredicate(IProjectSearchService projectSearchService, ISemanticDataSearchService semanticDataSearchService) { this.projectSearchService = Objects.requireNonNull(projectSearchService); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override public boolean test(IEditingContext editingContext) { return new UUIDParser().parse(editingContext.getId()) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()) .flatMap(this.projectSearchService::findById) .filter(this::isStudio) .isPresent(); 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-papaya/src/main/java/org/eclipse/sirius/web/papaya/services/PapayaEditingContextInitializer.java b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/services/PapayaEditingContextInitializer.java index 5f23b523b1..970a2a0b99 100644 --- a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/services/PapayaEditingContextInitializer.java +++ b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/services/PapayaEditingContextInitializer.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 @@ -21,6 +21,7 @@ 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.services.api.ISemanticDataSearchService; import org.eclipse.sirius.web.papaya.services.api.IPapayaViewProvider; import org.springframework.stereotype.Service; @@ -36,14 +37,19 @@ public class PapayaEditingContextInitializer implements IEditingContextProcessor private final IPapayaViewProvider papayaViewProvider; - public PapayaEditingContextInitializer(IProjectSearchService projectSearchService, IPapayaViewProvider papayaViewProvider) { + private final ISemanticDataSearchService semanticDataSearchService; + + public PapayaEditingContextInitializer(IProjectSearchService projectSearchService, IPapayaViewProvider papayaViewProvider, ISemanticDataSearchService semanticDataSearchService) { this.projectSearchService = Objects.requireNonNull(projectSearchService); this.papayaViewProvider = Objects.requireNonNull(papayaViewProvider); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override public void preProcess(IEditingContext editingContext) { var isPapayaProject = 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) 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..45d1f54874 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 @@ -51,7 +51,6 @@ import org.eclipse.sirius.web.table.dto.CreateProjectSuccessPayload; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -153,7 +152,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 +179,7 @@ private Optional createProject(IRepresentationInput representationInput this.jdbcClient.updateRepresentationContentDescriptionId(representationInput, representationDescriptionId, newDescriptionId, sourceId, documentId.toString()); return project; - } + }*/ } } return Optional.empty(); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/MigrationIdentifiers.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/MigrationIdentifiers.java index d4d8dc3efc..cdd348b78e 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/MigrationIdentifiers.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/MigrationIdentifiers.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 @@ -23,11 +23,11 @@ */ public final class MigrationIdentifiers { - public static final UUID MIGRATION_NODE_DESCRIPTION_LABEL_EXPRESSION_STUDIO = UUID.fromString("a3b86086-23f5-41cb-97b9-5ac7234a98af"); + public static final UUID MIGRATION_NODE_DESCRIPTION_LABEL_EXPRESSION_STUDIO = UUID.fromString("89d67892-0cc9-4ca4-b30e-28688470c0d4"); - public static final UUID MIGRATION_NODE_STYLE_DESCRIPTION_COLOR_STUDIO = UUID.fromString("14df1eb9-0915-4a62-ba83-b26ce5e2cfe1"); + public static final UUID MIGRATION_NODE_STYLE_DESCRIPTION_COLOR_STUDIO = UUID.fromString("ab42d745-3bae-45ee-9839-12aff3d431cf"); - public static final UUID MIGRATION_NODE_DESCRIPTION_USER_RESIZABLE_STUDIO = UUID.fromString("a5441b64-83a5-4754-8794-57227bf8a322"); + public static final UUID MIGRATION_NODE_DESCRIPTION_USER_RESIZABLE_STUDIO = UUID.fromString("e4a1dfda-81dd-481c-be93-63d96c6e7eb1"); public static final String MIGRATION_NODE_DESCRIPTION_LABEL_EXPRESSION_STUDIO_DIAGRAM = "NodeDescription#labelExpression migration"; diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/PapayaIdentifiers.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/PapayaIdentifiers.java index 73286b0d20..157d43d0d9 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/PapayaIdentifiers.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/PapayaIdentifiers.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 @@ -21,7 +21,7 @@ */ public final class PapayaIdentifiers { - public static final UUID PAPAYA_PROJECT = UUID.fromString("c3d7df85-e0bd-472c-aec1-c05cc88276e4"); + public static final UUID PAPAYA_PROJECT = UUID.fromString("cc89c500-c27e-4968-9c67-15cf767c6ef0"); public static final UUID PROJECT_OBJECT = UUID.fromString("aa0b7b22-ade2-4148-9ee2-c5972bd72ab7"); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.java index 51dfef0101..9afdaeb594 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.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 @@ -21,9 +21,9 @@ */ public final class StudioIdentifiers { - public static final UUID EMPTY_STUDIO_PROJECT = UUID.fromString("250cabc0-a211-438c-8015-2d2aa136eb81"); + public static final UUID EMPTY_STUDIO_PROJECT = UUID.fromString("bd3017e3-d95f-4535-8701-af6ba982619f"); - public static final UUID SAMPLE_STUDIO_PROJECT = UUID.fromString("01234836-0902-418a-900a-4c0afd20323e"); + public static final UUID SAMPLE_STUDIO_PROJECT = UUID.fromString("e344d967-a639-4f6c-9c00-a466d51063c6"); public static final UUID DOMAIN_DOCUMENT = UUID.fromString("f0e490c1-79f1-49a0-b1f2-3637f2958148"); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/TestIdentifiers.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/TestIdentifiers.java index 4a7def423a..13c755d4dc 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/TestIdentifiers.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/TestIdentifiers.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 @@ -23,10 +23,10 @@ public final class TestIdentifiers { public static final UUID INVALID_PROJECT = UUID.fromString("a2bed581-9661-41bf-9217-2870a9dce67c"); public static final UUID SAMPLE_STUDIO_PROJECT = UUID.fromString("01234836-0902-418a-900a-4c0afd20323e"); - public static final UUID UML_SAMPLE_PROJECT = UUID.fromString("7ba7bda7-13b9-422a-838b-e45a3597e952"); - public static final UUID SYSML_SAMPLE_PROJECT = UUID.fromString("4164c661-e0cb-4071-b25d-8516440bb8e8"); + public static final UUID UML_SAMPLE_PROJECT = UUID.fromString("503a1f9b-13f7-4394-94df-ddbf32840a31"); + public static final UUID SYSML_SAMPLE_PROJECT = UUID.fromString("86fa5d90-a602-4083-b3c1-65912b93b673"); public static final UUID SYSML_IMAGE = UUID.fromString("ff37f0eb-effb-4c57-b17f-76bc7ea64f5b"); - public static final UUID ECORE_SAMPLE_PROJECT = UUID.fromString("99d336a2-3049-439a-8853-b104ffb22653"); + public static final UUID ECORE_SAMPLE_PROJECT = UUID.fromString("cb133bf0-d7aa-4a83-a277-0972919dd46a"); public static final UUID ECORE_SAMPLE_DOCUMENT = UUID.fromString("48dc942a-6b76-4133-bca5-5b29ebee133d"); public static final UUID EPACKAGE_OBJECT = UUID.fromString("3237b215-ae23-48d7-861e-f542a4b9a4b8"); public static final UUID ECLASS_OBJECT = UUID.fromString("f0eecd16-d9da-4c98-a422-c73897bc48f5"); 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..162d8206b0 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,7 @@ 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.services.api.ISemanticDataSearchService; import org.springframework.stereotype.Service; /** @@ -50,13 +51,18 @@ 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) { 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) diff --git a/packages/starters/backend/sirius-components-flow-starter/src/main/java/org/eclipse/sirius/components/flow/starter/services/FlowStereotypeProvider.java b/packages/starters/backend/sirius-components-flow-starter/src/main/java/org/eclipse/sirius/components/flow/starter/services/FlowStereotypeProvider.java index 49edd62470..22837af3af 100644 --- a/packages/starters/backend/sirius-components-flow-starter/src/main/java/org/eclipse/sirius/components/flow/starter/services/FlowStereotypeProvider.java +++ b/packages/starters/backend/sirius-components-flow-starter/src/main/java/org/eclipse/sirius/components/flow/starter/services/FlowStereotypeProvider.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 @@ -21,6 +21,7 @@ import org.eclipse.sirius.web.application.document.services.api.IStereotypeProvider; 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.services.api.ISemanticDataSearchService; import org.springframework.stereotype.Service; /** @@ -37,13 +38,18 @@ public class FlowStereotypeProvider implements IStereotypeProvider { private final IProjectSearchService projectSearchService; - public FlowStereotypeProvider(IProjectSearchService projectSearchService) { + private final ISemanticDataSearchService semanticDataSearchService; + + public FlowStereotypeProvider(IProjectSearchService projectSearchService, ISemanticDataSearchService semanticDataSearchService) { this.projectSearchService = Objects.requireNonNull(projectSearchService); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override public List getStereotypes(IEditingContext editingContext) { 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) diff --git a/packages/starters/backend/sirius-components-task-starter/src/main/java/org/eclipse/sirius/components/task/starter/services/TaskEditingContextInitializer.java b/packages/starters/backend/sirius-components-task-starter/src/main/java/org/eclipse/sirius/components/task/starter/services/TaskEditingContextInitializer.java index 7fa844cf86..5bf5d4091b 100644 --- a/packages/starters/backend/sirius-components-task-starter/src/main/java/org/eclipse/sirius/components/task/starter/services/TaskEditingContextInitializer.java +++ b/packages/starters/backend/sirius-components-task-starter/src/main/java/org/eclipse/sirius/components/task/starter/services/TaskEditingContextInitializer.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 @@ -31,6 +31,7 @@ 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.services.api.ISemanticDataSearchService; import org.springframework.stereotype.Service; /** @@ -43,13 +44,18 @@ public class TaskEditingContextInitializer implements IEditingContextProcessor { private final IProjectSearchService projectSearchService; - public TaskEditingContextInitializer(IProjectSearchService projectSearchService) { + private final ISemanticDataSearchService semanticDataSearchService; + + public TaskEditingContextInitializer(IProjectSearchService projectSearchService, ISemanticDataSearchService semanticDataSearchService) { this.projectSearchService = Objects.requireNonNull(projectSearchService); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override public void preProcess(IEditingContext editingContext) { var isTaskProject = 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)