Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ The workbench view ID is now `related-views`.
- https://github.com/eclipse-sirius/sirius-web/issues/6041[#6041] [sirius-web] The method `IEditingDomainFactory#createEditingDomain` will now require the `editingContextId` to be used
- https://github.com/eclipse-sirius/sirius-web/issues/5910[#5910] [diagram] The `ReferencePosition` now uses a list of positions to take into account multiple drops.
- https://github.com/eclipse-sirius/sirius-web/issues/6101[#6101] [sirius-web] The `NewProjectCard` will now ask for a `url`
- https://github.com/eclipse-sirius/sirius-web/issues/5947[#5947] [sirius-web] Add support for publishing libraries from non-main editing contexts.
`PublishLibrariesInput#projectId` has been replaced with `PublishLibrariesInput#editingContextId`.
Note that the namespace of published libraries from studios still matches the `projectId` of the published studio.


=== Dependency update
Expand Down Expand Up @@ -267,6 +270,7 @@ The node action icons are now a little smaller and only appear after the node ha
The only difference is that this new marker has a second range of two dots after the first range.
- https://github.com/eclipse-sirius/sirius-web/issues/6101[#6101] [sirius-web] Allow more control of the redirect URL in the new project card
- https://github.com/eclipse-sirius/sirius-web/issues/5909[#5909] [graphql] Improve the customization of GraphQL error messages
- https://github.com/eclipse-sirius/sirius-web/issues/5947[#5947] [sirius-web] Add support for publishing libraries from non-main editing contexts.



Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* Copyright (c) 2025, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -23,6 +23,6 @@
*
* @author gdaniel
*/
public record PublishLibrariesInput(@NotNull UUID id, @NotNull String projectId, @NotNull String publicationKind, @NotNull String version, @NotNull String description) implements IInput {
public record PublishLibrariesInput(@NotNull UUID id, @NotNull String editingContextId, @NotNull String publicationKind, @NotNull String version, @NotNull String description) implements IInput {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* Copyright (c) 2025, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -32,10 +32,8 @@
import org.eclipse.sirius.web.application.studio.services.library.api.DependencyGraph;
import org.eclipse.sirius.web.application.studio.services.library.api.IStudioLibraryDependencyCollector;
import org.eclipse.sirius.web.application.studio.services.library.api.IStudioLibrarySemanticDataCreationService;
import org.eclipse.sirius.web.domain.boundedcontexts.projectsemanticdata.services.api.IProjectSemanticDataSearchService;
import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.SemanticData;
import org.eclipse.sirius.web.domain.services.api.IMessageService;
import org.springframework.data.jdbc.core.mapping.AggregateReference;
import org.springframework.stereotype.Service;

/**
Expand All @@ -50,16 +48,14 @@ public class StudioLibraryPublicationHandler implements ILibraryPublicationHandl

private final IStudioLibraryDependencyCollector studioLibraryDependencyCollector;

private final IProjectSemanticDataSearchService projectSemanticDataSearchService;

private final IStudioLibrarySemanticDataCreationService studioLibrarySemanticDataCreationService;

private final IMessageService messageService;

public StudioLibraryPublicationHandler(IEditingContextSearchService editingContextSearchService, IStudioLibraryDependencyCollector studioLibraryDependencyCollector, IProjectSemanticDataSearchService projectSemanticDataSearchService, IStudioLibrarySemanticDataCreationService studioLibrarySemanticDataCreationService, IMessageService messageService) {
public StudioLibraryPublicationHandler(IEditingContextSearchService editingContextSearchService, IStudioLibraryDependencyCollector studioLibraryDependencyCollector,
IStudioLibrarySemanticDataCreationService studioLibrarySemanticDataCreationService, IMessageService messageService) {
this.editingContextSearchService = Objects.requireNonNull(editingContextSearchService);
this.studioLibraryDependencyCollector = Objects.requireNonNull(studioLibraryDependencyCollector);
this.projectSemanticDataSearchService = Objects.requireNonNull(projectSemanticDataSearchService);
this.studioLibrarySemanticDataCreationService = Objects.requireNonNull(studioLibrarySemanticDataCreationService);
this.messageService = Objects.requireNonNull(messageService);
}
Expand All @@ -73,8 +69,7 @@ public boolean canHandle(PublishLibrariesInput input) {
public IPayload handle(PublishLibrariesInput input) {
IPayload result = new ErrorPayload(input.id(), this.messageService.unexpectedError());

Optional<IEMFEditingContext> optionalEditingContext = this.projectSemanticDataSearchService.findByProjectId(AggregateReference.to(input.projectId()))
.flatMap(projectSemanticData -> this.editingContextSearchService.findById(projectSemanticData.getSemanticData().getId().toString()))
Optional<IEMFEditingContext> optionalEditingContext = this.editingContextSearchService.findById(input.editingContextId())
.filter(IEMFEditingContext.class::isInstance)
.map(IEMFEditingContext.class::cast);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* Copyright (c) 2025, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -12,10 +12,16 @@
*******************************************************************************/
package org.eclipse.sirius.web.application.studio.services.library;

import java.util.Objects;
import java.util.Optional;

import org.eclipse.sirius.web.application.library.dto.PublishLibrariesInput;
import org.eclipse.sirius.web.application.project.services.api.IProjectEditingContextService;
import org.eclipse.sirius.web.domain.boundedcontexts.library.Library;
import org.eclipse.sirius.web.domain.boundedcontexts.library.services.api.ILibraryCreationService;
import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.events.SemanticDataCreatedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.jdbc.core.mapping.AggregateReference;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
Expand All @@ -32,8 +38,14 @@ public class StudioLibraryPublicationListener {

private final ILibraryCreationService libraryCreationService;

public StudioLibraryPublicationListener(ILibraryCreationService libraryCreationService) {
this.libraryCreationService = libraryCreationService;
private final IProjectEditingContextService projectEditingContextService;

private final Logger logger = LoggerFactory.getLogger(StudioLibraryPublicationListener.class);


public StudioLibraryPublicationListener(ILibraryCreationService libraryCreationService, IProjectEditingContextService projectEditingContextService) {
this.libraryCreationService = Objects.requireNonNull(libraryCreationService);
this.projectEditingContextService = Objects.requireNonNull(projectEditingContextService);
}

@Transactional(propagation = Propagation.REQUIRES_NEW)
Expand All @@ -42,14 +54,20 @@ public void onSemanticDataCreatedEvent(SemanticDataCreatedEvent semanticDataCrea
if (semanticDataCreatedEvent.causedBy() instanceof StudioLibrarySemanticDataCreationRequested request && request.causedBy() instanceof PublishLibrariesInput publishLibrariesInput) {
var semanticData = semanticDataCreatedEvent.semanticData();

Library library = Library.newLibrary()
.namespace(publishLibrariesInput.projectId())
.name(request.libraryName())
.semanticData(AggregateReference.to(semanticData.getId()))
.version(publishLibrariesInput.version())
.description(publishLibrariesInput.description())
.build(semanticDataCreatedEvent);
this.libraryCreationService.createLibrary(library);
Optional<String> optionalProjectId = this.projectEditingContextService.getProjectId(publishLibrariesInput.editingContextId());

if (optionalProjectId.isPresent()) {
Library library = Library.newLibrary()
.namespace(optionalProjectId.get())
.name(request.libraryName())
.semanticData(AggregateReference.to(semanticData.getId()))
.version(publishLibrariesInput.version())
.description(publishLibrariesInput.description())
.build(semanticDataCreatedEvent);
this.libraryCreationService.createLibrary(library);
} else {
this.logger.warn("No project found for editing context {}", publishLibrariesInput.editingContextId());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* Copyright (c) 2025, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -36,13 +36,16 @@
import org.eclipse.sirius.web.application.editingcontext.services.api.IResourceToDocumentService;
import org.eclipse.sirius.web.application.library.dto.PublishLibrariesInput;
import org.eclipse.sirius.web.application.library.services.LibraryMetadataAdapter;
import org.eclipse.sirius.web.application.project.services.api.IProjectEditingContextService;
import org.eclipse.sirius.web.application.studio.services.library.api.DependencyGraph;
import org.eclipse.sirius.web.application.studio.services.library.api.IStudioLibrarySemanticDataCreationService;
import org.eclipse.sirius.web.domain.boundedcontexts.library.services.api.ILibrarySearchService;
import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.SemanticData;
import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataCreationService;
import org.eclipse.sirius.web.domain.services.IResult;
import org.eclipse.sirius.web.domain.services.Success;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.jdbc.core.mapping.AggregateReference;
import org.springframework.stereotype.Service;

Expand All @@ -62,12 +65,17 @@ public class StudioLibrarySemanticDataCreationService implements IStudioLibraryS

private final ILibrarySearchService librarySearchService;

public StudioLibrarySemanticDataCreationService(IIdentityService identityService, IResourceToDocumentService resourceToDocumentService, ISemanticDataCreationService semanticDataCreationService, ILibrarySearchService librarySearchService) {
private final IProjectEditingContextService projectEditingContextService;

private final Logger logger = LoggerFactory.getLogger(StudioLibrarySemanticDataCreationService.class);

public StudioLibrarySemanticDataCreationService(IIdentityService identityService, IResourceToDocumentService resourceToDocumentService, ISemanticDataCreationService semanticDataCreationService,
ILibrarySearchService librarySearchService, IProjectEditingContextService projectEditingContextService) {
this.identityService = Objects.requireNonNull(identityService);
this.resourceToDocumentService = Objects.requireNonNull(resourceToDocumentService);
this.semanticDataCreationService = Objects.requireNonNull(semanticDataCreationService);
this.librarySearchService = Objects.requireNonNull(librarySearchService);

this.projectEditingContextService = Objects.requireNonNull(projectEditingContextService);
}

@Override
Expand All @@ -86,9 +94,14 @@ public Collection<SemanticData> createSemanticData(PublishLibrariesInput input,
} else {
// The shared component contains all its elements in its root, and its content may vary between version,
// it is more stable to use a fixed name as the resource identifier.
String resourceId = input.projectId() + ":" + "shared_components";
Resource sharedComponentsResource = this.getOrCreateLibraryResource("shared_components", resourceId, resourceSet);
sharedComponentsResource.getContents().add(libraryCandidate);
Optional<String> optionalProjectId = this.projectEditingContextService.getProjectId(input.editingContextId());
if (optionalProjectId.isPresent()) {
String resourceId = optionalProjectId.get() + ":" + "shared_components";
Resource sharedComponentsResource = this.getOrCreateLibraryResource("shared_components", resourceId, resourceSet);
sharedComponentsResource.getContents().add(libraryCandidate);
} else {
this.logger.warn("No project found for editing context {}", input.editingContextId());
}
}
}
}
Expand Down Expand Up @@ -174,9 +187,9 @@ private List<AggregateReference<SemanticData, UUID>> getDependencies(DependencyG
List<AggregateReference<SemanticData, UUID>> dependencies = new ArrayList<>();
for (EObject dependencyCandidate : dependencyGraph.getDependencies(libraryCandidate)) {
Optional<LibraryMetadataAdapter> optLibraryMetadata = dependencyCandidate.eResource().eAdapters().stream()
.filter(LibraryMetadataAdapter.class::isInstance)
.map(LibraryMetadataAdapter.class::cast)
.findFirst();
.filter(LibraryMetadataAdapter.class::isInstance)
.map(LibraryMetadataAdapter.class::cast)
.findFirst();
if (optLibraryMetadata.isPresent()) {
LibraryMetadataAdapter libraryMetadata = optLibraryMetadata.get();
this.librarySearchService.findByNamespaceAndNameAndVersion(libraryMetadata.getNamespace(), libraryMetadata.getName(), libraryMetadata.getVersion())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extend type EditingContext {

input PublishLibrariesInput {
id: ID!
projectId: ID!
editingContextId: ID!
publicationKind: String!
version: String!
description: String!
Expand All @@ -72,4 +72,4 @@ input UpdateLibraryInput {
libraryId: String!
}

union UpdateLibraryPayload = ErrorPayload | SuccessPayload
union UpdateLibraryPayload = ErrorPayload | SuccessPayload
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* Copyright (c) 2025, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -149,15 +149,15 @@ public void givenSetOfLibrariesWhenQueryIsPerformedThenTheLibrariesAreReturned()

@Test
@GivenSiriusWebServer
@DisplayName("Given a valid studio project ID, when the publication mutation is performed, then the libraries are published")
public void givenValidStudioProjectIdWhenPublicationMutationIsPerformedThenLibrariesArePublished() {
@DisplayName("Given a valid studio editing context ID, when the publication mutation is performed, then the libraries are published")
public void givenValidStudioEditingContextIdWhenPublicationMutationIsPerformedThenLibrariesArePublished() {
var page = this.librarySearchService.findAll(PageRequest.of(0, 10));
long initialLibraryCount = page.getTotalElements();

String version = "0.0.1";
String description = "Initial version";

var input = new PublishLibrariesInput(UUID.randomUUID(), StudioIdentifiers.SAMPLE_STUDIO_PROJECT, "studio-all", version, description);
var input = new PublishLibrariesInput(UUID.randomUUID(), StudioIdentifiers.SAMPLE_STUDIO_EDITING_CONTEXT_ID, "studio-all", version, description);
var result = this.publishLibrariesMutationRunner.run(input);
TestTransaction.flagForCommit();
TestTransaction.end();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* Copyright (c) 2025, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -66,7 +66,7 @@ export const PublishLibraryDialog = ({ open, title, message, publicationKind, on
const { project } = useCurrentProject();

const handlePublish = () => {
publishLibraries(project.id, publicationKind, state.version, state.description);
publishLibraries(project.currentEditingContext.id, publicationKind, state.version, state.description);
};

const isVersionInvalid = state.version.trim().length === 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* Copyright (c) 2025, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -71,11 +71,16 @@ export const usePublishLibraries = (): UsePublishLibrariesValue => {
}
}, [error, data]);

const publishLibraries = (projectId: string, publicationKind: string, version: string, description: string) => {
const publishLibraries = (
editingContextId: string,
publicationKind: string,
version: string,
description: string
) => {
const variables: GQLPublishLibrariesMutationVariables = {
input: {
id: crypto.randomUUID(),
projectId,
editingContextId,
publicationKind,
version,
description,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Obeo.
* Copyright (c) 2025, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -25,7 +25,7 @@ export interface GQLPublishLibrariesMutationVariables {

export interface GQLPublishLibrariesMutationInput {
id: string;
projectId: string;
editingContextId: string;
publicationKind: string;
version: string;
description: string;
Expand Down
Loading