diff --git a/backend/sirius-web-spring-collaborative-diagrams/src/main/java/org/eclipse/sirius/web/spring/collaborative/diagrams/ToolService.java b/backend/sirius-web-spring-collaborative-diagrams/src/main/java/org/eclipse/sirius/web/spring/collaborative/diagrams/ToolService.java deleted file mode 100644 index dc24230ee7..0000000000 --- a/backend/sirius-web-spring-collaborative-diagrams/src/main/java/org/eclipse/sirius/web/spring/collaborative/diagrams/ToolService.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 2020 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 - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.eclipse.sirius.web.spring.collaborative.diagrams; - -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -import org.eclipse.sirius.web.core.api.IRepresentationDescriptionSearchService; -import org.eclipse.sirius.web.diagrams.Diagram; -import org.eclipse.sirius.web.diagrams.description.DiagramDescription; -import org.eclipse.sirius.web.diagrams.tools.ITool; -import org.eclipse.sirius.web.diagrams.tools.ToolSection; -import org.eclipse.sirius.web.spring.collaborative.diagrams.api.IToolService; -import org.springframework.stereotype.Service; - -/** - * Class used to manipulate tools and tool sections. - * - * @author hmarchadour - */ -@Service -public class ToolService implements IToolService { - - private final IRepresentationDescriptionSearchService representationDescriptionSearchService; - - public ToolService(IRepresentationDescriptionSearchService representationDescriptionSearchService) { - this.representationDescriptionSearchService = Objects.requireNonNull(representationDescriptionSearchService); - } - - @Override - public List getToolSections(Diagram diagram) { - // @formatter:off - return this.representationDescriptionSearchService.findById(diagram.getDescriptionId()) - .filter(DiagramDescription.class::isInstance) - .map(DiagramDescription.class::cast) - .map(DiagramDescription::getToolSections) - .orElse(List.of()); - // @formatter:on - } - - @Override - public Optional findToolById(Diagram diagram, String toolId) { - // @formatter:off - return this.getToolSections(diagram) - .stream() - .map(ToolSection::getTools) - .flatMap(Collection::stream) - .filter(tool -> Objects.equals(tool.getId(), toolId)) - .findFirst(); - // @formatter:on - } - -} diff --git a/backend/sirius-web-spring-collaborative-diagrams/src/main/java/org/eclipse/sirius/web/spring/collaborative/diagrams/api/IToolService.java b/backend/sirius-web-spring-collaborative-diagrams/src/main/java/org/eclipse/sirius/web/spring/collaborative/diagrams/api/IToolService.java deleted file mode 100644 index 93da0f0403..0000000000 --- a/backend/sirius-web-spring-collaborative-diagrams/src/main/java/org/eclipse/sirius/web/spring/collaborative/diagrams/api/IToolService.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 2020 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 - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.eclipse.sirius.web.spring.collaborative.diagrams.api; - -import java.util.List; -import java.util.Optional; - -import org.eclipse.sirius.web.diagrams.Diagram; -import org.eclipse.sirius.web.diagrams.tools.ITool; -import org.eclipse.sirius.web.diagrams.tools.ToolSection; - -/** - * Interface used to manipulate tools. - * - * @author hmarchadour - */ -public interface IToolService { - - /** - * Find a specific tool according to the given diagram and tool identifiers. - * - * @param diagram - * the diagram - * @param toolId - * the tool identifier - */ - Optional findToolById(Diagram diagram, String toolId); - - /** - * Get all tool sections available in a specific diagram. - * - * @param diagram - * the diagram - */ - List getToolSections(Diagram diagram); - -}