From 8b9a1144c94d1660b7bde546c34bfb93009ba2ea Mon Sep 17 00:00:00 2001 From: Michael Charfadi Date: Wed, 15 Jan 2025 10:10:01 +0100 Subject: [PATCH] [4418] Change type of project_id from UUID to String MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-web/issues/4418 Signed-off-by: Michaƫl Charfadi --- CHANGELOG.adoc | 3 + .../web/application/dto/Identified.java | 6 +- .../EditingContextApplicationService.java | 7 +- .../services/EditingContextLoader.java | 5 +- .../EditingContextPersistenceService.java | 40 +++++------ .../services/EditingContextSearchService.java | 8 +-- .../services/api/IEditingContextLoader.java | 6 +- .../MutationUploadImageDataFetcher.java | 5 +- .../images/dto/UploadImageInput.java | 4 +- .../ProjectImageApplicationService.java | 4 +- .../api/IProjectImageApplicationService.java | 4 +- .../ProjectDownloadController.java | 5 +- .../controllers/ProjectRestController.java | 26 ++++--- .../controllers/ViewerProjectDataFetcher.java | 5 +- .../controllers/CommitRestController.java | 12 ++-- .../project/dto/DeleteProjectInput.java | 4 +- .../application/project/dto/ProjectDTO.java | 5 +- .../project/dto/ProjectEventInput.java | 4 +- .../dto/ProjectRenamedEventPayload.java | 4 +- .../project/dto/RenameProjectInput.java | 4 +- .../application/project/dto/RestProject.java | 5 +- .../DefaultEditingContextActionProvider.java | 6 +- .../services/ProjectApplicationService.java | 3 +- .../services/ProjectImportService.java | 8 +-- .../project/services/ProjectMapper.java | 2 +- .../services/ProjectSubscriptions.java | 11 ++- .../ProjectTemplateApplicationService.java | 5 +- .../services/RepresentationExportData.java | 4 +- .../services/RepresentationImportData.java | 4 +- .../RepresentationSerializedExportData.java | 4 +- .../RepresentationSerializedImportData.java | 4 +- .../TemplateBasedProjectInitializer.java | 7 +- .../api/IProjectApplicationService.java | 3 +- .../services/api/IProjectSubscriptions.java | 10 ++- .../api/ITemplateBasedProjectInitializer.java | 6 +- ...DanglingRepresentationDeletionService.java | 13 ++-- .../RepresentationApplicationService.java | 13 ++-- ...resentationMetadataPersistenceService.java | 8 +-- .../CustomImageMetadataSearchService.java | 8 +-- .../StudioCapableEditingContextPredicate.java | 6 +- .../StudioExplorerTreeFilterProvider.java | 9 +-- .../DomainExplorerServices.java | 12 ++-- .../explorer/services/ExplorerServices.java | 21 +++--- ...epresentationsFormDescriptionProvider.java | 11 +-- ...TreeRepresentationDescriptionProvider.java | 8 +-- .../boundedcontexts/project/Project.java | 10 +-- .../repositories/IProjectRepository.java | 4 +- .../repositories/ProjectSearchRepository.java | 5 +- .../ProjectSearchRepositoryDelegate.java | 11 ++- .../ProjectSearchRepositoryImpl.java | 11 ++- .../api/IProjectSearchRepositoryDelegate.java | 6 +- .../services/ProjectDeletionService.java | 5 +- .../services/ProjectSearchService.java | 25 ++----- .../services/ProjectUpdateService.java | 9 ++- .../services/api/IProjectDeletionService.java | 6 +- .../services/api/IProjectSearchService.java | 5 +- .../services/api/IProjectUpdateService.java | 10 ++- .../projectimage/ProjectImage.java | 8 +-- .../repositories/IProjectImageRepository.java | 8 +-- .../services/ProjectImageCreationService.java | 5 +- .../services/ProjectImageSearchService.java | 6 +- .../api/IProjectImageCreationService.java | 5 +- .../api/IProjectImageSearchService.java | 6 +- .../RepresentationMetadata.java | 10 +-- .../IRepresentationMetadataRepository.java | 8 +-- .../RepresentationMetadataSearchService.java | 10 +-- .../IRepresentationMetadataSearchService.java | 10 +-- .../semanticdata/SemanticData.java | 10 +-- .../repositories/ISemanticDataRepository.java | 4 +- .../services/SemanticDataCreationService.java | 5 +- .../services/SemanticDataSearchService.java | 5 +- .../services/SemanticDataUpdateService.java | 5 +- .../api/ISemanticDataCreationService.java | 6 +- .../api/ISemanticDataSearchService.java | 5 +- .../api/ISemanticDataUpdateService.java | 5 +- .../2025.2/01-alter_project_id_type.xml | 71 +++++++++++++++++++ .../db/changelog/2025.2/2025.2.0.xml | 19 +++++ .../main/resources/db/db.changelog-master.xml | 3 +- .../PapayaEditingContextInitializer.java | 6 +- .../PortalControllerIntegrationTests.java | 32 ++++----- .../CommitRestControllerIntegrationTests.java | 10 +-- .../ProjectControllerIntegrationTests.java | 8 +-- ...ectDownloadControllerIntegrationTests.java | 5 +- .../ProjectSearchControllerConfiguration.java | 9 ++- ...ojectUploadControllerIntegrationTests.java | 6 +- .../studiofork/TestCreateForkedStudio.java | 6 +- .../sirius/web/data/StudioIdentifiers.java | 8 +-- .../sirius/web/data/TestIdentifiers.java | 12 ++-- .../sirius/web/domain/DomainEventsTest.java | 9 ++- .../FlowEditingContextInitializer.java | 6 +- .../services/FlowStereotypeProvider.java | 6 +- .../TaskEditingContextInitializer.java | 6 +- 92 files changed, 397 insertions(+), 405 deletions(-) create mode 100644 packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2025.2/01-alter_project_id_type.xml create mode 100644 packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2025.2/2025.2.0.xml diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index faff5982d9..5f8098be4f 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -24,6 +24,8 @@ === Breaking changes +- https://github.com/eclipse-sirius/sirius-web/issues/4418[#4418] [sirius-web] Change type of project_id from UUID to String + === Dependency update @@ -92,6 +94,7 @@ Note that you can retrieve the URL of a page in the response header of `GET /api Note that you may need to encode special characters like `[`(by `%5B`) and `]` (by `%5D`) in your requests. - https://github.com/eclipse-sirius/sirius-web/issues/4381[#4381] [trees] Set activeFilterIds variable in DefaultExpandAllTreePathHandler. - https://github.com/eclipse-sirius/sirius-web/issues/3533[#3553] [diagram] Add a dedicated component to handle diagram subscription +- https://github.com/eclipse-sirius/sirius-web/issues/4418[#4418] [sirius-web] Change type of project_id from UUID to String == v2025.1.0 diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/dto/Identified.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/dto/Identified.java index 02b11eab26..29b97f46bf 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/dto/Identified.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/dto/Identified.java @@ -25,8 +25,12 @@ * @author arichard */ @Schema(name = "Identified", description = "Identified represents an Object through its ID and type.") -public record Identified(@JsonProperty("@id") UUID id) { +public record Identified(@JsonProperty("@id") String id) { public Identified { Objects.requireNonNull(id); } + + public Identified(UUID id) { + this(id.toString()); + } } 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..b76f217590 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 @@ -14,7 +14,6 @@ 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.springframework.stereotype.Service; @@ -37,8 +36,6 @@ public EditingContextApplicationService(IProjectSearchService projectSearchServi @Override @Transactional(readOnly = true) public boolean existsById(String editingContextId) { - return new UUIDParser().parse(editingContextId) - .map(this.projectSearchService::existsById) - .orElse(false); + return this.projectSearchService.existsById(editingContextId); } } 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..e0dc03d6ca 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 @@ -14,7 +14,6 @@ import java.util.List; import java.util.Objects; -import java.util.UUID; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.sirius.components.core.api.IEditingContextProcessor; @@ -60,7 +59,7 @@ public EditingContextLoader(ISemanticDataSearchService semanticDataSearchService this.migrationParticipantPredicates = Objects.requireNonNull(migrationParticipantPredicates); } - public void load(EditingContext editingContext, UUID projectId) { + public void load(EditingContext editingContext, String projectId) { this.editingContextProcessors.forEach(processor -> processor.preProcess(editingContext)); this.semanticDataSearchService.findByProject(AggregateReference.to(projectId)) 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 dec11f5ed6..b574ab63e4 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 @@ -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; @@ -24,7 +23,6 @@ import org.eclipse.sirius.components.core.api.IEditingContextPersistenceService; import org.eclipse.sirius.components.emf.services.api.IEMFEditingContext; import org.eclipse.sirius.components.events.ICause; -import org.eclipse.sirius.web.application.UUIDParser; 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; @@ -77,26 +75,24 @@ 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) - .ifPresent(project -> { - var documentData = emfEditingContext.getDomain().getResourceSet().getResources().stream() - .filter(resource -> IEMFEditingContext.RESOURCE_SCHEME.equals(resource.getURI().scheme())) - .filter(resource -> this.persistenceFilters.stream().allMatch(filter -> filter.shouldPersist(resource))) - .map(resource -> this.resourceToDocumentService.toDocument(resource, applyMigrationParticipants)) - .flatMap(Optional::stream) - .collect(Collectors.toSet()); - - var documents = new LinkedHashSet(); - var domainUris = new LinkedHashSet(); - - documentData.forEach(data -> { - documents.add(data.document()); - domainUris.addAll(data.ePackageEntries().stream().map(EPackageEntry::nsURI).toList()); - }); - - this.semanticDataUpdateService.updateDocuments(cause, project, documents, domainUris); - }); + AggregateReference projectId = AggregateReference.to(editingContext.getId()); + + var documentData = emfEditingContext.getDomain().getResourceSet().getResources().stream() + .filter(resource -> IEMFEditingContext.RESOURCE_SCHEME.equals(resource.getURI().scheme())) + .filter(resource -> this.persistenceFilters.stream().allMatch(filter -> filter.shouldPersist(resource))) + .map(resource -> this.resourceToDocumentService.toDocument(resource, applyMigrationParticipants)) + .flatMap(Optional::stream) + .collect(Collectors.toSet()); + + var documents = new LinkedHashSet(); + var domainUris = new LinkedHashSet(); + + documentData.forEach(data -> { + documents.add(data.document()); + domainUris.addAll(data.ePackageEntries().stream().map(EPackageEntry::nsURI).toList()); + }); + + this.semanticDataUpdateService.updateDocuments(cause, projectId, documents, domainUris); } long end = System.currentTimeMillis(); 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 10a2cff745..76ac0d2b09 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 @@ -24,7 +24,6 @@ import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IEditingContextSearchService; -import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.application.editingcontext.EditingContext; import org.eclipse.sirius.web.application.editingcontext.services.api.IEditingContextLoader; import org.eclipse.sirius.web.application.editingcontext.services.api.IEditingDomainFactory; @@ -68,16 +67,13 @@ public EditingContextSearchService(IProjectSearchService projectSearchService, I @Override @Transactional(readOnly = true) public boolean existsById(String editingContextId) { - return new UUIDParser().parse(editingContextId) - .map(this.projectSearchService::existsById) - .orElse(false); + return this.projectSearchService.existsById(editingContextId); } @Override @Transactional(readOnly = true) public Optional findById(String editingContextId) { - return new UUIDParser().parse(editingContextId) - .flatMap(this.projectSearchService::findById) + return this.projectSearchService.findById(editingContextId) .map(this::toEditingContext); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/api/IEditingContextLoader.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/api/IEditingContextLoader.java index 59a5ebf2e0..36a759b798 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/api/IEditingContextLoader.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/api/IEditingContextLoader.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,8 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.web.application.editingcontext.services.api; -import java.util.UUID; - import org.eclipse.sirius.web.application.editingcontext.EditingContext; /** @@ -23,6 +21,6 @@ */ public interface IEditingContextLoader { - void load(EditingContext editingContext, UUID projectId); + void load(EditingContext editingContext, String projectId); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/controllers/MutationUploadImageDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/controllers/MutationUploadImageDataFetcher.java index 401f5e241b..7f32423626 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/controllers/MutationUploadImageDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/controllers/MutationUploadImageDataFetcher.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 @@ -65,8 +65,7 @@ public IPayload get(DataFetchingEnvironment environment) throws Exception { .flatMap(new UUIDParser()::parse); var optionalProjectId = Optional.ofNullable(inputArgument.get(PROJECT_ID)) - .map(Object::toString) - .flatMap(new UUIDParser()::parse); + .map(Object::toString); var optionalLabel = Optional.ofNullable(inputArgument.get(LABEL)) .filter(String.class::isInstance) diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/dto/UploadImageInput.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/dto/UploadImageInput.java index 7f12b80290..d68d9d781f 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/dto/UploadImageInput.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/dto/UploadImageInput.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,7 @@ */ public record UploadImageInput( @NotNull UUID id, - @NotNull UUID projectId, + @NotNull String projectId, @NotNull String label, @NotNull UploadFile file) implements IInput { } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/services/ProjectImageApplicationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/services/ProjectImageApplicationService.java index d8248d2f21..ad059f8f37 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/services/ProjectImageApplicationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/services/ProjectImageApplicationService.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 @@ -72,7 +72,7 @@ public Optional findById(UUID id) { @Override @Transactional(readOnly = true) - public Page findAll(UUID projectId, Pageable pageable) { + public Page findAll(String projectId, Pageable pageable) { return this.projectImageSearchService.findAll(projectId, pageable).map(this.projectImageMapper::toDTO); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/services/api/IProjectImageApplicationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/services/api/IProjectImageApplicationService.java index eb6e7a40dc..c8ec61e41c 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/services/api/IProjectImageApplicationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/images/services/api/IProjectImageApplicationService.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 @@ -33,7 +33,7 @@ public interface IProjectImageApplicationService { Optional findById(UUID id); - Page findAll(UUID projectId, Pageable pageable); + Page findAll(String projectId, Pageable pageable); IPayload uploadImage(UploadImageInput input); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ProjectDownloadController.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ProjectDownloadController.java index 52cc756205..0f264d1c18 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ProjectDownloadController.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ProjectDownloadController.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 @@ -13,7 +13,6 @@ package org.eclipse.sirius.web.application.project.controllers; import java.util.Objects; -import java.util.UUID; import org.eclipse.sirius.web.application.project.services.api.IProjectExportService; import org.eclipse.sirius.web.domain.boundedcontexts.project.services.api.IProjectSearchService; @@ -58,7 +57,7 @@ public ProjectDownloadController(IProjectSearchService projectSearchService, IPr @ResponseBody @GetMapping(path = "/{projectId}") - public ResponseEntity downloadProject(@PathVariable UUID projectId) { + public ResponseEntity downloadProject(@PathVariable String projectId) { var optionalProject = this.projectSearchService.findById(projectId); if (optionalProject.isPresent()) { var project = optionalProject.get(); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ProjectRestController.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ProjectRestController.java index 813b140509..b61774f971 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ProjectRestController.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ProjectRestController.java @@ -98,8 +98,8 @@ public ResponseEntity> getProjects(@RequestParam(name = "page[ int limit = pageSize.orElse(DEFAULT_PAGE_SIZE); var window = this.projectApplicationService.findAll(position, limit); var restProjects = window - .map(project -> new RestProject(project.id(), DEFAULT_CREATED, new Identified(project.id()), null, project.name())) - .toList(); + .map(project -> new RestProject(project.id(), DEFAULT_CREATED, new Identified(project.id()), null, project.name())) + .toList(); var headers = this.handleLinkResponseHeader(restProjects, position, window.hasNext(), limit); return new ResponseEntity<>(restProjects, headers, HttpStatus.OK); } @@ -112,22 +112,20 @@ public ResponseEntity> getProjects(@RequestParam(name = "page[ @ApiResponse(responseCode = "404", description = "Not Found", content = { @Content() }) }) @GetMapping(path = "/{projectId}") - public ResponseEntity getProjectById(@PathVariable UUID projectId) { + public ResponseEntity getProjectById(@PathVariable String projectId) { var restProject = this.projectApplicationService.findById(projectId) - .map(project -> new RestProject(project.id(), DEFAULT_CREATED, new Identified(project.id()), null, project.name())); + .map(project -> new RestProject(project.id(), DEFAULT_CREATED, new Identified(project.id()), null, project.name())); - if (restProject.isPresent()) { - return new ResponseEntity<>(restProject.get(), HttpStatus.OK); - } + return restProject.map(project -> new ResponseEntity<>(project, HttpStatus.OK)) + .orElseGet(() -> new ResponseEntity<>(null, HttpStatus.NOT_FOUND)); - return new ResponseEntity<>(null, HttpStatus.NOT_FOUND); } @Operation(description = "Create a new project with the given name and description (optional).") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Created", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = RestProject.class)) - }) + }) }) @PostMapping public ResponseEntity createProject(@RequestParam String name, @RequestParam Optional description) { @@ -151,7 +149,7 @@ public ResponseEntity createProject(@RequestParam String name, @Req @ApiResponse(responseCode = "404", description = "Not Found", content = { @Content() }) }) @PutMapping(path = "/{projectId}") - public ResponseEntity updateProject(@PathVariable UUID projectId, @RequestParam Optional name, @RequestParam Optional description, @RequestParam Optional branch) { + public ResponseEntity updateProject(@PathVariable String projectId, @RequestParam Optional name, @RequestParam Optional description, @RequestParam Optional branch) { if (name.isPresent()) { var renameProjectInput = new RenameProjectInput(UUID.randomUUID(), projectId, name.get()); var renamedProjectPayload = this.projectApplicationService.renameProject(renameProjectInput); @@ -168,11 +166,11 @@ public ResponseEntity updateProject(@PathVariable UUID projectId, @ @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = RestProject.class)) - }), + }), @ApiResponse(responseCode = "204", description = "No content", content = { @Content() }) }) @DeleteMapping(path = "/{projectId}") - public ResponseEntity deleteProject(@PathVariable UUID projectId) { + public ResponseEntity deleteProject(@PathVariable String projectId) { var restProject = this.projectApplicationService.findById(projectId) .map(project -> new RestProject(project.id(), DEFAULT_CREATED, new Identified(project.id()), null, project.name())) .orElse(null); @@ -203,7 +201,7 @@ private MultiValueMap handleLinkResponseHeader(List private String createHeaderLink(List projects, int limit, String beforeOrAfterPage, String relationType) { var header = new StringBuilder(); var lastProject = projects.get(Math.min(projects.size() - 1, limit - 1)); - var cursorId = new Relay().toGlobalId("Project", lastProject.id().toString()); + var cursorId = new Relay().toGlobalId("Project", lastProject.id()); UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentRequestUri() .queryParam("page[" + beforeOrAfterPage + "]", cursorId) .queryParam("page[size]", limit) @@ -215,4 +213,4 @@ private String createHeaderLink(List projects, int limit, String be header.append("\""); return header.toString(); } -} +} \ No newline at end of file diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ViewerProjectDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ViewerProjectDataFetcher.java index 28b7391671..6a52687070 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ViewerProjectDataFetcher.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/controllers/ViewerProjectDataFetcher.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 org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; -import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.application.project.services.api.IProjectApplicationService; import org.eclipse.sirius.web.application.project.dto.ProjectDTO; @@ -41,6 +40,6 @@ public ViewerProjectDataFetcher(IProjectApplicationService projectApplicationSer @Override public ProjectDTO get(DataFetchingEnvironment environment) throws Exception { String projectId = environment.getArgument(PROJECT_ID_ARGUMENT); - return new UUIDParser().parse(projectId).flatMap(this.projectApplicationService::findById).orElse(null); + return this.projectApplicationService.findById(projectId).orElse(null); } } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/data/versioning/controllers/CommitRestController.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/data/versioning/controllers/CommitRestController.java index 9683316cb0..63dd58732d 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/data/versioning/controllers/CommitRestController.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/data/versioning/controllers/CommitRestController.java @@ -73,8 +73,8 @@ public CommitRestController(IEditingContextDispatcher editingContextDispatcher) @ApiResponse(responseCode = "404", description = "Not Found", content = { @Content() }) }) @GetMapping - public ResponseEntity> getCommits(@PathVariable UUID projectId) { - var payload = this.editingContextDispatcher.dispatchQuery(projectId.toString(), new GetCommitsRestInput(UUID.randomUUID())).block(Duration.ofSeconds(TIMEOUT)); + public ResponseEntity> getCommits(@PathVariable String projectId) { + var payload = this.editingContextDispatcher.dispatchQuery(projectId, new GetCommitsRestInput(UUID.randomUUID())).block(Duration.ofSeconds(TIMEOUT)); if (payload instanceof GetCommitsRestSuccessPayload successPayload) { return new ResponseEntity<>(successPayload.commits(), HttpStatus.OK); } @@ -119,8 +119,8 @@ Element Data (KerML) is created or updated, derived }) }) @PostMapping - public ResponseEntity createCommit(@PathVariable UUID projectId, @RequestParam Optional branchId) { - var payload = this.editingContextDispatcher.dispatchMutation(projectId.toString(), new CreateCommitRestInput(UUID.randomUUID(), branchId)).block(Duration.ofSeconds(TIMEOUT)); + public ResponseEntity createCommit(@PathVariable String projectId, @RequestParam Optional branchId) { + var payload = this.editingContextDispatcher.dispatchMutation(projectId, new CreateCommitRestInput(UUID.randomUUID(), branchId)).block(Duration.ofSeconds(TIMEOUT)); if (payload instanceof CreateCommitRestSuccessPayload successPayload) { return new ResponseEntity<>(successPayload.commit(), HttpStatus.CREATED); } @@ -136,8 +136,8 @@ public ResponseEntity createCommit(@PathVariable UUID projectId, @Re @ApiResponse(responseCode = "404", description = "Not Found", content = { @Content() }) }) @GetMapping(path = "/{commitId}") - public ResponseEntity getCommitById(@PathVariable UUID projectId, @PathVariable UUID commitId) { - var payload = this.editingContextDispatcher.dispatchQuery(projectId.toString(), new GetCommitByIdRestInput(UUID.randomUUID(), commitId)).block(Duration.ofSeconds(TIMEOUT)); + public ResponseEntity getCommitById(@PathVariable String projectId, @PathVariable UUID commitId) { + var payload = this.editingContextDispatcher.dispatchQuery(projectId, new GetCommitByIdRestInput(UUID.randomUUID(), commitId)).block(Duration.ofSeconds(TIMEOUT)); if (payload instanceof GetCommitByIdRestSuccessPayload successPayload) { return new ResponseEntity<>(successPayload.commit(), HttpStatus.OK); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/DeleteProjectInput.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/DeleteProjectInput.java index 9693130592..53358c949f 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/DeleteProjectInput.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/DeleteProjectInput.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,5 +23,5 @@ * * @author sbegaudeau */ -public record DeleteProjectInput(@NotNull UUID id, @NotNull UUID projectId) implements IInput { +public record DeleteProjectInput(@NotNull UUID id, @NotNull String projectId) implements IInput { } \ No newline at end of file diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectDTO.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectDTO.java index 76e1fe2508..064f105447 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectDTO.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectDTO.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 @@ -13,7 +13,6 @@ package org.eclipse.sirius.web.application.project.dto; import java.util.List; -import java.util.UUID; import jakarta.validation.constraints.NotNull; @@ -23,7 +22,7 @@ * @author sbegaudeau */ public record ProjectDTO( - @NotNull UUID id, + @NotNull String id, @NotNull String name, @NotNull List natures) { } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectEventInput.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectEventInput.java index 8b26aee243..356a22cc82 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectEventInput.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectEventInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 Obeo. + * Copyright (c) 2023, 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,5 +23,5 @@ * * @author arichard */ -public record ProjectEventInput(@NotNull UUID id, @NotNull UUID projectId) implements IInput { +public record ProjectEventInput(@NotNull UUID id, @NotNull String projectId) implements IInput { } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectRenamedEventPayload.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectRenamedEventPayload.java index 6a6a5337da..771f91d4d2 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectRenamedEventPayload.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/ProjectRenamedEventPayload.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 Obeo. + * Copyright (c) 2023, 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,5 +23,5 @@ * * @author arichard */ -public record ProjectRenamedEventPayload(@NotNull UUID id, @NotNull UUID projectId, @NotNull String newName) implements IPayload { +public record ProjectRenamedEventPayload(@NotNull UUID id, @NotNull String projectId, @NotNull String newName) implements IPayload { } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/RenameProjectInput.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/RenameProjectInput.java index e22a4513fb..841f53ed95 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/RenameProjectInput.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/RenameProjectInput.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,6 @@ */ public record RenameProjectInput( @NotNull UUID id, - @NotNull UUID projectId, + @NotNull String projectId, @NotNull String newName) implements IInput { } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/RestProject.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/RestProject.java index bee803b169..dc8e93ed1e 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/RestProject.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/dto/RestProject.java @@ -16,7 +16,6 @@ import java.time.OffsetDateTime; import java.util.Objects; -import java.util.UUID; import org.eclipse.sirius.web.application.dto.Identified; @@ -33,7 +32,7 @@ public record RestProject( @Schema(requiredMode = RequiredMode.REQUIRED, description = "The UUID assigned to the record") @JsonProperty("@id") - UUID id, + String id, @Schema(requiredMode = RequiredMode.REQUIRED, description = "Project") @JsonProperty("@type") @@ -63,7 +62,7 @@ public record RestProject( } public RestProject( - UUID id, + String id, OffsetDateTime created, Identified defaultBranch, String description, 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..9f61d375c4 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 @@ -19,7 +19,6 @@ import org.eclipse.sirius.components.collaborative.api.IEditingContextActionProvider; import org.eclipse.sirius.components.collaborative.dto.EditingContextAction; import org.eclipse.sirius.components.core.api.IEditingContext; -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.springframework.stereotype.Service; @@ -42,8 +41,7 @@ public DefaultEditingContextActionProvider(IProjectSearchService projectSearchSe @Override public List getEditingContextAction(IEditingContext editingContext) { - var isWithoutNature = new UUIDParser().parse(editingContext.getId()) - .flatMap(this.projectSearchService::findById) + var isWithoutNature = this.projectSearchService.findById(editingContext.getId()) .map(Project::getNatures) .orElseGet(Set::of) .isEmpty(); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectApplicationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectApplicationService.java index e8e1550377..d7fe90f619 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectApplicationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectApplicationService.java @@ -14,7 +14,6 @@ import java.util.Objects; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.components.core.api.ErrorPayload; import org.eclipse.sirius.components.core.api.IPayload; @@ -66,7 +65,7 @@ public ProjectApplicationService(IProjectSearchService projectSearchService, IPr @Override @Transactional(readOnly = true) - public Optional findById(UUID projectId) { + public Optional findById(String projectId) { return this.projectSearchService.findById(projectId).map(this.projectMapper::toDTO); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectImportService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectImportService.java index e3a5be9fd4..41d53d9ef4 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectImportService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectImportService.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 @@ -152,15 +152,15 @@ public IPayload importProject(UUID inputId, UploadFile file) { if (createProjectPayload instanceof CreateProjectSuccessPayload createProjectSuccessPayload) { var project = createProjectSuccessPayload.project(); Optional optionalEditingContextEventProcessor = this.editingContextEventProcessorRegistry - .getOrCreateEditingContextEventProcessor(project.id().toString()); + .getOrCreateEditingContextEventProcessor(project.id()); if (optionalEditingContextEventProcessor.isPresent()) { IEditingContextEventProcessor editingContextEventProcessor = optionalEditingContextEventProcessor.get(); - ProjectImporter projectImporter = new ProjectImporter(project.id().toString(), editingContextEventProcessor, documents, representationImportDatas, projectManifest); + ProjectImporter projectImporter = new ProjectImporter(project.id(), editingContextEventProcessor, documents, representationImportDatas, projectManifest); boolean hasBeenImported = projectImporter.importProject(inputId); if (!hasBeenImported) { - this.editingContextEventProcessorRegistry.disposeEditingContextEventProcessor(project.id().toString()); + this.editingContextEventProcessorRegistry.disposeEditingContextEventProcessor(project.id()); this.projectApplicationService.deleteProject(new DeleteProjectInput(inputId, project.id())); } else { payload = new UploadProjectSuccessPayload(inputId, project); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectMapper.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectMapper.java index 825c389807..474500277a 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectMapper.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectMapper.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 diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectSubscriptions.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectSubscriptions.java index 3baf1397d6..d598ac8af9 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectSubscriptions.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectSubscriptions.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.Map; import java.util.Objects; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.web.application.project.services.api.IProjectSubscriptions; @@ -37,7 +36,7 @@ public class ProjectSubscriptions implements IProjectSubscriptions { private final IProjectSearchService projectSearchService; - private final Map> projectIdsToSink = new HashMap<>(); + private final Map> projectIdsToSink = new HashMap<>(); public ProjectSubscriptions(IProjectSearchService projectSearchService) { this.projectSearchService = Objects.requireNonNull(projectSearchService); @@ -45,7 +44,7 @@ public ProjectSubscriptions(IProjectSearchService projectSearchService) { @Override @Transactional(readOnly = true) - public Optional> findProjectSubscriptionById(UUID projectId) { + public Optional> findProjectSubscriptionById(String projectId) { if (this.projectSearchService.existsById(projectId)) { var many = this.projectIdsToSink.computeIfAbsent(projectId, id -> Sinks.many().multicast().directBestEffort()); return Optional.of(many.asFlux()); @@ -54,12 +53,12 @@ public Optional> findProjectSubscriptionById(UUID projectId) { } @Override - public void emit(UUID projectId, IPayload payload) { + public void emit(String projectId, IPayload payload) { Optional.ofNullable(this.projectIdsToSink.get(projectId)).ifPresent(many -> many.tryEmitNext(payload)); } @Override - public void dispose(UUID projectId) { + public void dispose(String projectId) { Optional.ofNullable(this.projectIdsToSink.get(projectId)).ifPresent(Sinks.Many::tryEmitComplete); this.projectIdsToSink.remove(projectId); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectTemplateApplicationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectTemplateApplicationService.java index 963aa128e6..6ce2793f51 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectTemplateApplicationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/ProjectTemplateApplicationService.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 @@ -94,7 +94,8 @@ public IPayload createProjectFromTemplate(CreateProjectFromTemplateInput input) var projectCreationPayload = this.projectApplicationService.createProject(new CreateProjectInput(input.id(), projectTemplate.label(), natures)); if (projectCreationPayload instanceof CreateProjectSuccessPayload createProjectSuccessPayload) { - payload = this.templateBasedProjectInitializer.initializeProjectFromTemplate(input, createProjectSuccessPayload.project().id(), input.templateId()); + var projectId = createProjectSuccessPayload.project().id(); + payload = this.templateBasedProjectInitializer.initializeProjectFromTemplate(input, projectId, input.templateId()); } else { payload = projectCreationPayload; } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationExportData.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationExportData.java index 3c14f97d0a..e1126326d7 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationExportData.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationExportData.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 record RepresentationExportData( UUID id, - UUID projectId, + String projectId, String descriptionId, String targetObjectId, String label, diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationImportData.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationImportData.java index 8df8980f44..1feb71d533 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationImportData.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationImportData.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 record RepresentationImportData( UUID id, - UUID projectId, + String projectId, String descriptionId, String targetObjectId, String label, diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationSerializedExportData.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationSerializedExportData.java index c74d5348f9..21aa91ffcb 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationSerializedExportData.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationSerializedExportData.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,7 +23,7 @@ */ public record RepresentationSerializedExportData( UUID id, - UUID projectId, + String projectId, String descriptionId, String targetObjectId, String label, diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationSerializedImportData.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationSerializedImportData.java index 980f720b7c..a071fb3cc2 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationSerializedImportData.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/RepresentationSerializedImportData.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,7 +23,7 @@ */ public record RepresentationSerializedImportData( UUID id, - UUID projectId, + String projectId, String descriptionId, String targetObjectId, String label, diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/TemplateBasedProjectInitializer.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/TemplateBasedProjectInitializer.java index a909f8f0db..e5d88baaa2 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/TemplateBasedProjectInitializer.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/TemplateBasedProjectInitializer.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 @@ -14,7 +14,6 @@ import java.util.List; import java.util.Objects; -import java.util.UUID; import org.eclipse.sirius.components.core.api.ErrorPayload; import org.eclipse.sirius.components.core.api.IEditingContextPersistenceService; @@ -65,9 +64,9 @@ public TemplateBasedProjectInitializer(IProjectSearchService projectSearchServic @Override @Transactional - public IPayload initializeProjectFromTemplate(CreateProjectFromTemplateInput input, UUID projectId, String templateId) { + public IPayload initializeProjectFromTemplate(CreateProjectFromTemplateInput input, String projectId, String templateId) { var optionalProject = this.projectSearchService.findById(projectId); - var optionalEditingContext = this.editingContextSearchService.findById(projectId.toString()); + var optionalEditingContext = this.editingContextSearchService.findById(projectId); var optionalProjectTemplateInitializer = this.projectTemplateInitializers.stream() .filter(initializer -> initializer.canHandle(input.templateId())) .findFirst(); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/IProjectApplicationService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/IProjectApplicationService.java index dff4120e42..3d3534489b 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/IProjectApplicationService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/IProjectApplicationService.java @@ -13,7 +13,6 @@ package org.eclipse.sirius.web.application.project.services.api; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.web.application.project.dto.CreateProjectInput; @@ -29,7 +28,7 @@ * @author sbegaudeau */ public interface IProjectApplicationService { - Optional findById(UUID id); + Optional findById(String id); Window findAll(KeysetScrollPosition position, int limit); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/IProjectSubscriptions.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/IProjectSubscriptions.java index 9dad7d4162..47bf67e77d 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/IProjectSubscriptions.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/IProjectSubscriptions.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 @@ -13,8 +13,6 @@ package org.eclipse.sirius.web.application.project.services.api; import java.util.Optional; -import java.util.UUID; - import org.eclipse.sirius.components.core.api.IPayload; import reactor.core.publisher.Flux; @@ -25,9 +23,9 @@ * @author sbegaudeau */ public interface IProjectSubscriptions { - Optional> findProjectSubscriptionById(UUID projectId); + Optional> findProjectSubscriptionById(String projectId); - void emit(UUID projectId, IPayload payload); + void emit(String projectId, IPayload payload); - void dispose(UUID projectId); + void dispose(String projectId); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/ITemplateBasedProjectInitializer.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/ITemplateBasedProjectInitializer.java index 3b56c6a527..acf66dff6e 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/ITemplateBasedProjectInitializer.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/project/services/api/ITemplateBasedProjectInitializer.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,8 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.web.application.project.services.api; -import java.util.UUID; - import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.web.application.project.dto.CreateProjectFromTemplateInput; @@ -23,5 +21,5 @@ * @author sbegaudeau */ public interface ITemplateBasedProjectInitializer { - IPayload initializeProjectFromTemplate(CreateProjectFromTemplateInput input, UUID projectId, String templateId); + IPayload initializeProjectFromTemplate(CreateProjectFromTemplateInput input, String projectId, String templateId); } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DanglingRepresentationDeletionService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DanglingRepresentationDeletionService.java index 7322771141..9d4276cc83 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DanglingRepresentationDeletionService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/representation/services/DanglingRepresentationDeletionService.java @@ -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,7 +20,6 @@ import org.eclipse.sirius.components.core.api.IObjectSearchService; import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.components.representations.IRepresentation; -import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataDeletionService; import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; @@ -58,11 +57,9 @@ public boolean isDangling(IEditingContext editingContext, IRepresentation repres @Override @Transactional public void deleteDanglingRepresentations(ICause cause, IEditingContext editingContext) { - new UUIDParser().parse(editingContext.getId()).ifPresent(projectId -> { - this.representationMetadataSearchService.findAllMetadataByProject(AggregateReference.to(projectId)).stream() - .filter(representationMetadata -> this.objectSearchService.getObject(editingContext, representationMetadata.getTargetObjectId()).isEmpty()) - .map(RepresentationMetadata::getId) - .forEach(representationId -> this.representationMetadataDeletionService.delete(cause, representationId)); - }); + this.representationMetadataSearchService.findAllMetadataByProject(AggregateReference.to(editingContext.getId())).stream() + .filter(representationMetadata -> this.objectSearchService.getObject(editingContext, representationMetadata.getTargetObjectId()).isEmpty()) + .map(RepresentationMetadata::getId) + .forEach(representationId -> this.representationMetadataDeletionService.delete(cause, representationId)); } } 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..4053d0e697 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 @@ -13,10 +13,8 @@ package org.eclipse.sirius.web.application.representation.services; import java.util.Comparator; -import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.application.representation.dto.RepresentationMetadataDTO; @@ -52,10 +50,8 @@ public RepresentationApplicationService(IRepresentationMetadataSearchService rep @Override @Transactional(readOnly = true) public Page findAllByEditingContextId(String editingContextId, Pageable pageable) { - var representationMetadata = new UUIDParser().parse(editingContextId) - .map(AggregateReference::to) - .map(this.representationMetadataSearchService::findAllMetadataByProject) - .orElse(List.of()) + AggregateReference projectId = AggregateReference.to(editingContextId); + var representationMetadata = this.representationMetadataSearchService.findAllMetadataByProject(projectId) .stream() .sorted(Comparator.comparing(RepresentationMetadata::getLabel)) .toList(); @@ -73,8 +69,7 @@ public Page findAllByEditingContextId(String editingC public Optional findEditingContextIdFromRepresentationId(String representationId) { return new UUIDParser().parse(representationId) .flatMap(this.representationMetadataSearchService::findProjectByRepresentationId) - .map(AggregateReference::getId) - .map(UUID::toString); + .map(AggregateReference::getId); } @Override 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..9a4a3ff456 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 @@ -42,15 +42,13 @@ public RepresentationMetadataPersistenceService(IRepresentationMetadataCreationS @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 optionalRepresentationId = new UUIDParser().parse(representationMetadata.id()); - if (optionalProjectId.isPresent() && optionalRepresentationId.isPresent()) { - var projectId = optionalProjectId.get(); + if (optionalRepresentationId.isPresent()) { var representationId = optionalRepresentationId.get(); var boundedRepresentationMetadata = RepresentationMetadata.newRepresentationMetadata(representationId) - .project(AggregateReference.to(projectId)) + .project(AggregateReference.to(editingContext.getId())) .label(representationMetadata.label()) .kind(representationMetadata.kind()) .descriptionId(representationMetadata.descriptionId()) diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/CustomImageMetadataSearchService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/CustomImageMetadataSearchService.java index 5d446f1ebf..ecde7239d0 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/CustomImageMetadataSearchService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/CustomImageMetadataSearchService.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 @@ -18,7 +18,6 @@ import org.eclipse.sirius.components.view.emf.api.CustomImageMetadata; import org.eclipse.sirius.components.view.emf.api.ICustomImageMetadataSearchService; -import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.domain.boundedcontexts.image.services.api.IImageSearchService; import org.eclipse.sirius.web.domain.boundedcontexts.projectimage.services.api.IProjectImageSearchService; import org.springframework.stereotype.Service; @@ -46,9 +45,8 @@ public List getAvailableImages(String editingContextId) { .map(image -> new CustomImageMetadata(image.getId(), image.getLabel(), image.getContentType())) .toList(); - var projectCustomImageMetadata = new UUIDParser().parse(editingContextId) - .map(this.projectImageSearchService::findAll) - .orElse(List.of()) + var projectCustomImageMetadata = + this.projectImageSearchService.findAll(editingContextId) .stream() .map(image -> new CustomImageMetadata(image.getId(), image.getLabel(), image.getContentType())) .toList(); 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..8cf22ffedb 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 @@ -15,7 +15,6 @@ import java.util.Objects; import org.eclipse.sirius.components.core.api.IEditingContext; -import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.application.studio.services.api.IStudioCapableEditingContextPredicate; import org.eclipse.sirius.web.domain.boundedcontexts.project.Nature; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; @@ -38,8 +37,7 @@ public StudioCapableEditingContextPredicate(IProjectSearchService projectSearchS @Override public boolean test(IEditingContext editingContext) { - return new UUIDParser().parse(editingContext.getId()) - .flatMap(this.projectSearchService::findById) + return this.projectSearchService.findById(editingContext.getId()) .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..3f7c07e1ef 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 @@ -19,7 +19,6 @@ import org.eclipse.sirius.components.collaborative.trees.api.ITreeFilterProvider; import org.eclipse.sirius.components.collaborative.trees.api.TreeFilter; import org.eclipse.sirius.components.trees.description.TreeDescription; -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.springframework.stereotype.Service; @@ -42,13 +41,11 @@ public StudioExplorerTreeFilterProvider(IProjectSearchService projectSearchServi @Override public List get(String editingContextId, TreeDescription treeDescription, String representationId) { - var isStudio = new UUIDParser().parse(editingContextId) - .flatMap(this.projectSearchService::findById) + var isStudio = this.projectSearchService.findById(editingContextId) .map(project -> project.getNatures().stream() .map(Nature::name) .anyMatch(StudioProjectTemplateProvider.STUDIO_NATURE::equals)) - .orElse(false) - .booleanValue(); + .orElse(false); var filters = new ArrayList(); if (isStudio) { diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/representations/DomainExplorerServices.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/representations/DomainExplorerServices.java index 04a77fb7b2..ec778b73be 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/representations/DomainExplorerServices.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/representations/DomainExplorerServices.java @@ -27,7 +27,6 @@ import org.eclipse.sirius.components.core.api.IObjectService; import org.eclipse.sirius.components.domain.Domain; import org.eclipse.sirius.components.domain.Entity; -import org.eclipse.sirius.web.application.UUIDParser; import org.eclipse.sirius.web.application.views.explorer.services.api.IExplorerServices; import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService; import org.springframework.data.jdbc.core.mapping.AggregateReference; @@ -102,13 +101,10 @@ public List getChildren(Object self, IEditingContext editingContext, Lis if (self instanceof Resource resource) { result.addAll(resource.getContents()); } else if (self instanceof EObject) { - var optionalEditingContextId = new UUIDParser().parse(editingContext.getId()); - if (optionalEditingContextId.isPresent()) { - var projectId = optionalEditingContextId.get(); - var representationMetadata = new ArrayList<>(this.representationMetadataSearchService.findAllMetadataByProjectAndTargetObjectId(AggregateReference.to(projectId), id)); - representationMetadata.sort(Comparator.comparing(org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata::getLabel)); - result.addAll(representationMetadata); - } + var representationMetadata = new ArrayList<>(this.representationMetadataSearchService.findAllMetadataByProjectAndTargetObjectId(AggregateReference.to(editingContext.getId()), id)); + representationMetadata.sort(Comparator.comparing(org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata::getLabel)); + result.addAll(representationMetadata); + List contents = this.objectService.getContents(self); if (self instanceof Entity entity) { result.add(new SettingWrapper(((InternalEObject) entity).eSetting(entity.eClass().getEStructuralFeature("superTypes")))); 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..3a760faf64 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 @@ -208,12 +208,10 @@ public boolean hasChildren(Object self, IEditingContext editingContext) { hasChildren = !resource.getContents().isEmpty(); } else if (self instanceof EObject eObject) { hasChildren = !eObject.eContents().isEmpty(); - var optionalProjectId = Optional.ofNullable(editingContext).map(IEditingContext::getId).flatMap(new UUIDParser()::parse); - if (!hasChildren && optionalProjectId.isPresent()) { - var projectId = optionalProjectId.get(); + if (!hasChildren) { String id = this.objectService.getId(eObject); - hasChildren = this.representationMetadataSearchService.existAnyRepresentationForProjectAndTargetObjectId(AggregateReference.to(projectId), id); + hasChildren = this.representationMetadataSearchService.existAnyRepresentationForProjectAndTargetObjectId(AggregateReference.to(editingContext.getId()), id); } } return hasChildren; @@ -228,13 +226,11 @@ 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); - }); + var representationMetadata = new ArrayList<>(this.representationMetadataSearchService.findAllMetadataByProjectAndTargetObjectId(AggregateReference.to(editingContext.getId()), id)); + representationMetadata.sort(Comparator.comparing(RepresentationMetadata::getLabel)); + result.addAll(representationMetadata); + List contents = this.objectService.getContents(self); + result.addAll(contents); } } } @@ -244,7 +240,6 @@ public List getDefaultChildren(Object self, IEditingContext editingConte @Override public List getDefaultElements(IEditingContext editingContext) { var optionalResourceSet = Optional.ofNullable(editingContext) - .filter(IEditingContext.class::isInstance) .filter(IEMFEditingContext.class::isInstance) .map(IEMFEditingContext.class::cast) .map(IEMFEditingContext::getDomain) 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..b4808cf219 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 @@ -210,8 +210,7 @@ private String getTargetObjectId(VariableManager variableManager) { 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); + .map(IEditingContext::getId); if (optionalProjectId.isPresent()) { var projectId = optionalProjectId.get(); String id = this.identityService.getId(object); @@ -291,11 +290,7 @@ private List getChildren(VariableManager variableManager) { items = this.getPortalChildren(optionalPortal.get()); } } else if (id != null) { - var optionalProjectId = new UUIDParser().parse(editingContext.getId()); - if (optionalProjectId.isPresent()) { - var projectId = optionalProjectId.get(); - items = this.representationMetadataSearchService.findAllMetadataByProjectAndTargetObjectId(AggregateReference.to(projectId), id).stream().toList(); - } + items = this.representationMetadataSearchService.findAllMetadataByProjectAndTargetObjectId(AggregateReference.to(editingContext.getId()), id).stream().toList(); } } } diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/tree/DomainTreeRepresentationDescriptionProvider.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/tree/DomainTreeRepresentationDescriptionProvider.java index 3803178356..61bcdb7148 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/tree/DomainTreeRepresentationDescriptionProvider.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/views/tree/DomainTreeRepresentationDescriptionProvider.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 @@ -192,11 +192,11 @@ private boolean hasChildren(VariableManager variableManager) { boolean hasChildren = false; if (self instanceof EObject eObject) { hasChildren = !eObject.eContents().isEmpty(); - var optionalProjectId = variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class).map(IEditingContext::getId).flatMap(new UUIDParser()::parse); + var optionalProjectId = variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class).map(IEditingContext::getId); if (!hasChildren && optionalProjectId.isPresent()) { - var projectId = optionalProjectId.get(); String id = this.objectService.getId(eObject); + var projectId = optionalProjectId.get(); hasChildren = this.representationMetadataSearchService.existAnyRepresentationForProjectAndTargetObjectId(AggregateReference.to(projectId), id); } @@ -235,7 +235,7 @@ private List getDefaultChildren(VariableManager variableManager) { String id = this.getTreeItemId(variableManager); if (expandedIds.contains(id)) { if (self instanceof EObject) { - var optionalProjectId = variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class).map(IEditingContext::getId).flatMap(new UUIDParser()::parse); + var optionalProjectId = variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class).map(IEditingContext::getId); if (optionalProjectId.isPresent()) { var projectId = optionalProjectId.get(); var representationMetadata = new ArrayList<>(this.representationMetadataSearchService.findAllMetadataByProjectAndTargetObjectId(AggregateReference.to(projectId), id)); diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/Project.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/Project.java index 3c1b644266..61adb15158 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/Project.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/Project.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 @@ -40,13 +40,13 @@ * @author sbegaudeau */ @Table("project") -public class Project extends AbstractValidatingAggregateRoot implements Persistable { +public class Project extends AbstractValidatingAggregateRoot implements Persistable { @Transient private boolean isNew; @Id - private UUID id; + private String id; private String name; @@ -58,7 +58,7 @@ public class Project extends AbstractValidatingAggregateRoot implements private Instant lastModifiedOn; @Override - public UUID getId() { + public String getId() { return this.id; } @@ -152,7 +152,7 @@ public Builder natures(Collection natures) { public Project build(ICause cause) { var project = new Project(); project.isNew = true; - project.id = UUID.randomUUID(); + project.id = UUID.randomUUID().toString(); project.name = Objects.requireNonNull(this.name); project.natures = Objects.requireNonNull(this.natures); diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/IProjectRepository.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/IProjectRepository.java index 70a532435d..7e689a00bd 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/IProjectRepository.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/IProjectRepository.java @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.web.domain.boundedcontexts.project.repositories; -import java.util.UUID; - import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.springframework.data.repository.ListCrudRepository; import org.springframework.stereotype.Repository; @@ -25,5 +23,5 @@ * @author sbegaudeau */ @Repository -public interface IProjectRepository extends ListCrudRepository, ProjectSearchRepository { +public interface IProjectRepository extends ListCrudRepository, ProjectSearchRepository { } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepository.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepository.java index 01bc5c0a4b..acd67ba1fc 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepository.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepository.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.components.annotations.RepositoryFragment; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; @@ -33,7 +32,7 @@ public interface ProjectSearchRepository { Optional findById(ID id); - List findAllBefore(UUID cursorProjectId, int limit); + List findAllBefore(String cursorProjectId, int limit); - List findAllAfter(UUID cursorProjectId, int limit); + List findAllAfter(String cursorProjectId, int limit); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepositoryDelegate.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepositoryDelegate.java index 69bf8a0cf3..b89695b4f4 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepositoryDelegate.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepositoryDelegate.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.eclipse.sirius.web.domain.boundedcontexts.project.repositories.api.IProjectSearchRepositoryDelegate; @@ -81,19 +80,19 @@ public ProjectSearchRepositoryDelegate(JdbcAggregateOperations jdbcAggregateOper } @Override - public boolean existsById(UUID projectId) { + public boolean existsById(String projectId) { Query query = query(where(ID).is(projectId)); return this.jdbcAggregateOperations.exists(query, Project.class); } @Override - public Optional findById(UUID projectId) { + public Optional findById(String projectId) { Query query = query(where(ID).is(projectId)); return this.jdbcAggregateOperations.findOne(query, Project.class); } @Override - public List findAllBefore(UUID cursorProjectId, int limit) { + public List findAllBefore(String cursorProjectId, int limit) { List projectsBefore = null; if (limit > 0) { var projects = this.getAllProjectsQuery(FIND_ALL_BEFORE, cursorProjectId, limit + 1); @@ -103,7 +102,7 @@ public List findAllBefore(UUID cursorProjectId, int limit) { } @Override - public List findAllAfter(UUID cursorProjectId, int limit) { + public List findAllAfter(String cursorProjectId, int limit) { List projectsAfter = null; if (limit > 0) { var projects = this.getAllProjectsQuery(FIND_ALL_AFTER, cursorProjectId, limit + 1); @@ -112,7 +111,7 @@ public List findAllAfter(UUID cursorProjectId, int limit) { return projectsAfter; } - private List getAllProjectsQuery(String sqlQuery, UUID cursorProjectId, int limit) { + private List getAllProjectsQuery(String sqlQuery, String cursorProjectId, int limit) { return this.jdbcClient .sql(sqlQuery) .param(CURSOR_PROJECT_ID, cursorProjectId) diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepositoryImpl.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepositoryImpl.java index 5de3c1e54c..80129d5df8 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepositoryImpl.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/ProjectSearchRepositoryImpl.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.eclipse.sirius.web.domain.boundedcontexts.project.repositories.api.IProjectSearchRepositoryDelegate; @@ -27,7 +26,7 @@ * @author sbegaudeau */ @Repository -public class ProjectSearchRepositoryImpl implements ProjectSearchRepository { +public class ProjectSearchRepositoryImpl implements ProjectSearchRepository { private final IProjectSearchRepositoryDelegate projectSearchRepositoryDelegate; @@ -36,22 +35,22 @@ public ProjectSearchRepositoryImpl(IProjectSearchRepositoryDelegate projectSearc } @Override - public boolean existsById(UUID projectId) { + public boolean existsById(String projectId) { return this.projectSearchRepositoryDelegate.existsById(projectId); } @Override - public Optional findById(UUID projectId) { + public Optional findById(String projectId) { return this.projectSearchRepositoryDelegate.findById(projectId); } @Override - public List findAllAfter(UUID cursorProjectId, int limit) { + public List findAllAfter(String cursorProjectId, int limit) { return this.projectSearchRepositoryDelegate.findAllAfter(cursorProjectId, limit); } @Override - public List findAllBefore(UUID cursorProjectId, int limit) { + public List findAllBefore(String cursorProjectId, int limit) { return this.projectSearchRepositoryDelegate.findAllBefore(cursorProjectId, limit); } } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/api/IProjectSearchRepositoryDelegate.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/api/IProjectSearchRepositoryDelegate.java index 0073c887c6..bab946e7cd 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/api/IProjectSearchRepositoryDelegate.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/repositories/api/IProjectSearchRepositoryDelegate.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,8 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.web.domain.boundedcontexts.project.repositories.api; -import java.util.UUID; - import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.eclipse.sirius.web.domain.boundedcontexts.project.repositories.ProjectSearchRepository; @@ -22,5 +20,5 @@ * * @author sbegaudeau */ -public interface IProjectSearchRepositoryDelegate extends ProjectSearchRepository { +public interface IProjectSearchRepositoryDelegate extends ProjectSearchRepository { } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectDeletionService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectDeletionService.java index d6008da9bf..dbf4cde798 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectDeletionService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectDeletionService.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 @@ -13,7 +13,6 @@ package org.eclipse.sirius.web.domain.boundedcontexts.project.services; import java.util.Objects; -import java.util.UUID; import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.boundedcontexts.project.repositories.IProjectRepository; @@ -42,7 +41,7 @@ public ProjectDeletionService(IProjectRepository projectRepository, IMessageServ } @Override - public IResult deleteProject(ICause cause, UUID projectId) { + public IResult deleteProject(ICause cause, String projectId) { IResult result = null; var optionalProject = this.projectRepository.findById(projectId); diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectSearchService.java index 520f669fcb..df8eb5e49a 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectSearchService.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.eclipse.sirius.web.domain.boundedcontexts.project.repositories.IProjectRepository; @@ -38,12 +37,12 @@ public ProjectSearchService(IProjectRepository projectRepository) { } @Override - public boolean existsById(UUID projectId) { + public boolean existsById(String projectId) { return this.projectRepository.existsById(projectId); } @Override - public Optional findById(UUID projectId) { + public Optional findById(String projectId) { return this.projectRepository.findById(projectId); } @@ -53,17 +52,16 @@ public Window findAll(KeysetScrollPosition position, int limit) { if (limit > 0) { var cursorProjectKey = position.getKeys().get("id"); if (cursorProjectKey instanceof String cursorProjectId) { - var cursorProjectUUID = this.parse(cursorProjectId); - if (cursorProjectUUID.isPresent() && this.existsById(cursorProjectUUID.get())) { + if (this.existsById(cursorProjectId)) { if (position.scrollsForward()) { - var projects = this.projectRepository.findAllAfter(cursorProjectUUID.get(), limit + 1); + var projects = this.projectRepository.findAllAfter(cursorProjectId, limit + 1); boolean hasNext = projects.size() > limit; - boolean hasPrevious = !this.projectRepository.findAllBefore(cursorProjectUUID.get(), 1).isEmpty(); + boolean hasPrevious = !this.projectRepository.findAllBefore(cursorProjectId, 1).isEmpty(); window = new Window<>(projects.subList(0, Math.min(projects.size(), limit)), index -> position, hasNext, hasPrevious); } else if (position.scrollsBackward()) { - var projects = this.projectRepository.findAllBefore(cursorProjectUUID.get(), limit + 1); + var projects = this.projectRepository.findAllBefore(cursorProjectId, limit + 1); boolean hasPrevious = projects.size() > limit; - boolean hasNext = !this.projectRepository.findAllAfter(cursorProjectUUID.get(), 1).isEmpty(); + boolean hasNext = !this.projectRepository.findAllAfter(cursorProjectId, 1).isEmpty(); window = new Window<>(projects.subList(0, Math.min(projects.size(), limit)), index -> position, hasNext, hasPrevious); } } @@ -77,13 +75,4 @@ public Window findAll(KeysetScrollPosition position, int limit) { return window; } - private Optional parse(String id) { - try { - UUID uuid = UUID.fromString(id); - return Optional.of(uuid); - } catch (IllegalArgumentException exception) { - // Ignore, the information that the id is invalid is returned as an empty Optional. - } - return Optional.empty(); - } } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectUpdateService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectUpdateService.java index 5749f56e97..82171c78d5 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectUpdateService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/ProjectUpdateService.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 @@ -13,7 +13,6 @@ package org.eclipse.sirius.web.domain.boundedcontexts.project.services; import java.util.Objects; -import java.util.UUID; import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.boundedcontexts.project.repositories.IProjectRepository; @@ -46,7 +45,7 @@ public ProjectUpdateService(IProjectRepository projectRepository, IProjectNameVa } @Override - public IResult renameProject(ICause cause, UUID projectId, String newName) { + public IResult renameProject(ICause cause, String projectId, String newName) { IResult result = null; var optionalProject = this.projectRepository.findById(projectId); @@ -67,7 +66,7 @@ public IResult renameProject(ICause cause, UUID projectId, String newName) } @Override - public IResult addNature(ICause cause, UUID projectId, String natureName) { + public IResult addNature(ICause cause, String projectId, String natureName) { IResult result = null; var optionalProject = this.projectRepository.findById(projectId); @@ -85,7 +84,7 @@ public IResult addNature(ICause cause, UUID projectId, String natureName) } @Override - public IResult removeNature(ICause cause, UUID projectId, String natureName) { + public IResult removeNature(ICause cause, String projectId, String natureName) { IResult result = null; var optionalProject = this.projectRepository.findById(projectId); diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectDeletionService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectDeletionService.java index 9d8da6f925..690833745c 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectDeletionService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectDeletionService.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,8 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.web.domain.boundedcontexts.project.services.api; -import java.util.UUID; - import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.services.IResult; @@ -23,5 +21,5 @@ * @author sbegaudeau */ public interface IProjectDeletionService { - IResult deleteProject(ICause cause, UUID projectId); + IResult deleteProject(ICause cause, String projectId); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectSearchService.java index eceaa3deae..2733bba982 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectSearchService.java @@ -13,7 +13,6 @@ package org.eclipse.sirius.web.domain.boundedcontexts.project.services.api; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.eclipse.sirius.web.domain.boundedcontexts.project.services.Window; @@ -26,9 +25,9 @@ */ public interface IProjectSearchService { - boolean existsById(UUID projectId); + boolean existsById(String projectId); - Optional findById(UUID projectId); + Optional findById(String projectId); Window findAll(KeysetScrollPosition position, int limit); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectUpdateService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectUpdateService.java index 5ec7a213e9..655f48dc87 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectUpdateService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/project/services/api/IProjectUpdateService.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,8 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.web.domain.boundedcontexts.project.services.api; -import java.util.UUID; - import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.services.IResult; @@ -23,9 +21,9 @@ * @author sbegaudeau */ public interface IProjectUpdateService { - IResult renameProject(ICause cause, UUID projectId, String newName); + IResult renameProject(ICause cause, String projectId, String newName); - IResult addNature(ICause cause, UUID projectId, String natureName); + IResult addNature(ICause cause, String projectId, String natureName); - IResult removeNature(ICause cause, UUID projectId, String natureName); + IResult removeNature(ICause cause, String projectId, String natureName); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/ProjectImage.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/ProjectImage.java index 786ae8fd16..998c74a0b5 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/ProjectImage.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/ProjectImage.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 @@ -44,7 +44,7 @@ public class ProjectImage extends AbstractValidatingAggregateRoot private UUID id; @Column("project_id") - private AggregateReference project; + private AggregateReference project; private String label; @@ -111,7 +111,7 @@ public static Builder newProjectImage() { @SuppressWarnings("checkstyle:HiddenField") public static final class Builder { - private AggregateReference project; + private AggregateReference project; private String label; @@ -119,7 +119,7 @@ public static final class Builder { private byte[] content; - public Builder project(AggregateReference project) { + public Builder project(AggregateReference project) { this.project = Objects.requireNonNull(project); return this; } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/repositories/IProjectImageRepository.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/repositories/IProjectImageRepository.java index 5bec972195..9064540140 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/repositories/IProjectImageRepository.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/repositories/IProjectImageRepository.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 @@ -34,19 +34,19 @@ public interface IProjectImageRepository extends ListPagingAndSortingRepository< FROM project_image projectImage WHERE projectImage.project_id = :projectId """) - List findAllByProjectId(UUID projectId); + List findAllByProjectId(String projectId); @Query(""" SELECT * FROM project_image projectImage WHERE projectImage.project_id = :projectId """) - List findAllByProjectId(UUID projectId, Pageable pageable); + List findAllByProjectId(String projectId, Pageable pageable); @Query(""" SELECT count(*) FROM project_image projectImage WHERE projectImage.project_id = :projectId """) - long countByProjectId(UUID projectId); + long countByProjectId(String projectId); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/ProjectImageCreationService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/ProjectImageCreationService.java index 6858126817..eed43bbfa1 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/ProjectImageCreationService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/ProjectImageCreationService.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 @@ -18,7 +18,6 @@ import java.nio.file.Path; import java.util.Objects; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.boundedcontexts.projectimage.ProjectImage; @@ -49,7 +48,7 @@ public ProjectImageCreationService(IProjectImageRepository projectImageRepositor } @Override - public IResult createProjectImage(ICause cause, UUID projectId, String label, String fileName, InputStream inputStream) { + public IResult createProjectImage(ICause cause, String projectId, String label, String fileName, InputStream inputStream) { IResult result = null; var optionalContent = this.getContent(inputStream); diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/ProjectImageSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/ProjectImageSearchService.java index 40d29ffd92..a29f0d7c19 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/ProjectImageSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/ProjectImageSearchService.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 @@ -45,7 +45,7 @@ public Optional findById(UUID id) { } @Override - public Page findAll(UUID projectId, Pageable pageable) { + public Page findAll(String projectId, Pageable pageable) { var projectImages = this.projectImageRepository.findAllByProjectId(projectId, pageable); var count = this.projectImageRepository.countByProjectId(projectId); @@ -53,7 +53,7 @@ public Page findAll(UUID projectId, Pageable pageable) { } @Override - public List findAll(UUID projectId) { + public List findAll(String projectId) { return this.projectImageRepository.findAllByProjectId(projectId); } } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/api/IProjectImageCreationService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/api/IProjectImageCreationService.java index 2bf1e94d8a..297809dea2 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/api/IProjectImageCreationService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/api/IProjectImageCreationService.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 @@ -13,7 +13,6 @@ package org.eclipse.sirius.web.domain.boundedcontexts.projectimage.services.api; import java.io.InputStream; -import java.util.UUID; import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.boundedcontexts.projectimage.ProjectImage; @@ -25,5 +24,5 @@ * @author sbegaudeau */ public interface IProjectImageCreationService { - IResult createProjectImage(ICause cause, UUID projectId, String label, String fileName, InputStream inputStream); + IResult createProjectImage(ICause cause, String projectId, String label, String fileName, InputStream inputStream); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/api/IProjectImageSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/api/IProjectImageSearchService.java index e28836c431..aa051106fa 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/api/IProjectImageSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/projectimage/services/api/IProjectImageSearchService.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 @@ -28,7 +28,7 @@ public interface IProjectImageSearchService { Optional findById(UUID id); - Page findAll(UUID projectId, Pageable pageable); + Page findAll(String projectId, Pageable pageable); - List findAll(UUID projectId); + List findAll(String projectId); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationMetadata.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationMetadata.java index d3b651326a..16f653af77 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationMetadata.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/RepresentationMetadata.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 @@ -48,7 +48,7 @@ public class RepresentationMetadata extends AbstractValidatingAggregateRoot project; + private AggregateReference project; private String targetObjectId; @@ -72,7 +72,7 @@ public UUID getId() { return this.id; } - public AggregateReference getProject() { + public AggregateReference getProject() { return this.project; } @@ -153,7 +153,7 @@ public static final class Builder { private final UUID id; - private AggregateReference project; + private AggregateReference project; private String targetObjectId; @@ -171,7 +171,7 @@ public Builder(UUID id) { this.id = Objects.requireNonNull(id); } - public Builder project(AggregateReference project) { + public Builder project(AggregateReference project) { this.project = Objects.requireNonNull(project); return this; } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationMetadataRepository.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationMetadataRepository.java index 6e16f90b7c..986db4b2b4 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationMetadataRepository.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/repositories/IRepresentationMetadataRepository.java @@ -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 @@ -42,7 +42,7 @@ public interface IRepresentationMetadataRepository extends ListPagingAndSortingR FROM representation_metadata representationMetadata WHERE representationMetadata.project_id = :projectId """) - List findAllMetadataByProjectId(UUID projectId); + List findAllMetadataByProjectId(String projectId); @Query(""" SELECT representationMetadata.* @@ -50,14 +50,14 @@ public interface IRepresentationMetadataRepository extends ListPagingAndSortingR WHERE representationMetadata.target_object_id = :targetObjectId AND representationMetadata.project_id = :projectId """) - List findAllMetadataByProjectAndTargetObjectId(UUID projectId, String targetObjectId); + List findAllMetadataByProjectAndTargetObjectId(String projectId, String targetObjectId); @Query(""" SELECT representationMetadata.project_id FROM representation_metadata representationMetadata WHERE representationMetadata.id = :representationId """) - Optional findProjectIdFromRepresentationId(UUID representationId); + Optional findProjectIdFromRepresentationId(UUID representationId); @Query(""" SELECT CASE WHEN COUNT(*) > 0 THEN true ELSE false END diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataSearchService.java index 2e72b05368..85a2d864ce 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/RepresentationMetadataSearchService.java @@ -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 @@ -54,22 +54,22 @@ public boolean existsByIdAndKind(UUID id, List kinds) { } @Override - public List findAllMetadataByProject(AggregateReference project) { + public List findAllMetadataByProject(AggregateReference project) { return this.representationMetadataRepository.findAllMetadataByProjectId(project.getId()); } @Override - public List findAllMetadataByProjectAndTargetObjectId(AggregateReference project, String targetObjectId) { + public List findAllMetadataByProjectAndTargetObjectId(AggregateReference project, String targetObjectId) { return this.representationMetadataRepository.findAllMetadataByProjectAndTargetObjectId(project.getId(), targetObjectId); } @Override - public boolean existAnyRepresentationForProjectAndTargetObjectId(AggregateReference project, String targetObjectId) { + public boolean existAnyRepresentationForProjectAndTargetObjectId(AggregateReference project, String targetObjectId) { return this.representationMetadataRepository.existAnyRepresentationForTargetObjectId(targetObjectId); } @Override - public Optional> findProjectByRepresentationId(UUID representationId) { + public Optional> findProjectByRepresentationId(UUID representationId) { return this.representationMetadataRepository.findProjectIdFromRepresentationId(representationId) .map(AggregateReference::to); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataSearchService.java index 2e8558bb60..ec504b8a62 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataSearchService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/representationdata/services/api/IRepresentationMetadataSearchService.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 @@ -33,11 +33,11 @@ public interface IRepresentationMetadataSearchService { boolean existsByIdAndKind(UUID id, List kinds); - List findAllMetadataByProject(AggregateReference project); + List findAllMetadataByProject(AggregateReference project); - List findAllMetadataByProjectAndTargetObjectId(AggregateReference project, String targetObjectId); + List findAllMetadataByProjectAndTargetObjectId(AggregateReference project, String targetObjectId); - boolean existAnyRepresentationForProjectAndTargetObjectId(AggregateReference project, String targetObjectId); + boolean existAnyRepresentationForProjectAndTargetObjectId(AggregateReference project, String targetObjectId); - Optional> findProjectByRepresentationId(UUID representationId); + Optional> findProjectByRepresentationId(UUID representationId); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/SemanticData.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/SemanticData.java index 49b5951b34..82a77e1724 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/SemanticData.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/SemanticData.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 @@ -49,7 +49,7 @@ public class SemanticData extends AbstractValidatingAggregateRoot private UUID id; @Column("project_id") - private AggregateReference project; + private AggregateReference project; @MappedCollection(idColumn = "semantic_data_id") private Set documents = new LinkedHashSet<>(); @@ -66,7 +66,7 @@ public UUID getId() { return this.id; } - public AggregateReference getProject() { + public AggregateReference getProject() { return this.project; } @@ -159,13 +159,13 @@ public static Builder newSemanticData() { */ @SuppressWarnings("checkstyle:HiddenField") public static final class Builder { - private AggregateReference project; + private AggregateReference project; private Set documents = new LinkedHashSet<>(); private Set domains = new LinkedHashSet<>(); - public Builder project(AggregateReference project) { + public Builder project(AggregateReference project) { this.project = Objects.requireNonNull(project); return this; } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/repositories/ISemanticDataRepository.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/repositories/ISemanticDataRepository.java index 6d4172eaac..816554f07d 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/repositories/ISemanticDataRepository.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/repositories/ISemanticDataRepository.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 @@ -35,7 +35,7 @@ public interface ISemanticDataRepository extends ListPagingAndSortingRepository< FROM semantic_data semanticData WHERE semanticData.project_id = :projectId """) - Optional findByProjectId(UUID projectId); + Optional findByProjectId(String projectId); @Query(""" SELECT semanticData.* diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataCreationService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataCreationService.java index 4c0dd6ff1e..4e45bf3efd 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataCreationService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataCreationService.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 @@ -14,7 +14,6 @@ import java.util.Objects; import java.util.Set; -import java.util.UUID; import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; @@ -39,7 +38,7 @@ public SemanticDataCreationService(ISemanticDataRepository semanticDataRepositor } @Override - public void initialize(ICause cause, AggregateReference project) { + public void initialize(ICause cause, AggregateReference project) { var semanticData = SemanticData.newSemanticData() .project(project) .documents(Set.of()) diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataSearchService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataSearchService.java index c6fba1281f..6dcfe65757 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 @@ -15,7 +15,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.SemanticData; @@ -39,7 +38,7 @@ public SemanticDataSearchService(ISemanticDataRepository semanticDataRepository) } @Override - public Optional findByProject(AggregateReference project) { + public Optional findByProject(AggregateReference project) { return this.semanticDataRepository.findByProjectId(project.getId()); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataUpdateService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataUpdateService.java index d7cdef5de8..c4ec98a156 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataUpdateService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/SemanticDataUpdateService.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 @@ -14,7 +14,6 @@ import java.util.Objects; import java.util.Set; -import java.util.UUID; import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; @@ -39,7 +38,7 @@ public SemanticDataUpdateService(ISemanticDataRepository semanticDataRepository) } @Override - public void updateDocuments(ICause cause, AggregateReference project, Set documents, Set domainUris) { + public void updateDocuments(ICause cause, AggregateReference project, Set documents, Set domainUris) { this.semanticDataRepository.findByProjectId(project.getId()).ifPresent(semanticData -> { semanticData.updateDocuments(cause, documents, domainUris); this.semanticDataRepository.save(semanticData); diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataCreationService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataCreationService.java index 0ffec97aac..2f72ba52f9 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataCreationService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataCreationService.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,8 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api; -import java.util.UUID; - import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.springframework.data.jdbc.core.mapping.AggregateReference; @@ -24,5 +22,5 @@ * @author sbegaudeau */ public interface ISemanticDataCreationService { - void initialize(ICause cause, AggregateReference project); + void initialize(ICause cause, AggregateReference project); } 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..44b22e602f 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 @@ -14,7 +14,6 @@ import java.util.List; import java.util.Optional; -import java.util.UUID; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.SemanticData; @@ -27,7 +26,7 @@ */ public interface ISemanticDataSearchService { - Optional findByProject(AggregateReference project); + Optional findByProject(AggregateReference project); List findAllByDomains(List domainUris); } diff --git a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataUpdateService.java b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataUpdateService.java index f2fa66b633..ce3273abb5 100644 --- a/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataUpdateService.java +++ b/packages/sirius-web/backend/sirius-web-domain/src/main/java/org/eclipse/sirius/web/domain/boundedcontexts/semanticdata/services/api/ISemanticDataUpdateService.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 @@ -13,7 +13,6 @@ package org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api; import java.util.Set; -import java.util.UUID; import org.eclipse.sirius.components.events.ICause; import org.eclipse.sirius.web.domain.boundedcontexts.project.Project; @@ -26,5 +25,5 @@ * @author sbegaudeau */ public interface ISemanticDataUpdateService { - void updateDocuments(ICause cause, AggregateReference project, Set documents, Set domainUris); + void updateDocuments(ICause cause, AggregateReference project, Set documents, Set domainUris); } diff --git a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2025.2/01-alter_project_id_type.xml b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2025.2/01-alter_project_id_type.xml new file mode 100644 index 0000000000..58a4256be7 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2025.2/01-alter_project_id_type.xml @@ -0,0 +1,71 @@ + + + + + + + ALTER TABLE nature + drop constraint fk_nature_project_id; + + ALTER TABLE representation_metadata + drop constraint fk_representation_data_project_id; + + ALTER TABLE semantic_data + drop constraint fk_semantic_data_project_id; + + ALTER TABLE project_image + drop constraint fk_project_image_project_id; + + ALTER TABLE project + ALTER COLUMN id TYPE text; + + ALTER TABLE project_image + ALTER COLUMN project_id TYPE text; + + ALTER TABLE nature + ALTER COLUMN project_id TYPE text; + + ALTER TABLE semantic_data + ALTER COLUMN project_id TYPE text; + + ALTER TABLE representation_metadata + ALTER COLUMN project_id TYPE text; + + alter table nature + ADD constraint fk_nature_project_id + foreign key (project_id) references project (id) + ON DELETE CASCADE; + + alter table representation_metadata + ADD constraint fk_representation_data_project_id + foreign key (project_id) references project (id) + ON DELETE CASCADE; + + alter table semantic_data + ADD constraint fk_semantic_data_project_id + foreign key (project_id) references project (id) + ON DELETE CASCADE; + + alter table project_image + ADD constraint fk_project_image_project_id + foreign key (project_id) references project (id) + ON DELETE CASCADE; + + + + + \ No newline at end of file diff --git a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2025.2/2025.2.0.xml b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2025.2/2025.2.0.xml new file mode 100644 index 0000000000..b21e3fd6e2 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/changelog/2025.2/2025.2.0.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/db.changelog-master.xml b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/db.changelog-master.xml index 2a0009e87c..f3df66fdb0 100644 --- a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/db.changelog-master.xml +++ b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/resources/db/db.changelog-master.xml @@ -1,6 +1,6 @@