Skip to content

Commit 1ade956

Browse files
committed
InstanceLinks are TraceLinks
1 parent c76c861 commit 1ade956

File tree

5 files changed

+24
-64
lines changed

5 files changed

+24
-64
lines changed

framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/entity/Entity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected Entity(String name) {
3737

3838
protected Entity(String name, String id) {
3939
this.id = Objects.requireNonNull(id);
40-
this.name = name;
40+
this.name = Objects.requireNonNull(name);
4141
}
4242

4343
public String getId() {

framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/stage/connectiongenerator/ConnectionState.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,31 @@ public interface ConnectionState extends IConfigurable {
2727
*
2828
* @return all instance links
2929
*/
30-
ImmutableList<InstanceLink> getInstanceLinks();
30+
ImmutableList<TraceLink<RecommendedInstance, ModelInstance>> getInstanceLinks();
3131

3232
/**
3333
* Returns all instance links with a model instance containing the given name.
3434
*
3535
* @param name the name of a model instance
3636
* @return all instance links with a model instance containing the given name as list
3737
*/
38-
ImmutableList<InstanceLink> getInstanceLinksByName(String name);
38+
ImmutableList<TraceLink<RecommendedInstance, ModelInstance>> getInstanceLinksByName(String name);
3939

4040
/**
4141
* Returns all instance links with a model instance containing the given type.
4242
*
4343
* @param type the type of a model instance
4444
* @return all instance links with a model instance containing the given type as list
4545
*/
46-
ImmutableList<InstanceLink> getInstanceLinksByType(String type);
46+
ImmutableList<TraceLink<RecommendedInstance, ModelInstance>> getInstanceLinksByType(String type);
4747

4848
/**
4949
* Returns all instance links with a model instance containing the given recommended instance.
5050
*
5151
* @param recommendedInstance the recommended instance to consider
5252
* @return all instance links found
5353
*/
54-
ImmutableList<InstanceLink> getInstanceLinksByRecommendedInstance(RecommendedInstance recommendedInstance);
54+
ImmutableList<TraceLink<RecommendedInstance, ModelInstance>> getInstanceLinksByRecommendedInstance(RecommendedInstance recommendedInstance);
5555

5656
/**
5757
* Returns all instance links with a model instance containing the given name and type.
@@ -60,7 +60,7 @@ public interface ConnectionState extends IConfigurable {
6060
* @param type the type of a model instance
6161
* @return all instance links with a model instance containing the given name and type as list
6262
*/
63-
ImmutableList<InstanceLink> getInstanceLinks(String name, String type);
63+
ImmutableList<TraceLink<RecommendedInstance, ModelInstance>> getInstanceLinks(String name, String type);
6464

6565
/**
6666
* Returns a list of tracelinks that are contained within this connection state.
@@ -69,11 +69,11 @@ public interface ConnectionState extends IConfigurable {
6969
*/
7070
default ImmutableSet<TraceLink<SentenceEntity, ArchitectureEntity>> getTraceLinks() {
7171
MutableSet<TraceLink<SentenceEntity, ArchitectureEntity>> traceLinks = Sets.mutable.empty();
72-
for (var instanceLink : getInstanceLinks()) {
73-
var textualInstance = instanceLink.getTextualInstance();
72+
for (var instanceLink : this.getInstanceLinks()) {
73+
var textualInstance = instanceLink.getFirstEndpoint();
7474
for (var nm : textualInstance.getNameMappings()) {
7575
for (var word : nm.getWords()) {
76-
var traceLink = new SadSamTraceLink(word.getSentence(), instanceLink.getModelInstance());
76+
var traceLink = new SadSamTraceLink(word.getSentence(), instanceLink.getSecondEndpoint());
7777
traceLinks.add(traceLink);
7878
}
7979
}
@@ -98,14 +98,14 @@ default ImmutableSet<TraceLink<SentenceEntity, ArchitectureEntity>> getTraceLink
9898
* @param instanceLink the given instance link
9999
* @return true if it is already contained
100100
*/
101-
boolean isContainedByInstanceLinks(InstanceLink instanceLink);
101+
boolean isContainedByInstanceLinks(TraceLink<RecommendedInstance, ModelInstance> instanceLink);
102102

103103
/**
104104
* Removes an instance link from the state.
105105
*
106106
* @param instanceMapping the instance link to remove
107107
*/
108-
void removeFromMappings(InstanceLink instanceMapping);
108+
void removeFromMappings(TraceLink<RecommendedInstance, ModelInstance> instanceMapping);
109109

110110
/**
111111
* Removes all instance links containing the given instance.

framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/stage/connectiongenerator/InstanceLink.java

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/* Licensed under MIT 2021-2024. */
22
package edu.kit.kastel.mcse.ardoco.core.api.stage.connectiongenerator;
33

4-
import java.io.Serializable;
54
import java.util.Arrays;
65
import java.util.LinkedHashSet;
7-
import java.util.Objects;
86
import java.util.Set;
97

108
import org.eclipse.collections.api.factory.Lists;
@@ -13,6 +11,7 @@
1311
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance;
1412
import edu.kit.kastel.mcse.ardoco.core.api.stage.recommendationgenerator.RecommendedInstance;
1513
import edu.kit.kastel.mcse.ardoco.core.api.stage.textextraction.NounMapping;
14+
import edu.kit.kastel.mcse.ardoco.core.api.tracelink.TraceLink;
1615
import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic;
1716
import edu.kit.kastel.mcse.ardoco.core.common.AggregationFunctions;
1817
import edu.kit.kastel.mcse.ardoco.core.data.Confidence;
@@ -22,12 +21,9 @@
2221
* An InstanceLink defines a link between an {@link RecommendedInstance} and an {@link ModelInstance}.
2322
*/
2423
@Deterministic
25-
public class InstanceLink implements Serializable {
24+
public class InstanceLink extends TraceLink<RecommendedInstance, ModelInstance> {
2625

2726
private static final long serialVersionUID = -8630933950725516269L;
28-
29-
private final RecommendedInstance textualInstance;
30-
private final ModelInstance modelInstance;
3127
private final Confidence confidence;
3228

3329
/**
@@ -37,8 +33,7 @@ public class InstanceLink implements Serializable {
3733
* @param modelInstance the model instance
3834
*/
3935
public InstanceLink(RecommendedInstance textualInstance, ModelInstance modelInstance) {
40-
this.textualInstance = textualInstance;
41-
this.modelInstance = modelInstance;
36+
super(textualInstance, modelInstance);
4237
this.confidence = new Confidence(AggregationFunctions.AVERAGE);
4338
}
4439

@@ -74,58 +69,24 @@ public final double getConfidence() {
7469
return this.confidence.getConfidence();
7570
}
7671

77-
/**
78-
* Returns the recommended instance.
79-
*
80-
* @return the textual instance
81-
*/
82-
public final RecommendedInstance getTextualInstance() {
83-
return this.textualInstance;
84-
}
85-
86-
/**
87-
* Returns the model instance.
88-
*
89-
* @return the extracted instance
90-
*/
91-
public final ModelInstance getModelInstance() {
92-
return this.modelInstance;
93-
}
94-
95-
@Override
96-
public int hashCode() {
97-
return Objects.hash(this.modelInstance, this.textualInstance);
98-
}
99-
100-
@Override
101-
public boolean equals(Object obj) {
102-
if (this == obj) {
103-
return true;
104-
}
105-
if (!(obj instanceof InstanceLink other)) {
106-
return false;
107-
}
108-
return Objects.equals(this.getModelInstance(), other.getModelInstance()) && Objects.equals(this.getTextualInstance(), other.getTextualInstance());
109-
}
110-
11172
@Override
11273
public String toString() {
11374
Set<String> names = new LinkedHashSet<>();
11475
MutableList<Integer> namePositions = Lists.mutable.empty();
11576
Set<String> types = new LinkedHashSet<>();
11677
MutableList<Integer> typePositions = Lists.mutable.empty();
11778

118-
for (NounMapping nameMapping : this.textualInstance.getNameMappings()) {
79+
for (NounMapping nameMapping : this.getFirstEndpoint().getNameMappings()) {
11980
names.addAll(nameMapping.getSurfaceForms().castToCollection());
12081
namePositions.addAll(nameMapping.getMappingSentenceNo().castToCollection());
12182
}
122-
for (NounMapping typeMapping : this.textualInstance.getTypeMappings()) {
83+
for (NounMapping typeMapping : this.getFirstEndpoint().getTypeMappings()) {
12384
types.addAll(typeMapping.getSurfaceForms().castToCollection());
12485
typePositions.addAll(typeMapping.getMappingSentenceNo().castToCollection());
12586
}
126-
return "InstanceMapping [ uid=" + this.modelInstance.getUid() + ", name=" + this.modelInstance.getFullName() + //
127-
", as=" + String.join(", ", this.modelInstance.getFullType()) + ", probability=" + this.getConfidence() + ", FOUND: " + //
128-
this.textualInstance.getName() + " : " + this.textualInstance.getType() + ", occurrences= " + //
87+
return "InstanceMapping [ uid=" + this.getSecondEndpoint().getUid() + ", name=" + this.getSecondEndpoint().getFullName() + //
88+
", as=" + String.join(", ", this.getSecondEndpoint().getFullType()) + ", probability=" + this.getConfidence() + ", FOUND: " + //
89+
this.getFirstEndpoint().getName() + " : " + this.getFirstEndpoint().getType() + ", occurrences= " + //
12990
"NameVariants: " + names.size() + ": " + names + " sentences{" + Arrays.toString(namePositions.toArray()) + "}" + //
13091
", TypeVariants: " + types.size() + ": " + types + "sentences{" + Arrays.toString(typePositions.toArray()) + "}" + "]";
13192
}

pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/output/ArDoCoResult.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public ImmutableList<TraceLink<SentenceEntity, ArchitectureEntity>> getAllTraceL
9696
MutableSet<TraceLink<SentenceEntity, ArchitectureEntity>> traceLinks = Sets.mutable.empty();
9797

9898
for (var modelId : this.getModelIds()) {
99-
if (this.getModelState(modelId).getMetamodel() == Metamodel.ARCHITECTURE) {
99+
if (modelId == Metamodel.ARCHITECTURE) {
100100
traceLinks.addAll(this.getTraceLinksForModel(modelId).castToCollection());
101101
}
102102
}
@@ -255,8 +255,7 @@ public Sentence getSentence(int sentenceNo) {
255255
public ConnectionState getConnectionState(Metamodel modelId) {
256256
if (DataRepositoryHelper.hasConnectionStates(this.dataRepository)) {
257257
var connectionStates = DataRepositoryHelper.getConnectionStates(this.dataRepository);
258-
var modelState = this.getModelState(modelId);
259-
return connectionStates.getConnectionState(modelState.getMetamodel());
258+
return connectionStates.getConnectionState(modelId);
260259
}
261260
ArDoCoResult.logger.warn("No ConnectionState found.");
262261
return null;
@@ -271,8 +270,7 @@ public ConnectionState getConnectionState(Metamodel modelId) {
271270
public InconsistencyState getInconsistencyState(Metamodel modelId) {
272271
if (DataRepositoryHelper.hasInconsistencyStates(this.dataRepository)) {
273272
var inconsistencyStates = DataRepositoryHelper.getInconsistencyStates(this.dataRepository);
274-
var modelState = this.getModelState(modelId);
275-
return inconsistencyStates.getInconsistencyState(modelState.getMetamodel());
273+
return inconsistencyStates.getInconsistencyState(modelId);
276274
}
277275
ArDoCoResult.logger.warn("No InconsistencyState found.");
278276
return null;

pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/execution/ProjectPipelineDataImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
public class ProjectPipelineDataImpl implements ProjectPipelineData {
1010

11+
private static final long serialVersionUID = -993634357212795104L;
1112
private final String projectName;
1213

1314
/**
@@ -22,6 +23,6 @@ public class ProjectPipelineDataImpl implements ProjectPipelineData {
2223

2324
@Override
2425
public String getProjectName() {
25-
return projectName;
26+
return this.projectName;
2627
}
2728
}

0 commit comments

Comments
 (0)