Skip to content

Commit

Permalink
Sync 19:47
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuchss committed Nov 29, 2024
1 parent 55e0aac commit 06211ff
Show file tree
Hide file tree
Showing 52 changed files with 514 additions and 462 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import org.eclipse.collections.api.set.ImmutableSet;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SadCodeTraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SamCodeTraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TraceLink;
Expand All @@ -33,7 +33,7 @@ public interface CodeTraceabilityState extends PipelineStepData {
* @param traceLinks the trace links to add
* @return whether the operation was successful
*/
boolean addSamCodeTraceLinks(Collection<TraceLink<ArchitectureEntity, CodeCompilationUnit>> traceLinks);
boolean addSamCodeTraceLinks(Collection<? extends TraceLink<ArchitectureEntity, CodeCompilationUnit>> traceLinks);

/**
* Return a set of stored {@link SamCodeTraceLink SamCodeTraceLinks}.
Expand All @@ -56,7 +56,7 @@ public interface CodeTraceabilityState extends PipelineStepData {
* @param traceLinks the trace links to add
* @return whether the operation was successful
*/
boolean addSadCodeTraceLinks(Collection<TraceLink<SentenceEntity, CodeCompilationUnit>> traceLinks);
boolean addSadCodeTraceLinks(Collection<? extends TraceLink<SentenceEntity, CodeCompilationUnit>> traceLinks);

/**
* Return a set of stored {@link TransitiveTraceLink TransitiveTraceLinks}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import org.eclipse.collections.api.set.ImmutableSet;
import org.eclipse.collections.api.set.MutableSet;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity;
import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.InstanceLink;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SadSamTraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.recommendationgenerator.RecommendedInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Licensed under MIT 2021-2024. */
package edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks;
package edu.kit.kastel.mcse.ardoco.core.api.connectiongenerator;

import java.util.Arrays;
import java.util.LinkedHashSet;
Expand All @@ -9,20 +9,25 @@
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.list.MutableList;

import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.EndpointTuple;
import edu.kit.kastel.mcse.ardoco.core.api.recommendationgenerator.RecommendedInstance;
import edu.kit.kastel.mcse.ardoco.core.api.textextraction.NounMapping;
import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic;
import edu.kit.kastel.mcse.ardoco.core.common.AggregationFunctions;
import edu.kit.kastel.mcse.ardoco.core.common.Internal;
import edu.kit.kastel.mcse.ardoco.core.data.Confidence;
import edu.kit.kastel.mcse.ardoco.core.pipeline.agent.Claimant;

/**
* An InstanceLink defines a link between an {@link RecommendedInstance} and an {@link ModelInstance}.
*/
@Deterministic
@Internal
public class InstanceLink extends EndpointTuple<RecommendedInstance, ModelInstance> {

private static final long serialVersionUID = -8630933950725516269L;

private final RecommendedInstance textualInstance;
private final ModelInstance modelInstance;
private final Confidence confidence;
Expand Down Expand Up @@ -55,7 +60,7 @@ public InstanceLink(RecommendedInstance textualInstance, ModelInstance modelInst

/**
* Add confidence to this link.
*
*
* @param claimant the claimant that wants to change the confidence
* @param confidence the confidence value to add
*/
Expand All @@ -69,7 +74,7 @@ public final void addConfidence(Claimant claimant, double confidence) {
* @return the probability of this link
*/
public final double getConfidence() {
return confidence.getConfidence();
return this.confidence.getConfidence();
}

/**
Expand All @@ -78,7 +83,7 @@ public final double getConfidence() {
* @return the textual instance
*/
public final RecommendedInstance getTextualInstance() {
return textualInstance;
return this.textualInstance;
}

/**
Expand All @@ -87,12 +92,12 @@ public final RecommendedInstance getTextualInstance() {
* @return the extracted instance
*/
public final ModelInstance getModelInstance() {
return modelInstance;
return this.modelInstance;
}

@Override
public int hashCode() {
return Objects.hash(modelInstance, textualInstance);
return Objects.hash(this.modelInstance, this.textualInstance);
}

@Override
Expand All @@ -103,7 +108,7 @@ public boolean equals(Object obj) {
if (!(obj instanceof InstanceLink other)) {
return false;
}
return Objects.equals(getModelInstance(), other.getModelInstance()) && Objects.equals(getTextualInstance(), other.getTextualInstance());
return Objects.equals(this.getModelInstance(), other.getModelInstance()) && Objects.equals(this.getTextualInstance(), other.getTextualInstance());
}

@Override
Expand All @@ -113,17 +118,17 @@ public String toString() {
Set<String> types = new LinkedHashSet<>();
MutableList<Integer> typePositions = Lists.mutable.empty();

for (NounMapping nameMapping : textualInstance.getNameMappings()) {
for (NounMapping nameMapping : this.textualInstance.getNameMappings()) {
names.addAll(nameMapping.getSurfaceForms().castToCollection());
namePositions.addAll(nameMapping.getMappingSentenceNo().castToCollection());
}
for (NounMapping typeMapping : textualInstance.getTypeMappings()) {
for (NounMapping typeMapping : this.textualInstance.getTypeMappings()) {
types.addAll(typeMapping.getSurfaceForms().castToCollection());
typePositions.addAll(typeMapping.getMappingSentenceNo().castToCollection());
}
return "InstanceMapping [ uid=" + modelInstance.getUid() + ", name=" + modelInstance.getFullName() + //
", as=" + String.join(", ", modelInstance.getFullType()) + ", probability=" + getConfidence() + ", FOUND: " + //
textualInstance.getName() + " : " + textualInstance.getType() + ", occurrences= " + //
return "InstanceMapping [ uid=" + this.modelInstance.getUid() + ", name=" + this.modelInstance.getFullName() + //
", as=" + String.join(", ", this.modelInstance.getFullType()) + ", probability=" + this.getConfidence() + ", FOUND: " + //
this.textualInstance.getName() + " : " + this.textualInstance.getType() + ", occurrences= " + //
"NameVariants: " + names.size() + ": " + names + " sentences{" + Arrays.toString(namePositions.toArray()) + "}" + //
", TypeVariants: " + types.size() + ": " + types + "sentences{" + Arrays.toString(typePositions.toArray()) + "}" + "]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public enum ArchitectureModelType implements ModelType {
RAW;

@Override
public String getModelId() {
return this.name();
public Metamodel getMetamodel() {
return Metamodel.ARCHITECTURE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public enum CodeModelType implements ModelType {
CODE_MODEL;

@Override
public String getModelId() {
return "CodeModel";
public Metamodel getMetamodel() {
return Metamodel.CODE;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.ArchitectureModel;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.CodeModel;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.Model;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.LegacyModelExtractionState;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.LegacyModelExtractionStateByArCoTL;
import edu.kit.kastel.mcse.ardoco.core.data.PipelineStepData;

public class ModelStates implements PipelineStepData {
private static final long serialVersionUID = -603436842247064371L;

public static final String ID = "ModelStatesData";

private SortedMap<String, Model> models = new TreeMap<>();
private SortedMap<String, LegacyModelExtractionState> legacyModels = new TreeMap<>();
private SortedMap<Metamodel, Model> models = new TreeMap<>();
private SortedMap<Metamodel, LegacyModelExtractionState> legacyModels = new TreeMap<>();

/**
* Constructor to create a {@link ModelStates} object that holds all {@link LegacyModelExtractionState}s
Expand All @@ -29,23 +33,25 @@ public ModelStates() {
*
* @param id the id
* @return the corresponding {@link LegacyModelExtractionState}
* @deprecated use {@link #getModel(String)} instead
* @deprecated use {@link #getModel(Metamodel)} instead
*/
@Deprecated
public LegacyModelExtractionState getModelExtractionState(String id) {
if (legacyModels.containsKey(id))
return legacyModels.get(id);
public LegacyModelExtractionState getModelExtractionState(Metamodel id) {
if (this.legacyModels.containsKey(id)) {
return this.legacyModels.get(id);
}

var model = models.get(id);
if (model == null)
var model = this.models.get(id);
if (model == null) {
return null;
}

var legacyModel = switch (model) {
case ArchitectureModel am -> new LegacyModelExtractionStateByArCoTL(am);
case CodeModel cm -> new LegacyModelExtractionStateByArCoTL(cm);
};

legacyModels.put(id, legacyModel);
this.legacyModels.put(id, legacyModel);
return legacyModel;
}

Expand All @@ -54,8 +60,8 @@ public LegacyModelExtractionState getModelExtractionState(String id) {
*
* @return the IDs of all contained {@link Model Models}
*/
public SortedSet<String> modelIds() {
return new TreeSet<>(models.keySet());
public SortedSet<Metamodel> modelIds() {
return new TreeSet<>(this.models.keySet());
}

/**
Expand All @@ -64,8 +70,8 @@ public SortedSet<String> modelIds() {
* @param id the id
* @param model the {@link Model}
*/
public void addModel(String id, Model model) {
models.put(id, model);
public void addModel(Metamodel id, Model model) {
this.models.put(id, model);
}

/**
Expand All @@ -74,8 +80,8 @@ public void addModel(String id, Model model) {
* @param id the id
* @return the corresponding {@link Model}
*/
public Model getModel(String id) {
return models.get(id);
public Model getModel(Metamodel id) {
return this.models.get(id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
package edu.kit.kastel.mcse.ardoco.core.api.models;

public interface ModelType {
String getModelId();
Metamodel getMetamodel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeItem;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeItemRepository;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodePackage;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity;

/**
* A code model that is a CMTL instance.
Expand Down
Loading

0 comments on commit 06211ff

Please sign in to comment.