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/EditingContextPersistenceService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextPersistenceService.java index 43cc38b0d4..4ac7e504d4 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextPersistenceService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextPersistenceService.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 @@ -16,7 +16,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -28,8 +27,9 @@ import org.eclipse.sirius.web.application.editingcontext.services.api.IEditingContextMigrationParticipantPredicate; import org.eclipse.sirius.web.application.editingcontext.services.api.IEditingContextPersistenceFilter; import org.eclipse.sirius.web.application.editingcontext.services.api.IResourceToDocumentService; -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.Document; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataUpdateService; import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; @@ -56,13 +56,20 @@ public class EditingContextPersistenceService implements IEditingContextPersiste private final List migrationParticipantPredicates; + private final ISemanticDataSearchService semanticDataSearchService; + + private final IProjectSearchService projectSearchService; + + private final Timer timer; - public EditingContextPersistenceService(ISemanticDataUpdateService semanticDataUpdateService, IResourceToDocumentService resourceToDocumentService, List persistenceFilters, List migrationParticipantPredicates, MeterRegistry meterRegistry) { + public EditingContextPersistenceService(ISemanticDataUpdateService semanticDataUpdateService, IResourceToDocumentService resourceToDocumentService, List persistenceFilters, List migrationParticipantPredicates, ISemanticDataSearchService semanticDataSearchService, IProjectSearchService projectSearchService, MeterRegistry meterRegistry) { this.semanticDataUpdateService = Objects.requireNonNull(semanticDataUpdateService); this.resourceToDocumentService = Objects.requireNonNull(resourceToDocumentService); this.persistenceFilters = Objects.requireNonNull(persistenceFilters); this.migrationParticipantPredicates = Objects.requireNonNull(migrationParticipantPredicates); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); + this.projectSearchService = Objects.requireNonNull(projectSearchService); this.timer = Timer.builder(TIMER_NAME).register(meterRegistry); } @@ -74,7 +81,9 @@ public void persist(ICause cause, IEditingContext editingContext) { if (editingContext instanceof IEMFEditingContext emfEditingContext) { var applyMigrationParticipants = this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(emfEditingContext)); new UUIDParser().parse(editingContext.getId()) - .map(AggregateReference::to) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()) + .flatMap(this.projectSearchService::findById) .ifPresent(project -> { var documentData = emfEditingContext.getDomain().getResourceSet().getResources().stream() .filter(resource -> IEMFEditingContext.RESOURCE_SCHEME.equals(resource.getURI().scheme())) @@ -91,7 +100,7 @@ public void persist(ICause cause, IEditingContext editingContext) { domainUris.addAll(data.ePackageEntries().stream().map(EPackageEntry::nsURI).toList()); }); - this.semanticDataUpdateService.updateDocuments(cause, project, documents, domainUris); + this.semanticDataUpdateService.updateDocuments(cause, AggregateReference.to(project.getId()), documents, domainUris); }); } 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/project/services/DefaultEditingContextActionProvider.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/DefaultEditingContextActionProvider.java index b6e8ece171..5e8b792ca7 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/DefaultEditingContextActionProvider.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/DefaultEditingContextActionProvider.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 org.eclipse.sirius.web.application.UUIDParser; 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; /** @@ -36,13 +37,19 @@ public class DefaultEditingContextActionProvider implements IEditingContextActio private final IProjectSearchService projectSearchService; - public DefaultEditingContextActionProvider(IProjectSearchService projectSearchService) { + private final ISemanticDataSearchService semanticDataSearchService; + + + public DefaultEditingContextActionProvider(IProjectSearchService projectSearchService, ISemanticDataSearchService semanticDataSearchService) { this.projectSearchService = Objects.requireNonNull(projectSearchService); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override public List getEditingContextAction(IEditingContext editingContext) { var isWithoutNature = new UUIDParser().parse(editingContext.getId()) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()) .flatMap(this.projectSearchService::findById) .map(Project::getNatures) .orElseGet(Set::of) 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-application/src/main/java/org/eclipse/sirius/web/application/studio/services/StudioExplorerTreeFilterProvider.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/StudioExplorerTreeFilterProvider.java index bd4913d0bd..acd92b330b 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/StudioExplorerTreeFilterProvider.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/StudioExplorerTreeFilterProvider.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 org.eclipse.sirius.web.application.UUIDParser; 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; /** @@ -36,13 +37,18 @@ public class StudioExplorerTreeFilterProvider implements ITreeFilterProvider { private final IProjectSearchService projectSearchService; - public StudioExplorerTreeFilterProvider(IProjectSearchService projectSearchService) { + private final ISemanticDataSearchService semanticDataSearchService; + + public StudioExplorerTreeFilterProvider(IProjectSearchService projectSearchService, ISemanticDataSearchService semanticDataSearchService) { this.projectSearchService = Objects.requireNonNull(projectSearchService); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override public List get(String editingContextId, TreeDescription treeDescription, String representationId) { var isStudio = new UUIDParser().parse(editingContextId) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()) .flatMap(this.projectSearchService::findById) .map(project -> project.getNatures().stream() .map(Nature::name) diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerServices.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerServices.java index 709ccb9cf0..c9e8349d62 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerServices.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/explorer/services/ExplorerServices.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 @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.Objects; import java.util.Optional; import org.eclipse.emf.common.util.URI; @@ -36,6 +37,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.IRepresentationMetadataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; @@ -55,12 +57,15 @@ public class ExplorerServices implements IExplorerServices { private final IRepresentationMetadataSearchService representationMetadataSearchService; + private final ISemanticDataSearchService semanticDataSearchService; + public ExplorerServices(IObjectService objectService, IURLParser urlParser, List representationImageProviders, - IRepresentationMetadataSearchService representationMetadataSearchService) { + IRepresentationMetadataSearchService representationMetadataSearchService, ISemanticDataSearchService semanticDataSearchService) { this.objectService = objectService; this.urlParser = urlParser; this.representationImageProviders = representationImageProviders; this.representationMetadataSearchService = representationMetadataSearchService; + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override @@ -228,13 +233,16 @@ public List getDefaultChildren(Object self, IEditingContext editingConte if (self instanceof Resource resource) { result.addAll(resource.getContents()); } else if (self instanceof EObject) { - new UUIDParser().parse(editingContext.getId()).ifPresent(projectId -> { - var representationMetadata = new ArrayList<>(this.representationMetadataSearchService.findAllMetadataByProjectAndTargetObjectId(AggregateReference.to(projectId), id)); - representationMetadata.sort(Comparator.comparing(RepresentationMetadata::getLabel)); - result.addAll(representationMetadata); - List contents = this.objectService.getContents(self); - result.addAll(contents); - }); + new UUIDParser().parse(editingContext.getId()) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()) + .ifPresent(projectId -> { + var representationMetadata = new ArrayList<>(this.representationMetadataSearchService.findAllMetadataByProjectAndTargetObjectId(AggregateReference.to(projectId), id)); + representationMetadata.sort(Comparator.comparing(RepresentationMetadata::getLabel)); + result.addAll(representationMetadata); + List contents = this.objectService.getContents(self); + result.addAll(contents); + }); } } } 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 ce2e0ba52a..9f2a6458f6 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 @@ -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 @@ -55,6 +55,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.IRepresentationMetadataSearchService; +import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; @@ -86,12 +87,15 @@ public class RepresentationsFormDescriptionProvider implements IRepresentationsD private final List representationImageProviders; - public RepresentationsFormDescriptionProvider(IIdentityService identityService, ILabelService labelService, IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationSearchService representationSearchService, List representationImageProviders) { + private final ISemanticDataSearchService semanticDataSearchService; + + public RepresentationsFormDescriptionProvider(IIdentityService identityService, ILabelService labelService, IRepresentationMetadataSearchService representationMetadataSearchService, IRepresentationSearchService representationSearchService, List representationImageProviders, ISemanticDataSearchService semanticDataSearchService) { this.identityService = Objects.requireNonNull(identityService); this.labelService = Objects.requireNonNull(labelService); this.representationMetadataSearchService = Objects.requireNonNull(representationMetadataSearchService); this.representationSearchService = Objects.requireNonNull(representationSearchService); this.representationImageProviders = Objects.requireNonNull(representationImageProviders); + this.semanticDataSearchService = Objects.requireNonNull(semanticDataSearchService); } @Override @@ -211,7 +215,9 @@ private List getItems(VariableManager variableManager) { Object object = variableManager.getVariables().get(VariableManager.SELF); var optionalProjectId = variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class) .map(IEditingContext::getId) - .flatMap(new UUIDParser()::parse); + .flatMap(new UUIDParser()::parse) + .flatMap(this.semanticDataSearchService::findById) + .map(semanticData -> semanticData.getProject().getId()); if (optionalProjectId.isPresent()) { var projectId = optionalProjectId.get(); String id = this.identityService.getId(object); 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/application/controllers/EditingContextControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/EditingContextControllerIntegrationTests.java index e058c02a6c..76256f4d83 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/EditingContextControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/EditingContextControllerIntegrationTests.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 @@ -99,7 +99,7 @@ public void givenEditingContextIdWhenQueryIsPerformedThenTheEditingContextIsRetu @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 givenProjectWhenQueryIsPerformedThenTheEditingContextIdIsReturned() { - Map variables = Map.of("projectId", TestIdentifiers.ECORE_SAMPLE_PROJECT.toString()); + Map variables = Map.of("projectId", TestIdentifiers.ECORE_SAMPLE_PROJECT_ID.toString()); var result = this.currentEditingContextQueryRunner.run(variables); String editingContextId = JsonPath.read(result, "$.data.viewer.project.currentEditingContext.id"); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/services/CustomImageMetadataSearchServiceTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/services/CustomImageMetadataSearchServiceTests.java index a6a1336634..2a73578803 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/services/CustomImageMetadataSearchServiceTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/services/CustomImageMetadataSearchServiceTests.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 @@ -76,7 +76,7 @@ public void beforeEach() { @Sql(scripts = {"/scripts/studio.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 givenProjectImagesAndGlobalImagesInTheDatabaseWhenCustomImageMetadataAreRequestedThenBothCanBeRetrieved() { - var images = this.customImageMetadataSearchService.getAvailableImages(StudioIdentifiers.SAMPLE_STUDIO_PROJECT.toString()); + var images = this.customImageMetadataSearchService.getAvailableImages(StudioIdentifiers.SAMPLE_STUDIO_PROJECT_ID.toString()); assertThat(images) .isNotEmpty() .anySatisfy(image -> assertThat(image.id()).isEqualTo(StudioIdentifiers.PLACEHOLDER_IMAGE_OBJECT)) @@ -88,7 +88,7 @@ public void givenProjectImagesAndGlobalImagesInTheDatabaseWhenCustomImageMetadat @Sql(scripts = {"/scripts/studio.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 givenProjectImagesAndGlobalImagesInTheDatabaseWhenGlobalImageIsDeletedThenItDoesNotExist() { - var images = this.customImageMetadataSearchService.getAvailableImages(StudioIdentifiers.SAMPLE_STUDIO_PROJECT.toString()); + var images = this.customImageMetadataSearchService.getAvailableImages(StudioIdentifiers.SAMPLE_STUDIO_PROJECT_ID.toString()); assertThat(images) .isNotEmpty() .anySatisfy(image -> assertThat(image.id()).isEqualTo(StudioIdentifiers.PLACEHOLDER_IMAGE_OBJECT)) @@ -105,7 +105,7 @@ public void givenProjectImagesAndGlobalImagesInTheDatabaseWhenGlobalImageIsDelet TestTransaction.end(); TestTransaction.start(); - images = this.customImageMetadataSearchService.getAvailableImages(StudioIdentifiers.SAMPLE_STUDIO_PROJECT.toString()); + images = this.customImageMetadataSearchService.getAvailableImages(StudioIdentifiers.SAMPLE_STUDIO_PROJECT_ID.toString()); assertThat(images) .isNotEmpty() .anySatisfy(image -> assertThat(image.id()).isEqualTo(StudioIdentifiers.PLACEHOLDER_IMAGE_OBJECT)) 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..072e39cff5 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"; @@ -41,29 +41,29 @@ public final class MigrationIdentifiers { public static final UUID MIGRATION_STUDIO_DIAGRAM = UUID.fromString("9698833e-ffd4-435a-9aec-765622ce524e"); - public static final UUID MIGRATION_DIAGRAM_LABEL_STYLE_BORDER_SIZE_STUDIO = UUID.fromString("8ce6147e-1f5b-426f-b1be-dfeabd37a50a"); + public static final UUID MIGRATION_DIAGRAM_LABEL_STYLE_BORDER_SIZE_STUDIO = UUID.fromString("65edc1f2-989c-4001-971b-29981179ebfa"); public static final String MIGRATION_DIAGRAM_LABEL_STYLE_BORDER_SIZE_STUDIO_DIAGRAM = "DiagramLabelStyle#borderSize migration"; - public static final UUID MIGRATION_NODE_LABEL_STYLE_SHOW_ICON_STUDIO = UUID.fromString("8e4dc281-b458-4354-b2c8-a03b426b6966"); + public static final UUID MIGRATION_NODE_LABEL_STYLE_SHOW_ICON_STUDIO = UUID.fromString("6d89dded-c843-475f-91b4-e2c91b9a883a"); public static final String MIGRATION_NODE_LABEL_STYLE_SHOW_ICON_STUDIO_DIAGRAM = "NodeLabelStyle#showIcon migration"; - public static final UUID MIGRATION_SELECTION_DIALOG_DESCRIPTION_SELECTION_CANDIDATES_EXPRESSION_STUDIO = UUID.fromString("19d73d38-3de2-4d03-a8f1-ce36c2ed36db"); + public static final UUID MIGRATION_SELECTION_DIALOG_DESCRIPTION_SELECTION_CANDIDATES_EXPRESSION_STUDIO = UUID.fromString("06d828d9-c2c6-46d0-a9c4-7fabd588755b"); public static final String MIGRATION_SELECTION_DIALOG_DESCRIPTION_SELECTION_CANDIDATES_EXPRESSION_STUDIO_DIAGRAM = "SelectionDialogDescription#selectionCandidatesExpression migration"; - public static final UUID MIGRATION_INSIDE_LABEL_STYLE_HEADER_SEPARATOR_DISPLAY_STUDIO = UUID.fromString("590949b9-5d48-46ba-b206-29ad2473e5a5"); + public static final UUID MIGRATION_INSIDE_LABEL_STYLE_HEADER_SEPARATOR_DISPLAY_STUDIO = UUID.fromString("dc9643f8-b1ce-4c93-a176-379063d42b32"); public static final String MIGRATION_INSIDE_LABEL_STYLE_HEADER_SEPARATOR_DISPLAY_STUDIO_DIAGRAM = "InsideLabelStyle#displayHeaderSeparator migration"; public static final String MIGRATION_INSIDE_LABEL_STYLE_HEADER_SEPARATOR_DISPLAY_STUDIO_NODE_1 = "migration Node 1"; - public static final UUID MIGRATION_WIDGET_DESCRIPTION_STYLE_LAYOUT_PROPERTIES_MIGRATION_PARTICIPANT_STUDIO = UUID.fromString("01234836-0902-418a-900a-4c0afd20323e"); + public static final UUID MIGRATION_WIDGET_DESCRIPTION_STYLE_LAYOUT_PROPERTIES_MIGRATION_PARTICIPANT_STUDIO = UUID.fromString("e344d967-a639-4f6c-9c00-a466d51063c6"); public static final String MIGRATION_WIDGET_DESCRIPTION_STYLE_LAYOUT_PROPERTIES_MIGRATION_PARTICIPANT_STUDIO_FORM = "Form View for WidgetDescriptionStyleLayoutPropertiesMigrationParticipant"; - public static final String MIGRATION_TREE_DESCRIPTION_ICON_URL_STUDIO = "718868e6-de6d-4b00-b84f-56802aa6d5d0"; + public static final String MIGRATION_TREE_DESCRIPTION_ICON_URL_STUDIO = "340026b5-1363-4c93-8c2b-7f11188cca8b"; public static final String MIGRATION_TREE_DESCRIPTION_ICON_URL_STUDIO_DOCUMENT_NAME = "TreeDescription#iconUrlDescription 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..30c7c6ba35 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,11 @@ */ 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 SAMPLE_STUDIO_PROJECT_ID = UUID.fromString("01234836-0902-418a-900a-4c0afd20323e"); public static final UUID DOMAIN_DOCUMENT = UUID.fromString("f0e490c1-79f1-49a0-b1f2-3637f2958148"); @@ -53,7 +55,7 @@ public final class StudioIdentifiers { public static final UUID PLACEHOLDER_IMAGE_OBJECT = UUID.fromString("7f8ce6ef-a23f-4c62-a6f8-381d5c237742"); - public static final UUID INSTANCE_PROJECT = UUID.fromString("bb66e0e9-4ab5-47ef-99f5-c6b26be995ea"); + public static final UUID INSTANCE_PROJECT = UUID.fromString("63f4353f-0c71-4122-93be-2d359fc0fa16"); public static final UUID ROOT_OBJECT = UUID.fromString("87fa4553-6889-4ce6-b017-d013987f9fae"); 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..3c0fc0de84 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 @@ -26,7 +26,8 @@ public final class TestIdentifiers { 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 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_PROJECT_ID = UUID.fromString("99d336a2-3049-439a-8853-b104ffb22653"); 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)