diff --git a/Dockerfile b/Dockerfile
index f5eba3d..12a3508 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
-FROM alpine:3.14
+FROM alpine:3.15
# Prepare the environment
RUN apk add maven
@@ -12,13 +12,13 @@ COPY pom.xml .
RUN mvn package || exit
-FROM alpine:3.14
+FROM alpine:3.15
# Create a user
RUN adduser --disabled-password --home /home/user --gecos '' user
RUN apk add --no-cache --upgrade bash
-RUN apk add --update openjdk11 unzip
+RUN apk add --update openjdk17 unzip
RUN apk add --no-cache msttcorefonts-installer fontconfig
RUN update-ms-fonts
RUN apk add --no-cache tesseract-ocr python3 py3-pip py3-numpy && \
diff --git a/experiment.bat b/experiment.bat
index 2ade082..a0ed369 100644
--- a/experiment.bat
+++ b/experiment.bat
@@ -1,5 +1,4 @@
@echo Starting %*
-@if not exist "results" mkdir results
@docker run --rm -v "%cd%/results":"/home/user/results" match-experiments %*
diff --git a/pom.xml b/pom.xml
index 78ab7d6..b940814 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,20 +6,15 @@
de.variantsync.matching
RaQuN
- 1.0
+ 1.1
- 11
+ 17
UTF-8
5.6.0
-
@@ -31,18 +26,6 @@
${java.version}
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.2.0
-
-
-
- de.variantsync.matching.experiments.RQ1Runner
-
-
-
-
maven-assembly-plugin
@@ -53,10 +36,11 @@
single
- RaQuN
+ RaQuN-${project.version}
jar-with-dependencies
+ false
diff --git a/src/main/java/de/variantsync/matching/emf2csv/Architecture2CSV.java b/src/main/java/de/variantsync/matching/emf2csv/Architecture2CSV.java
index 5ea50e1..03b7876 100644
--- a/src/main/java/de/variantsync/matching/emf2csv/Architecture2CSV.java
+++ b/src/main/java/de/variantsync/matching/emf2csv/Architecture2CSV.java
@@ -25,7 +25,7 @@
*/
public class Architecture2CSV {
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
System.out.println("Running Architecture2CSV...");
if (args.length != 1) {
@@ -33,37 +33,37 @@ public static void main(String[] args) throws Exception {
System.exit(0);
}
- File inFolder = new File(args[0]);
+ final File inFolder = new File(args[0]);
if (!inFolder.exists() || !inFolder.isDirectory()) {
System.err.println("Directory does not exist: " + inFolder.getAbsolutePath());
System.exit(0);
}
System.out.println("Model Directory: " + inFolder.getAbsolutePath());
- File outFile = new File("csv-models/" + inFolder.getName() + ".csv");
+ final File outFile = new File("csv-models/" + inFolder.getName() + ".csv");
outFile.getParentFile().mkdirs();
- List elementTypes = new ArrayList();
+ final List elementTypes = new ArrayList();
elementTypes.add(ArchitecturePackage.eINSTANCE.getComponent());
elementTypes.add(ArchitecturePackage.eINSTANCE.getConnector());
convert(inFolder, outFile, elementTypes);
}
- private static void convert(File inFolder, File outFile, List elementTypes) throws Exception {
- List allElementRecords = new ArrayList();
+ private static void convert(final File inFolder, final File outFile, final List elementTypes) throws Exception {
+ final List allElementRecords = new ArrayList<>();
- File modelFiles[] = inFolder.listFiles();
- for (File file : modelFiles) {
+ final File[] modelFiles = inFolder.listFiles();
+ for (final File file : modelFiles) {
System.out.println("Processing " + file.getAbsolutePath());
- Architecture model = ModelUtil.loadArchitectureModel(file.getAbsolutePath());
+ final Architecture model = ModelUtil.loadArchitectureModel(file.getAbsolutePath());
String modelId = file.getName();
modelId = modelId.substring(0, modelId.length() - 5);
// Elements
- for (EClass elementType : elementTypes) {
- for (Element element : ModelUtil.getAllElements(model, elementType)) {
- String[] elementRecord = new String[4];
+ for (final EClass elementType : elementTypes) {
+ for (final Element element : ModelUtil.getAllElements(model, elementType)) {
+ final String[] elementRecord = new String[4];
elementRecord[0] = modelId;
elementRecord[1] = ModelUtil.getXmiId(element);
elementRecord[2] = element.getName();
@@ -84,16 +84,16 @@ private static void convert(File inFolder, File outFile, List elementTyp
writeCSV(allElementRecords, outFile.getAbsolutePath());
}
- private static String getComponentPropertyString(Component component) {
+ private static String getComponentPropertyString(final Component component) {
String propertyString = "Component";
- for (Port port : component.getPorts()) {
+ for (final Port port : component.getPorts()) {
propertyString += ";" + port.getName();
- for (Connector c : port.getOutgoings()) {
+ for (final Connector c : port.getOutgoings()) {
propertyString += ";out_" + c.getName();
}
- for (Connector c : port.getIncomings()) {
+ for (final Connector c : port.getIncomings()) {
propertyString += ";in_" + c.getName();
}
}
@@ -101,7 +101,7 @@ private static String getComponentPropertyString(Component component) {
return propertyString;
}
- private static String getConnectorPropertyString(Connector connector) {
+ private static String getConnectorPropertyString(final Connector connector) {
String propertyString = "Connector";
propertyString += ";" + connector.getType().toString();
@@ -112,9 +112,9 @@ private static String getConnectorPropertyString(Connector connector) {
return propertyString;
}
- private static void writeCSV(List stringArray, String path) throws Exception {
+ private static void writeCSV(final List stringArray, final String path) throws Exception {
System.out.println("Writing Output CSV: " + path);
- CSVWriter writer = new CSVWriter(new FileWriter(path.toString()), ',', Character.MIN_VALUE);
+ final CSVWriter writer = new CSVWriter(new FileWriter(path.toString()), ',', Character.MIN_VALUE);
writer.writeAll(stringArray);
writer.close();
}
diff --git a/src/main/java/de/variantsync/matching/emf2csv/ModelUtil.java b/src/main/java/de/variantsync/matching/emf2csv/ModelUtil.java
index 1443c66..982e659 100644
--- a/src/main/java/de/variantsync/matching/emf2csv/ModelUtil.java
+++ b/src/main/java/de/variantsync/matching/emf2csv/ModelUtil.java
@@ -32,25 +32,25 @@ public class ModelUtil {
static {
// Register the proper EMF resource factories
- Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
- Map m = reg.getExtensionToFactoryMap();
+ final Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
+ final Map m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
m.put("arch", new XMIResourceFactoryImpl());
m.put("ecore", new EcoreResourceFactoryImpl());
}
- public static List getAllFeatures(Class clazz) {
- List properties = new ArrayList();
+ public static List getAllFeatures(final Class clazz) {
+ final List properties = new ArrayList<>();
properties.addAll(clazz.getAttributes());
properties.addAll(clazz.getOperations());
return properties;
}
- public static List getAllElements(Model model, EClass eClass) {
- List elements = new ArrayList();
- for (Iterator iterator = model.eAllContents(); iterator.hasNext();) {
- EObject eObject = (EObject) iterator.next();
+ public static List getAllElements(final Model model, final EClass eClass) {
+ final List elements = new ArrayList<>();
+ for (final Iterator iterator = model.eAllContents(); iterator.hasNext();) {
+ final EObject eObject = iterator.next();
if (eObject.eClass() == eClass) {
elements.add((NamedElement) eObject);
}
@@ -59,10 +59,10 @@ public static List getAllElements(Model model, EClass eClass) {
return elements;
}
- public static List getAllElements(Architecture model, EClass eClass) {
- List elements = new ArrayList();
- for (Iterator iterator = model.eAllContents(); iterator.hasNext();) {
- EObject eObject = (EObject) iterator.next();
+ public static List getAllElements(final Architecture model, final EClass eClass) {
+ final List elements = new ArrayList<>();
+ for (final Iterator iterator = model.eAllContents(); iterator.hasNext();) {
+ final EObject eObject = iterator.next();
if (eObject.eClass() == eClass) {
elements.add((Element) eObject);
}
@@ -71,43 +71,39 @@ public static List getAllElements(Architecture model, EClass eClass) {
return elements;
}
- public static String getXmiId(EObject eObject) {
+ public static String getXmiId(final EObject eObject) {
assert (eObject != null && eObject.eResource() instanceof XMIResource);
- String objectID = ((XMIResource) eObject.eResource()).getID(eObject);
-
- return objectID;
+ return ((XMIResource) eObject.eResource()).getID(eObject);
}
- public static Model loadModel(String path) {
- ResourceSet resourceSet = new ResourceSetImpl();
+ public static Model loadModel(final String path) {
+ final ResourceSet resourceSet = new ResourceSetImpl();
UMLResourcesUtil.init(resourceSet);
- Resource resource = resourceSet.getResource(URI.createFileURI(path), true);
- Model model = (Model) resource.getContents().get(0);
+ final Resource resource = resourceSet.getResource(URI.createFileURI(path), true);
- return model;
+ return (Model) resource.getContents().get(0);
}
- public static Architecture loadArchitectureModel(String path) {
- ResourceSet resourceSet = new ResourceSetImpl();
+ public static Architecture loadArchitectureModel(final String path) {
+ final ResourceSet resourceSet = new ResourceSetImpl();
UMLResourcesUtil.init(resourceSet);
- Resource resource = resourceSet.getResource(URI.createFileURI(path), true);
- Architecture model = (Architecture) resource.getContents().get(0);
+ final Resource resource = resourceSet.getResource(URI.createFileURI(path), true);
- return model;
+ return (Architecture) resource.getContents().get(0);
}
- public static void saveModel(Model model, String path) {
+ public static void saveModel(final Model model, final String path) {
System.out.println(path);
- ResourceSet resourceSet = new ResourceSetImpl();
+ final ResourceSet resourceSet = new ResourceSetImpl();
UMLResourcesUtil.init(resourceSet);
- Resource resource = resourceSet.createResource(URI.createFileURI(path));
+ final Resource resource = resourceSet.createResource(URI.createFileURI(path));
resource.getContents().add(model);
// now save the content.
try {
resource.save(Collections.EMPTY_MAP);
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
diff --git a/src/main/java/de/variantsync/matching/emf2csv/UML2CSV.java b/src/main/java/de/variantsync/matching/emf2csv/UML2CSV.java
index d52584b..d07cf78 100644
--- a/src/main/java/de/variantsync/matching/emf2csv/UML2CSV.java
+++ b/src/main/java/de/variantsync/matching/emf2csv/UML2CSV.java
@@ -30,7 +30,7 @@
*/
public class UML2CSV {
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
System.out.println("Running UML2CSV...");
// Get arguments and prepare the conversion settings
@@ -43,7 +43,7 @@ public static void main(String[] args) throws Exception {
System.err.println("Required arguments: ['classdiagram'|'statemachine'] ");
System.exit(0);
}
- List elementTypes = new ArrayList();
+ final List elementTypes = new ArrayList<>();
if (args[0].equals("classdiagram")) {
elementTypes.add(UMLPackage.eINSTANCE.getClass_());
}
@@ -52,13 +52,13 @@ public static void main(String[] args) throws Exception {
elementTypes.add(UMLPackage.eINSTANCE.getTransition());
}
- File inFolder = new File(args[1]);
+ final File inFolder = new File(args[1]);
if (!inFolder.exists() || !inFolder.isDirectory()) {
System.err.println("Directory does not exist: " + inFolder.getAbsolutePath());
System.exit(0);
}
- File outFile = new File("csv-models/" + inFolder.getName() + ".csv");
+ final File outFile = new File("csv-models/" + inFolder.getName() + ".csv");
outFile.getParentFile().mkdirs();
System.out.println("Model Type: " + args[0]);
@@ -68,20 +68,20 @@ public static void main(String[] args) throws Exception {
convert(inFolder, outFile, elementTypes);
}
- private static void convert(File inFolder, File outFile, List elementTypes) throws Exception {
- List allElementRecords = new ArrayList();
+ private static void convert(final File inFolder, final File outFile, final List elementTypes) throws Exception {
+ final List allElementRecords = new ArrayList<>();
- File modelFiles[] = inFolder.listFiles();
- for (File file : modelFiles) {
+ final File[] modelFiles = inFolder.listFiles();
+ for (final File file : modelFiles) {
System.out.println("Processing " + file.getAbsolutePath());
- Model model = ModelUtil.loadModel(file.getAbsolutePath());
+ final Model model = ModelUtil.loadModel(file.getAbsolutePath());
String modelId = file.getName();
modelId = modelId.substring(0, modelId.length() - 4);
// Elements
- for (EClass elementType : elementTypes) {
- for (NamedElement element : ModelUtil.getAllElements(model, elementType)) {
- String[] elementRecord = new String[4];
+ for (final EClass elementType : elementTypes) {
+ for (final NamedElement element : ModelUtil.getAllElements(model, elementType)) {
+ final String[] elementRecord = new String[4];
elementRecord[0] = modelId;
elementRecord[1] = ModelUtil.getXmiId(element);
elementRecord[2] = element.getName();
@@ -105,10 +105,10 @@ private static void convert(File inFolder, File outFile, List elementTyp
writeCSV(allElementRecords, outFile.getAbsolutePath());
}
- private static String getClassPropertyString(Class clazz) {
+ private static String getClassPropertyString(final Class clazz) {
String propertyString = "";
- List properties = ModelUtil.getAllFeatures(clazz);
- for (Feature feature : properties) {
+ final List properties = ModelUtil.getAllFeatures(clazz);
+ for (final Feature feature : properties) {
// Semicolon to separate features needed?
if (!propertyString.isEmpty()) {
propertyString += ";";
@@ -116,12 +116,12 @@ private static String getClassPropertyString(Class clazz) {
// String representation of property
if (feature instanceof Operation) {
// Special handling of Operations
- Operation operation = (Operation) feature;
+ final Operation operation = (Operation) feature;
propertyString += operation.getName();
if (operation.getOwnedParameters().isEmpty()) {
propertyString += "_";
} else {
- for (Parameter param : operation.getOwnedParameters()) {
+ for (final Parameter param : operation.getOwnedParameters()) {
propertyString += "_" + param.getName();
}
}
@@ -134,13 +134,13 @@ private static String getClassPropertyString(Class clazz) {
return propertyString;
}
- private static String getStatePropertyString(State state) {
+ private static String getStatePropertyString(final State state) {
String propertyString = "State";
- for (Transition t : state.getOutgoings()) {
+ for (final Transition t : state.getOutgoings()) {
propertyString += ";out_" + t.getName();
}
- for (Transition t : state.getIncomings()) {
+ for (final Transition t : state.getIncomings()) {
propertyString += ";in_" + t.getName();
}
@@ -159,7 +159,7 @@ private static String getStatePropertyString(State state) {
return propertyString;
}
- private static String getTransitionPropertyString(Transition transition) {
+ private static String getTransitionPropertyString(final Transition transition) {
String propertyString = "Transition";
propertyString += ";src_" + transition.getSource().getName();
@@ -175,9 +175,9 @@ private static String getTransitionPropertyString(Transition transition) {
return propertyString;
}
- protected static void writeCSV(List stringArray, String path) throws Exception {
+ protected static void writeCSV(final List stringArray, final String path) throws Exception {
System.out.println("Writing Output CSV: " + path);
- CSVWriter writer = new CSVWriter(new FileWriter(path.toString()), ',', Character.MIN_VALUE);
+ final CSVWriter writer = new CSVWriter(new FileWriter(path.toString()), ',', Character.MIN_VALUE);
writer.writeAll(stringArray);
writer.close();
}
diff --git a/src/main/java/de/variantsync/matching/experiments/AbstractRQRunner.java b/src/main/java/de/variantsync/matching/experiments/AbstractRQRunner.java
index 4904b7e..0d961d0 100644
--- a/src/main/java/de/variantsync/matching/experiments/AbstractRQRunner.java
+++ b/src/main/java/de/variantsync/matching/experiments/AbstractRQRunner.java
@@ -3,7 +3,6 @@
import de.variantsync.matching.experiments.common.ExperimentConfiguration;
import java.io.File;
-import java.util.concurrent.TimeUnit;
/**
* Abstract base class for RQRunners
diff --git a/src/main/java/de/variantsync/matching/experiments/baseline/BaselineAlgoAdapter.java b/src/main/java/de/variantsync/matching/experiments/baseline/BaselineAlgoAdapter.java
index e0fe7bf..815675e 100644
--- a/src/main/java/de/variantsync/matching/experiments/baseline/BaselineAlgoAdapter.java
+++ b/src/main/java/de/variantsync/matching/experiments/baseline/BaselineAlgoAdapter.java
@@ -3,7 +3,6 @@
import de.variantsync.matching.experiments.EAlgorithm;
import de.variantsync.matching.experiments.common.*;
import de.variantsync.matching.nwm.alg.merge.ChainingOptimizingMerger;
-import de.variantsync.matching.nwm.alg.merge.MultiModelMerger;
import de.variantsync.matching.nwm.common.AlgoUtil;
import de.variantsync.matching.nwm.domain.Element;
import de.variantsync.matching.nwm.domain.Model;
@@ -30,7 +29,7 @@ public BaselineAlgoAdapter(final EAlgorithm algorithm) {
@Override
public boolean run(final ExperimentSetup setup) {
for (int runID = 0; runID < setup.numberOfRepeats; runID++) {
- // Here, we use the Model class of Rubin an Chechik
+ // Here, we use the Model class of Rubin and Chechik
final ArrayList models = Model.readModelsFile(setup.datasetFile);
final List> chunks = ExperimentHelper.getDatasetChunks(models, setup.chunkSize);
@@ -80,8 +79,6 @@ public boolean run(final ExperimentSetup setup) {
if (solution == null || runResult == null) {
return false;
- } else {
- System.out.println("");
}
// We parse the matching returned by NwM to our own data format, in order to do the evaluation
@@ -100,7 +97,6 @@ public boolean run(final ExperimentSetup setup) {
System.out.println();
matchStatistic.writeAsJSON(setup.resultFile, true);
- //executionStatistic.writeModel(setup.mergeResultFile);
}
}
return true;
diff --git a/src/main/java/de/variantsync/matching/experiments/common/ExperimentConfiguration.java b/src/main/java/de/variantsync/matching/experiments/common/ExperimentConfiguration.java
index 5ad4e07..f125103 100644
--- a/src/main/java/de/variantsync/matching/experiments/common/ExperimentConfiguration.java
+++ b/src/main/java/de/variantsync/matching/experiments/common/ExperimentConfiguration.java
@@ -115,18 +115,13 @@ public long timeoutDuration() {
public TimeUnit timeoutUnit() {
final String unit = config.getString(EXPERIMENTS_TIMEOUT_UNIT).trim();
- switch (unit) {
- case "SECONDS":
- return TimeUnit.SECONDS;
- case "MINUTES":
- return TimeUnit.MINUTES;
- case "HOURS":
- return TimeUnit.HOURS;
- case "DAYS":
- return TimeUnit.DAYS;
- default:
- throw new IllegalArgumentException(unit + " is not a valid time unit for the timeout");
- }
+ return switch (unit) {
+ case "SECONDS" -> TimeUnit.SECONDS;
+ case "MINUTES" -> TimeUnit.MINUTES;
+ case "HOURS" -> TimeUnit.HOURS;
+ case "DAYS" -> TimeUnit.DAYS;
+ default -> throw new IllegalArgumentException(unit + " is not a valid time unit for the timeout");
+ };
}
public boolean verboseResults() {
return config.getBoolean(EXPERIMENTS_EXECUTION_VERBOSE);
diff --git a/src/main/java/de/variantsync/matching/experiments/common/ExperimentHelper.java b/src/main/java/de/variantsync/matching/experiments/common/ExperimentHelper.java
index ec93c63..a6d6113 100644
--- a/src/main/java/de/variantsync/matching/experiments/common/ExperimentHelper.java
+++ b/src/main/java/de/variantsync/matching/experiments/common/ExperimentHelper.java
@@ -77,7 +77,7 @@ public static boolean runExperiment(final MatcherAdapter adapter, final Experime
}
- public static V executeWithTimeout(final Callable callable, final ExperimentSetup setup, IKillableLongTask task) {
+ public static V executeWithTimeout(final Callable callable, final ExperimentSetup setup, final IKillableLongTask task) {
final ExecutorService executor = Executors.newSingleThreadExecutor();
final Future future = executor.submit(callable);
try {
@@ -87,7 +87,7 @@ public static V executeWithTimeout(final Callable callable, final Experim
try {
System.err.println("Awaiting stop confirmation...");
return future.get();
- } catch (InterruptedException | ExecutionException ex) {
+ } catch (final InterruptedException | ExecutionException ex) {
throw new RuntimeException(ex);
} finally {
System.err.println("Stop confirmed: " + task + " on " + setup.datasetName);
diff --git a/src/main/java/de/variantsync/matching/raqun/tree/TreeNeighbor.java b/src/main/java/de/variantsync/matching/raqun/tree/TreeNeighbor.java
index 1bab2d2..78cee7e 100644
--- a/src/main/java/de/variantsync/matching/raqun/tree/TreeNeighbor.java
+++ b/src/main/java/de/variantsync/matching/raqun/tree/TreeNeighbor.java
@@ -6,22 +6,17 @@
* Representation of a neighboring element in a k-d-tree. A TreeNeighbor comprises the neighboring element and the distance
* to it.
*/
-public class TreeNeighbor {
- private final RElement element;
- private final double distance;
-
+public record TreeNeighbor(RElement element, double distance) {
/**
* Initialize a new neighboring element
- * @param element the neighboring element
+ *
+ * @param element the neighboring element
* @param distance the distance to it
*/
- public TreeNeighbor(final RElement element, final double distance) {
- this.element = element;
- this.distance = distance;
+ public TreeNeighbor {
}
/**
- *
* @return The distance to the neighbor
*/
public double getDistance() {
@@ -29,7 +24,6 @@ public double getDistance() {
}
/**
- *
* @return The neighboring element
*/
public RElement getElement() {