Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add informal diagram consistency pipeline steps #308

Merged
merged 37 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cbb5572
Adapt code model to support nested classes
jeanpmathes Aug 19, 2023
145487d
Merge remote-tracking branch 'old-origin/main' into modified
jeanpmathes Aug 31, 2023
d58fa2b
Merge tag 'v0.23.0' into modified
jeanpmathes Aug 31, 2023
d56594d
Extend code model to store references of types to other types
jeanpmathes Oct 9, 2023
87371b7
Merge tag 'v0.26.0' into modified
jeanpmathes Oct 22, 2023
d93d160
Move code from thesis repo into ArDoCo core
jeanpmathes Oct 23, 2023
280273f
Fix some test
jeanpmathes Oct 23, 2023
1f706ad
Merge the two existing diagram classes
jeanpmathes Oct 25, 2023
5605fdc
Fix the large graph test
jeanpmathes Oct 25, 2023
9c4ddb0
Fix version name
jeanpmathes Dec 5, 2023
3ec41d2
Merge branch 'main' into modified
jeanpmathes Dec 5, 2023
918bdff
Update stages/diagram-consistency/pom.xml
jeanpmathes Dec 5, 2023
3b6a34a
Adapt pom.xml files as reviewed and adapt to changes related to packa…
jeanpmathes Dec 5, 2023
0083304
Update framework/common/pom.xml
dfuchss Dec 5, 2023
68a1bc0
Apply spotless
jeanpmathes Dec 6, 2023
37cf86e
Merge remote-tracking branch 'target/modified' into modified
jeanpmathes Dec 6, 2023
979c261
Reset benchmark
dfuchss Dec 6, 2023
6b136cf
Merge commit '1f6f1a6515c7f2e2d9b2d7bd5fe5e9b1b3833d5e' into modified
dfuchss Dec 6, 2023
1f6f1a6
Squashed 'tests/tests-base/src/main/resources/benchmark/' changes fro…
dfuchss Dec 6, 2023
24bc6c0
Let evaluation code extract code models if no already extracted model…
jeanpmathes Dec 6, 2023
e43787e
Merge remote-tracking branch 'target/modified' into modified
jeanpmathes Dec 6, 2023
664e2e0
Apply spotless
jeanpmathes Dec 6, 2023
d6987d1
Use assertion messages to gain more information about the occurring f…
jeanpmathes Dec 8, 2023
8009807
Merge remote-tracking branch 'target/main' into modified
jeanpmathes Dec 8, 2023
169b624
When extracting a code model, clone first
jeanpmathes Dec 8, 2023
a5a12f7
Delete directory before cloning
jeanpmathes Dec 8, 2023
c4db18a
Squashed 'tests/tests-base/src/main/resources/benchmark/' changes fro…
dfuchss Dec 11, 2023
ed842d2
Merge commit 'c4db18a640cc03c62f1c98976b89752b80ca5b43' into modified
dfuchss Dec 11, 2023
fb180c8
Merge branch 'main' into modified
dfuchss Dec 13, 2023
ccb7bd4
Work on code smells
jeanpmathes Dec 13, 2023
ef6933c
Merge remote-tracking branch 'target/modified' into modified
jeanpmathes Dec 13, 2023
550fd5a
Merge branch 'main' into modified
dfuchss Dec 14, 2023
8dfa1ba
Remove annotation that leads to compile error
jeanpmathes Dec 14, 2023
5e23229
Merge remote-tracking branch 'target/modified' into modified
jeanpmathes Dec 14, 2023
937e4fc
Register diagram-consistency to report
dfuchss Dec 14, 2023
be2030b
Fix loading of ACM
dfuchss Dec 15, 2023
b144531
Remove commented out import
jeanpmathes Dec 20, 2023
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
6 changes: 6 additions & 0 deletions framework/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,11 @@
<artifactId>sqlite-jdbc</artifactId>
<version>3.44.1.0</version>
</dependency>
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
<version>${jgrapht.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
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) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package edu.kit.kastel.mcse.ardoco.core.api.diagramconsistency.common;

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;

import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.UUID;
import java.util.stream.Collectors;

/**
* 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()));
}
}
Loading