From 319b9ecf6bdbf98fa6f186790096111dcfaf0012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Fuch=C3=9F?= Date: Wed, 21 Aug 2024 09:17:41 +0200 Subject: [PATCH] Remove Diagrams from Core (#391) --- .../ardoco/core/api/InputDiagramData.java | 79 ---- .../DiagramMatchingModelSelectionState.java | 123 ------- .../DiagramModelInconsistencyState.java | 56 --- .../DiagramModelLinkState.java | 38 -- .../api/diagramconsistency/DiagramState.java | 30 -- .../common/DiagramUtility.java | 127 ------- .../api/diagramconsistency/common/Edge.java | 37 -- .../common/ElementRole.java | 30 -- .../common/Extractions.java | 165 --------- .../api/diagramconsistency/common/Label.java | 18 - .../common/TextSimilarity.java | 96 ----- .../common/Transformations.java | 343 ------------------ .../api/diagramconsistency/common/Vertex.java | 64 ---- .../common/WeightedTextSimilarity.java | 115 ------ .../HierarchyInconsistency.java | 80 ---- .../common/inconsistencies/Inconsistency.java | 104 ------ .../inconsistencies/InconsistencyType.java | 34 -- .../MissingBoxInconsistency.java | 39 -- .../MissingLineInconsistency.java | 76 ---- .../inconsistencies/NameInconsistency.java | 82 ----- .../UnexpectedBoxInconsistency.java | 39 -- .../UnexpectedLineInconsistency.java | 76 ---- .../inconsistencies/refinement/Casing.java | 114 ------ .../inconsistencies/refinement/Group.java | 70 ---- .../refinement/LineInversion.java | 117 ------ .../refinement/NameExtension.java | 129 ------- .../inconsistencies/refinement/Swap.java | 117 ------ .../rules/AllBoxesMustBeLinked.java | 23 -- .../AllModelEntitiesMustBeRepresented.java | 24 -- .../rules/BoxesMustBeInParent.java | 80 ---- ...sMustBeConnectedExactlyToDependencies.java | 70 ---- ...MustContainAllSubpackagesIfOneIsEmpty.java | 92 ----- .../common/inconsistencies/rules/Rule.java | 84 ----- .../rules/SameNameForLinkedElements.java | 28 -- .../similarityflooding/FixpointFormula.java | 120 ------ .../similarityflooding/LabeledEdge.java | 17 - .../similarityflooding/MatchingFilter.java | 25 -- .../OrderedMatchingFilter.java | 108 ------ .../PropagationCoefficientFormula.java | 63 ---- .../SimilarityFloodingAlgorithm.java | 281 -------------- .../similarityflooding/SimilarityMapping.java | 148 -------- .../api/diagramrecognition/BoundingBox.java | 152 -------- .../core/api/diagramrecognition/Box.java | 286 --------------- .../diagramrecognition/Classification.java | 36 -- .../api/diagramrecognition/Connector.java | 36 -- .../core/api/diagramrecognition/Diagram.java | 70 ---- .../diagramrecognition/DiagramElement.java | 119 ------ .../DiagramRecognitionState.java | 61 ---- .../api/diagramrecognition/DiagramUtil.java | 87 ----- .../core/api/diagramrecognition/TextBox.java | 120 ------ .../DiagramGoldStandardTraceLink.java | 91 ----- .../diagrams/DiagramTextTraceLink.java | 92 ----- .../diagrams/DiagramWordTraceLink.java | 114 ------ .../models/tracelinks/diagrams/TraceType.java | 31 -- .../common/util/DataRepositoryHelper.java | 37 -- 55 files changed, 4893 deletions(-) delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/InputDiagramData.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramMatchingModelSelectionState.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelInconsistencyState.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelLinkState.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramState.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/DiagramUtility.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/Edge.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/ElementRole.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/Extractions.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/Label.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/TextSimilarity.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/Transformations.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/Vertex.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/WeightedTextSimilarity.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/HierarchyInconsistency.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/Inconsistency.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/InconsistencyType.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/MissingBoxInconsistency.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/MissingLineInconsistency.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/NameInconsistency.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/UnexpectedBoxInconsistency.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/UnexpectedLineInconsistency.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/refinement/Casing.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/refinement/Group.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/refinement/LineInversion.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/refinement/NameExtension.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/refinement/Swap.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/rules/AllBoxesMustBeLinked.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/rules/AllModelEntitiesMustBeRepresented.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/rules/BoxesMustBeInParent.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/rules/EntitiesMustBeConnectedExactlyToDependencies.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/rules/PackagesMustContainAllSubpackagesIfOneIsEmpty.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/rules/Rule.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/inconsistencies/rules/SameNameForLinkedElements.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/similarityflooding/FixpointFormula.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/similarityflooding/LabeledEdge.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/similarityflooding/MatchingFilter.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/similarityflooding/OrderedMatchingFilter.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/similarityflooding/PropagationCoefficientFormula.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/similarityflooding/SimilarityFloodingAlgorithm.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/similarityflooding/SimilarityMapping.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/BoundingBox.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/Box.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/Classification.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/Connector.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/Diagram.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/DiagramElement.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/DiagramRecognitionState.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/DiagramUtil.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramrecognition/TextBox.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/diagrams/DiagramGoldStandardTraceLink.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/diagrams/DiagramTextTraceLink.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/diagrams/DiagramWordTraceLink.java delete mode 100644 framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/diagrams/TraceType.java diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/InputDiagramData.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/InputDiagramData.java deleted file mode 100644 index 7b6fe9ab3..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/InputDiagramData.java +++ /dev/null @@ -1,79 +0,0 @@ -/* Licensed under MIT 2023-2024. */ -package edu.kit.kastel.mcse.ardoco.core.api; - -import java.io.File; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; - -import edu.kit.kastel.mcse.ardoco.core.common.tuple.Pair; -import edu.kit.kastel.mcse.ardoco.core.data.PipelineStepData; - -/** - * This {@link PipelineStepData} gives access to diagrams associated with the project to analyze. - */ -public class InputDiagramData implements PipelineStepData { - public static final String ID = "InputDiagramData"; - private static final List ALLOWED_FILE_TYPES = List.of("jpg", "png", "jpeg"); - - private String pathToDiagrams; - - private List> diagramFiles; - - /** - * Create the data by a directory of image files. - * - * @param pathToDiagrams the path to a directory containing diagrams and sketches - */ - public InputDiagramData(String pathToDiagrams) { - this.pathToDiagrams = Objects.requireNonNull(pathToDiagrams); - } - - /** - * Create the data by a directory of image files. - * - * @param diagramDirectory the directory containing diagrams and sketches - */ - public InputDiagramData(File diagramDirectory) { - this(Objects.requireNonNull(diagramDirectory).getAbsolutePath()); - } - - /** - * Create the data by a list of image files. - * - * @param diagramFiles the diagram files - */ - public InputDiagramData(List> diagramFiles) { - Objects.requireNonNull(diagramFiles); - this.diagramFiles = diagramFiles; - } - - /** - * Get all image files of the given directory (not recursive). - * - * @return a list of image files ordered by name - */ - public List> getDiagramData() { - if (diagramFiles != null) - return diagramFiles; - if (pathToDiagrams == null) - return List.of(); - File directoryOfDiagrams = new File(pathToDiagrams); - if (!directoryOfDiagrams.exists() || !directoryOfDiagrams.isDirectory()) { - return List.of(); - } - File[] allFiles = directoryOfDiagrams.listFiles(); - if (allFiles == null) - return List.of(); - List> diagrams = Arrays.stream(allFiles) - .filter(File::isFile) - .filter(f -> ALLOWED_FILE_TYPES.stream().anyMatch(t -> f.getName().toLowerCase().endsWith("." + t))) - .sorted(Comparator.comparing(File::getName)) - .map(f -> new Pair<>(f.getName(), f)) - .toList(); - logger.info("Found {} diagrams to consider.", diagrams.size()); - return diagrams; - } - -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramMatchingModelSelectionState.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramMatchingModelSelectionState.java deleted file mode 100644 index d3f26c23e..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramMatchingModelSelectionState.java +++ /dev/null @@ -1,123 +0,0 @@ -/* Licensed under MIT 2023. */ -package edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency.common.ElementRole; -import edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency.common.WeightedTextSimilarity; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelType; -import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic; -import edu.kit.kastel.mcse.ardoco.core.data.PipelineStepData; - -/** - * Stores data created during the model selection process, as well as the selection itself. The data includes a created - * text similarity function and all occurrences of diagram elements in models. - */ -@Deterministic -public interface DiagramMatchingModelSelectionState extends PipelineStepData { - /** - * The ID of this state. - */ - String ID = "DiagramMatchingModelSelectionState"; - - /** - * Gets the model types that are in principle available, meaning their loading is attempted. - * - * @return The model types. - */ - Set getAvailableModelTypes(); - - /** - * Sets the model types that are in principle available, meaning their loading is attempted. - * - * @param availableModelTypes - * The model types. - */ - void setAvailableModelTypes(Set availableModelTypes); - - /** - * Gets the similarity function. - * - * @return The similarity function. - */ - WeightedTextSimilarity getSimilarityFunction(); - - /** - * Sets the similarity function. - * - * @param similarity - * The similarity function. - */ - void setSimilarityFunction(WeightedTextSimilarity similarity); - - /** - * Gets the model type that is selected to be matched with the diagram. - * - * @return The model type. - */ - Set getSelection(); - - /** - * Sets the models that are selected to be matched with the diagram. - * - * @param modelTypes - * The model types. - */ - void setSelection(Set modelTypes); - - /** - * Adds an occurrence of a diagram element in a model. - * - * @param diagramID The ID of the diagram element. - * @param modelType The model the model element is in. - * @param modelID The ID of the model element. - * @param role The role of the model element. - */ - void addOccurrence(String diagramID, ModelType modelType, String modelID, ElementRole role); - - /** - * Get all occurrences of a diagram element in a model. - * - * @param diagramID The ID of the diagram element. - * @param modelType The model to get the occurrences in. - * @return The occurrences. - */ - List getOccurrences(String diagramID, ModelType modelType); - - /** - * Get all occurrences of a diagram element in all models. - * - * @param diagramID - * The ID of the diagram element. - * @return The occurrences. - */ - List getOccurrences(String diagramID); - - /** - * Gets the explanation why the model type was selected. - * - * @return The explanation, which is a match value for each model type. - */ - Map getSelectionExplanation(); - - /** - * Sets the explanation why the model type was selected. - * - * @param explanation - * The explanation, which is a match value for each model type. - */ - void setSelectionExplanation(Map explanation); - - /** - * Describes an occurrence of a diagram element in a model. - * - * @param modelID - * The ID of the model element. - * @param role - * The role of the model element. - */ - public record Occurrence(String modelID, ElementRole role) { - } -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelInconsistencyState.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelInconsistencyState.java deleted file mode 100644 index 229005521..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelInconsistencyState.java +++ /dev/null @@ -1,56 +0,0 @@ -/* Licensed under MIT 2023. */ -package edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency; - -import java.util.List; - -import edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency.common.inconsistencies.Inconsistency; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelType; -import edu.kit.kastel.mcse.ardoco.core.data.PipelineStepData; - -/** - * Contains information about found inconsistencies between the diagram and the given models. - */ -public interface DiagramModelInconsistencyState extends PipelineStepData { - /** - * The ID of this state. - */ - String ID = "DiagramModelInconsistencyState"; - - /** - * Adds an inconsistency. - * - * @param modelType The model type to add the inconsistency for. - * @param inconsistency - * The inconsistency to add. - */ - void addInconsistency(ModelType modelType, Inconsistency inconsistency); - - /** - * Returns all found inconsistencies. - * - * @param modelType The model type to get inconsistencies for. - * @return All inconsistencies. - */ - List> getInconsistencies(ModelType modelType); - - /** - * Set the extended inconsistencies. The extended inconsistency list is based on the basic inconsistency list but a - * larger selection of more concrete inconsistency types can be used. - * - * @param modelType - * The model type to set the inconsistencies for. - * @param inconsistencies - * The inconsistencies to set. - */ - void setExtendedInconsistencies(ModelType modelType, List> inconsistencies); - - /** - * Returns the extended inconsistencies. If no extended inconsistencies are set, the basic inconsistencies are - * returned. - * - * @param modelType - * The model type to get the inconsistencies for. - * @return The extended inconsistencies. - */ - List> getExtendedInconsistencies(ModelType modelType); -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelLinkState.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelLinkState.java deleted file mode 100644 index e4f4ced87..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelLinkState.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Licensed under MIT 2023. */ -package edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency; - -import org.eclipse.collections.api.bimap.MutableBiMap; - -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelType; -import edu.kit.kastel.mcse.ardoco.core.data.PipelineStepData; - -/** - * Stores all results of the matching process. - */ -public interface DiagramModelLinkState extends PipelineStepData { - /** - * The ID of this state. - */ - String ID = "DiagramModelLinkState"; - - /** - * Adds a link between a diagram element and a model element. - * - * @param modelType - * The model type of the model in which the model element is located. - * @param diagramID - * The ID of the diagram element. - * @param modelID - * The ID of the model element. - */ - void addLink(ModelType modelType, String diagramID, String modelID); - - /** - * Get all currently stored links between the diagram and a model. - * - * @param modelType - * The type of the model. - * @return The links. - */ - MutableBiMap getLinks(ModelType modelType); -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramState.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramState.java deleted file mode 100644 index 41eafae42..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramState.java +++ /dev/null @@ -1,30 +0,0 @@ -/* Licensed under MIT 2023. */ -package edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency; - -import edu.kit.kastel.mcse.ardoco.core.api.diagramrecognition.Diagram; -import edu.kit.kastel.mcse.ardoco.core.data.PipelineStepData; - -/** - * Contains the loaded diagram. - */ -public interface DiagramState extends PipelineStepData { - /** - * The ID in the data repository. - */ - String ID = "DiagramStateData"; - - /** - * Returns the diagram. - * - * @return The diagram. May be null. - */ - Diagram getDiagram(); - - /** - * Sets the diagram. Overwrites the old diagram. - * - * @param diagram - * The diagram. - */ - void setDiagram(Diagram diagram); -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/DiagramUtility.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/DiagramUtility.java deleted file mode 100644 index 2c9b33d66..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/DiagramUtility.java +++ /dev/null @@ -1,127 +0,0 @@ -/* Licensed under MIT 2023-2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency.common; - -import java.util.List; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.UUID; -import java.util.stream.Collectors; - -import edu.kit.kastel.mcse.ardoco.core.api.diagramrecognition.Box; -import edu.kit.kastel.mcse.ardoco.core.api.diagramrecognition.Connector; -import edu.kit.kastel.mcse.ardoco.core.api.diagramrecognition.Diagram; -import edu.kit.kastel.mcse.ardoco.core.api.diagramrecognition.TextBox; -import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic; - -/** - * This class contains utility methods to use with the diagram interface. - */ -@Deterministic -public class DiagramUtility { - private DiagramUtility() { - } - - /** - * Checks if there is a connection between the two boxes. - * - * @param diagram The diagram in which the boxes are located. - * @param source The source box. - * @param target The target box. - * @return True if there is a connection between the two boxes, false otherwise. - */ - public static boolean hasConnectionBetween(Diagram diagram, Box source, Box target) { - return diagram.getConnectors().stream().anyMatch(connector -> isConnectionBetween(connector, source, target)); - } - - /** - * Checks if the connector connects the two boxes. - * - * @param connector The connector to check. - * @param source The source box. - * @param target The target box. - * @return True if the connector connects the two boxes, false otherwise. - */ - public static boolean isConnectionBetween(Connector connector, Box source, Box target) { - List connectedBoxes = connector.getConnectedBoxes(); - return connectedBoxes.get(0).equals(source.getUUID()) && connectedBoxes.contains(target.getUUID()); - } - - /** - * Returns all connectors that are outgoing from the box. - * - * @param diagram The diagram in which the box is located. - * @param box The box. - * @return All connectors that are outgoing from the box. - */ - public static List getOutgoingConnectors(Diagram diagram, Box box) { - return diagram.getConnectors().stream().filter(connector -> connector.getConnectedBoxes().get(0).equals(box.getUUID())).toList(); - } - - /** - * Get a map of all boxes in the diagram. - * - * @param diagram The diagram. - * @return A map from the UUID of the box to the box. - */ - public static SortedMap getBoxes(Diagram diagram) { - return diagram.getBoxes().stream().collect(Collectors.toMap(Box::getUUID, box -> box, (a, b) -> b, TreeMap::new)); - } - - /** - * Get the targets of the connector. - * - * @param connector The connector. - * @param boxes A UUID-box map. - * @return The targets of the connector. - */ - public static List getTargets(Connector connector, SortedMap boxes) { - return connector.getConnectedBoxes().stream().skip(1).map(boxes::get).toList(); - } - - /** - * Get the text of the box. - * - * @param box The box. - * @return The text of the box. - */ - public static String getBoxText(Box box) { - return box.getTexts().stream().map(TextBox::getText).collect(Collectors.joining(" ")); - } - - /** - * Get the contained boxes of the box. - * - * @param box The box. - * @param boxes A UUID-box map. - * @return The contained boxes of the box. - */ - public static List getContainedBoxes(Box box, SortedMap boxes) { - return box.getContainedBoxes().stream().map(boxes::get).toList(); - } - - /** - * Add a box to the diagram. - * - * @param diagram The diagram. - * @param text The text of the box. - * @return The added box. - */ - public static Box addBox(Diagram diagram, String text) { - TextBox textBox = new TextBox(0, 0, 0, 0, 1.0, text, null); - Box box = new Box(diagram, String.valueOf(diagram.getBoxes().size()), new int[] { 0, 0, 0, 0 }, 1.0, null, List.of(textBox), null); - - diagram.addBox(box); - return box; - } - - /** - * Add a connector between the two boxes. - * - * @param diagram The diagram in which the boxes are located. - * @param source The source box. - * @param target The target box. - */ - public static void addConnector(Diagram diagram, Box source, Box target) { - diagram.addConnector(new Connector(UUID.randomUUID().toString(), List.of(source.getUUID(), target.getUUID()), List.of())); - } -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/Edge.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/Edge.java deleted file mode 100644 index d6b7545a3..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/Edge.java +++ /dev/null @@ -1,37 +0,0 @@ -/* Licensed under MIT 2023. */ -package edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency.common; - -import org.jgrapht.graph.DefaultEdge; - -import edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency.common.similarityflooding.LabeledEdge; - -/** - * The edge type used in the graphs that are matched. - */ -public class Edge extends DefaultEdge implements LabeledEdge