-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add informal diagram consistency pipeline steps (#308)
* Adapt code model to support nested classes * Extend code model to store references of types to other types * Move code from thesis repo into ArDoCo core * Fix some test * Merge the two existing diagram classes * Fix the large graph test * Fix version name * Update stages/diagram-consistency/pom.xml Co-authored-by: Dominik Fuchß <develop@fuchss.org> * Adapt pom.xml files as reviewed and adapt to changes related to package structure * Update framework/common/pom.xml * Apply spotless * Reset benchmark * Squashed 'tests/tests-base/src/main/resources/benchmark/' changes from 7675243a..daeaee7e daeaee7e Update code models to contain parent class and reference info (#12) 4fae195e Format Code Model. Fix #13 814aa945 Remove duplicate in GS git-subtree-dir: tests/tests-base/src/main/resources/benchmark git-subtree-split: daeaee7e6273722b44a1a82b5d7bdd204edd743c * Let evaluation code extract code models if no already extracted model available * Apply spotless * Use assertion messages to gain more information about the occurring failures * When extracting a code model, clone first * Delete directory before cloning * Squashed 'tests/tests-base/src/main/resources/benchmark/' changes from daeaee7e..9bbc3a89 9bbc3a89 Update code models to contain parent class and reference info, using new formatting (#16) fe5a8549 Update the codemodel to be more (human) readable git-subtree-dir: tests/tests-base/src/main/resources/benchmark git-subtree-split: 9bbc3a89677ffba98bb861f0c0206a93c61ec5d1 * Work on code smells * Remove annotation that leads to compile error * Register diagram-consistency to report * Fix loading of ACM * Remove commented out import --------- Co-authored-by: Dominik Fuchß <dominik.fuchss@kit.edu>
- Loading branch information
1 parent
a5f884e
commit 99b45b0
Showing
138 changed files
with
12,167 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...it/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramMatchingModelSelectionState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* 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<ModelType> getAvailableModelTypes(); | ||
|
||
/** | ||
* Sets the model types that are in principle available, meaning their loading is attempted. | ||
* | ||
* @param availableModelTypes | ||
* The model types. | ||
*/ | ||
void setAvailableModelTypes(Set<ModelType> 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<ModelType> getSelection(); | ||
|
||
/** | ||
* Sets the models that are selected to be matched with the diagram. | ||
* | ||
* @param modelTypes | ||
* The model types. | ||
*/ | ||
void setSelection(Set<ModelType> 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<Occurrence> 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<Occurrence> 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<ModelType, Double> 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<ModelType, Double> 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) { | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...du/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelInconsistencyState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* 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<String, String> inconsistency); | ||
|
||
/** | ||
* Returns all found inconsistencies. | ||
* | ||
* @param modelType The model type to get inconsistencies for. | ||
* @return All inconsistencies. | ||
*/ | ||
List<Inconsistency<String, String>> 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<Inconsistency<String, String>> 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<Inconsistency<String, String>> getExtendedInconsistencies(ModelType modelType); | ||
} |
38 changes: 38 additions & 0 deletions
38
...in/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramModelLinkState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* 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<String, String> getLinks(ModelType modelType); | ||
} |
30 changes: 30 additions & 0 deletions
30
...on/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/DiagramState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* 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); | ||
} |
127 changes: 127 additions & 0 deletions
127
...in/java/edu/kit/kastel/mcse/ardoco/core/api/diagramconsistency/common/DiagramUtility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* Licensed under MIT 2023. */ | ||
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<String> 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<Connector> 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<String, Box> 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<Box> getTargets(Connector connector, SortedMap<String, Box> 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<Box> getContainedBoxes(Box box, SortedMap<String, Box> 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(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())); | ||
} | ||
} |
Oops, something went wrong.