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 baa6424 commit 40af515
Show file tree
Hide file tree
Showing 46 changed files with 329 additions and 304 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,50 @@
import org.eclipse.collections.impl.factory.Sets;

import edu.kit.kastel.mcse.ardoco.core.api.codetraceability.CodeTraceabilityState;
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.arcotl.code.CodeCompilationUnit;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.text.SentenceEntity;
import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic;
import edu.kit.kastel.mcse.ardoco.core.data.AbstractState;

@Deterministic
public class CodeTraceabilityStateImpl extends AbstractState implements CodeTraceabilityState {

private MutableList<SamCodeTraceLink> samCodeTraceLinks = Lists.mutable.empty();
private MutableList<SadCodeTraceLink> transitiveTraceLinks = Lists.mutable.empty();
private MutableList<TraceLink<ArchitectureEntity, CodeCompilationUnit>> samCodeTraceLinks = Lists.mutable.empty();
private MutableList<TraceLink<SentenceEntity, CodeCompilationUnit>> transitiveTraceLinks = Lists.mutable.empty();

public CodeTraceabilityStateImpl() {
super();
}

@Override
public boolean addSamCodeTraceLink(SamCodeTraceLink traceLink) {
public boolean addSamCodeTraceLink(TraceLink<ArchitectureEntity, CodeCompilationUnit> traceLink) {
return this.samCodeTraceLinks.add(traceLink);
}

@Override
public boolean addSamCodeTraceLinks(Collection<SamCodeTraceLink> traceLinks) {
public boolean addSamCodeTraceLinks(Collection<? extends TraceLink<ArchitectureEntity, CodeCompilationUnit>> traceLinks) {
return this.samCodeTraceLinks.addAll(traceLinks);
}

@Override
public ImmutableSet<SamCodeTraceLink> getSamCodeTraceLinks() {
public ImmutableSet<TraceLink<ArchitectureEntity, CodeCompilationUnit>> getSamCodeTraceLinks() {
return Sets.immutable.withAll(new LinkedHashSet<>(this.samCodeTraceLinks));
}

@Override
public boolean addSadCodeTraceLink(SadCodeTraceLink traceLink) {
public boolean addSadCodeTraceLink(TraceLink<SentenceEntity, CodeCompilationUnit> traceLink) {
return this.transitiveTraceLinks.add(traceLink);
}

@Override
public boolean addSadCodeTraceLinks(Collection<SadCodeTraceLink> traceLinks) {
public boolean addSadCodeTraceLinks(Collection<? extends TraceLink<SentenceEntity, CodeCompilationUnit>> traceLinks) {
return this.transitiveTraceLinks.addAll(traceLinks);
}

@Override
public ImmutableSet<SadCodeTraceLink> getSadCodeTraceLinks() {
public ImmutableSet<TraceLink<SentenceEntity, CodeCompilationUnit>> getSadCodeTraceLinks() {
return this.transitiveTraceLinks.toImmutableSet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.api.models.CodeModelType;
import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel;
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.tlr.codetraceability.informants.arcotl.TraceLinkGenerator;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.computationtree.Node;
import edu.kit.kastel.mcse.ardoco.core.common.util.DataRepositoryHelper;
import edu.kit.kastel.mcse.ardoco.core.data.DataRepository;
import edu.kit.kastel.mcse.ardoco.core.pipeline.agent.Informant;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.TraceLinkGenerator;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.computationtree.Node;

public class ArCoTLInformant extends Informant {
public ArCoTLInformant(DataRepository dataRepository) {
Expand All @@ -21,16 +22,16 @@ public ArCoTLInformant(DataRepository dataRepository) {

@Override
public void process() {
var dataRepository = getDataRepository();
var dataRepository = this.getDataRepository();
var modelStates = DataRepositoryHelper.getModelStatesData(dataRepository);
var samCodeTraceabilityState = DataRepositoryHelper.getCodeTraceabilityState(dataRepository);

ArchitectureModel architectureModel = null;
CodeModel codeModel = null;
for (var modelId : modelStates.modelIds()) {
if (isAnArchitectureModel(modelId)) {
if (ArCoTLInformant.isAnArchitectureModel(modelId)) {
architectureModel = (ArchitectureModel) modelStates.getModel(modelId);
} else if (isACodeModel(modelId)) {
} else if (ArCoTLInformant.isACodeModel(modelId)) {
codeModel = (CodeModel) modelStates.getModel(modelId);
}
}
Expand All @@ -40,12 +41,12 @@ public void process() {
samCodeTraceabilityState.addSamCodeTraceLinks(traceLinks);
}

private static boolean isACodeModel(String modelId) {
return Arrays.stream(CodeModelType.values()).anyMatch(codeModelType -> codeModelType.getModelId().equals(modelId));
private static boolean isACodeModel(Metamodel modelId) {
return Arrays.stream(CodeModelType.values()).anyMatch(codeModelType -> codeModelType.getMetamodel().equals(modelId));
}

private static boolean isAnArchitectureModel(String modelId) {
return Arrays.stream(ArchitectureModelType.values()).anyMatch(architectureModelType -> architectureModelType.getModelId().equals(modelId));
private static boolean isAnArchitectureModel(Metamodel modelId) {
return Arrays.stream(ArchitectureModelType.values()).anyMatch(architectureModelType -> architectureModelType.getMetamodel().equals(modelId));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
import edu.kit.kastel.mcse.ardoco.core.api.models.ModelStates;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.CodeModel;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.EndpointTuple;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SadCodeTraceLink;
import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.CodeTraceabilityStateImpl;
import edu.kit.kastel.mcse.ardoco.core.common.util.DataRepositoryHelper;
import edu.kit.kastel.mcse.ardoco.core.data.DataRepository;
import edu.kit.kastel.mcse.ardoco.core.pipeline.agent.Informant;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.CodeTraceabilityStateImpl;

@Deterministic
public class ArchitectureLinkToCodeLinkTransformerInformant extends Informant {
Expand All @@ -33,33 +32,33 @@ public ArchitectureLinkToCodeLinkTransformerInformant(DataRepository dataReposit
public void process() {
MutableSet<SadCodeTraceLink> sadCodeTracelinks = Sets.mutable.empty();

ModelStates modelStatesData = DataRepositoryHelper.getModelStatesData(getDataRepository());
ConnectionStates connectionStates = DataRepositoryHelper.getConnectionStates(getDataRepository());
ModelStates modelStatesData = DataRepositoryHelper.getModelStatesData(this.getDataRepository());
ConnectionStates connectionStates = DataRepositoryHelper.getConnectionStates(this.getDataRepository());
if (modelStatesData == null || connectionStates == null) {
return;
}

CodeModel codeModel = findCodeModel(modelStatesData);
CodeModel codeModel = this.findCodeModel(modelStatesData);

for (var traceLink : connectionStates.getConnectionState(Metamodel.CODE).getTraceLinks()) {
var modelElement = traceLink.getModelElementUid();
var mentionedCodeModelElements = findMentionedCodeModelElementsById(modelElement, codeModel);
var modelElement = traceLink.getSecondEndpoint().getId();
var mentionedCodeModelElements = this.findMentionedCodeModelElementsById(modelElement, codeModel);
for (var mid : mentionedCodeModelElements) {
sadCodeTracelinks.add(new SadCodeTraceLink(new EndpointTuple(traceLink.getEndpointTuple().firstEndpoint(), mid)));
sadCodeTracelinks.add(new SadCodeTraceLink(traceLink.getFirstEndpoint(), mid));
}
}

CodeTraceabilityState codeTraceabilityState = new CodeTraceabilityStateImpl();
getDataRepository().addData(CodeTraceabilityState.ID, codeTraceabilityState);
this.getDataRepository().addData(CodeTraceabilityState.ID, codeTraceabilityState);
codeTraceabilityState.addSadCodeTraceLinks(sadCodeTracelinks);
}

private List<CodeCompilationUnit> findMentionedCodeModelElementsById(String modelElementId, CodeModel codeModel) {
boolean isPackage = modelElementId.endsWith("/");
if (isPackage) {
return findAllClassesInPackage(modelElementId, codeModel);
return this.findAllClassesInPackage(modelElementId, codeModel);
}
return findCompilationUnitById(modelElementId, codeModel);
return this.findCompilationUnitById(modelElementId, codeModel);
}

private List<CodeCompilationUnit> findAllClassesInPackage(String modelElementId, CodeModel codeModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import edu.kit.kastel.mcse.ardoco.core.api.codetraceability.CodeTraceabilityState;
import edu.kit.kastel.mcse.ardoco.core.api.connectiongenerator.ConnectionStates;
import edu.kit.kastel.mcse.ardoco.core.api.models.ModelStates;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SadCodeTraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SadSamTraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SamCodeTraceLink;
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.TraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TransitiveTraceLink;
import edu.kit.kastel.mcse.ardoco.core.api.text.SentenceEntity;
import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic;
import edu.kit.kastel.mcse.ardoco.core.common.util.DataRepositoryHelper;
import edu.kit.kastel.mcse.ardoco.core.data.DataRepository;
Expand All @@ -28,10 +29,10 @@ public TraceLinkCombiner(DataRepository dataRepository) {

@Override
public void process() {
MutableSet<SadCodeTraceLink> transitiveTraceLinks = Sets.mutable.empty();
CodeTraceabilityState codeTraceabilityState = DataRepositoryHelper.getCodeTraceabilityState(getDataRepository());
ModelStates modelStatesData = DataRepositoryHelper.getModelStatesData(getDataRepository());
ConnectionStates connectionStates = DataRepositoryHelper.getConnectionStates(getDataRepository());
MutableSet<TraceLink<SentenceEntity, CodeCompilationUnit>> transitiveTraceLinks = Sets.mutable.empty();
CodeTraceabilityState codeTraceabilityState = DataRepositoryHelper.getCodeTraceabilityState(this.getDataRepository());
ModelStates modelStatesData = DataRepositoryHelper.getModelStatesData(this.getDataRepository());
ConnectionStates connectionStates = DataRepositoryHelper.getConnectionStates(this.getDataRepository());

if (codeTraceabilityState == null || modelStatesData == null || connectionStates == null) {
return;
Expand All @@ -42,23 +43,26 @@ public void process() {
var connectionState = connectionStates.getConnectionState(metamodel);
var sadSamTraceLinks = connectionState.getTraceLinks();

var combinedLinks = combineToTransitiveTraceLinks(sadSamTraceLinks, samCodeTraceLinks);
var combinedLinks = this.combineToTransitiveTraceLinks(sadSamTraceLinks, samCodeTraceLinks);
transitiveTraceLinks.addAll(combinedLinks.toList());
}

codeTraceabilityState.addSadCodeTraceLinks(transitiveTraceLinks);
}

private ImmutableSet<SadCodeTraceLink> combineToTransitiveTraceLinks(ImmutableSet<SadSamTraceLink> sadSamTraceLinks,
ImmutableSet<SamCodeTraceLink> samCodeTraceLinks) {
MutableSet<SadCodeTraceLink> transitiveTraceLinks = Sets.mutable.empty();
for (var sadSamTraceLink : sadSamTraceLinks) {
String modelElementUid = sadSamTraceLink.getModelElementUid();
for (var samCodeTraceLink : samCodeTraceLinks) {
private ImmutableSet<TraceLink<SentenceEntity, CodeCompilationUnit>> combineToTransitiveTraceLinks(
ImmutableSet<? extends TraceLink<SentenceEntity, ArchitectureEntity>> sadSamTraceLinks,
ImmutableSet<? extends TraceLink<ArchitectureEntity, CodeCompilationUnit>> samCodeTraceLinks) {

MutableSet<TraceLink<SentenceEntity, CodeCompilationUnit>> transitiveTraceLinks = Sets.mutable.empty();

for (TraceLink<SentenceEntity, ArchitectureEntity> sadSamTraceLink : sadSamTraceLinks) {
String modelElementUid = sadSamTraceLink.getSecondEndpoint().getId();
for (TraceLink<ArchitectureEntity, CodeCompilationUnit> samCodeTraceLink : samCodeTraceLinks) {
String samCodeTraceLinkModelElementId = samCodeTraceLink.getEndpointTuple().firstEndpoint().getId();
if (modelElementUid.equals(samCodeTraceLinkModelElementId)) {
var transitiveTraceLinkOptional = TransitiveTraceLink.createTransitiveTraceLink(sadSamTraceLink, samCodeTraceLink);
transitiveTraceLinkOptional.ifPresent(transitiveTraceLinks::add);
transitiveTraceLinkOptional.ifPresent(it -> transitiveTraceLinks.add(it));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import java.util.SortedSet;
import java.util.TreeSet;

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.CodeModule;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodePackage;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.pipeline.CoreDocument;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import java.util.SortedSet;
import java.util.TreeSet;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
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.architecture.ArchitectureItem;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.EndpointTuple;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SamCodeTraceLink;
import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.ArrayList;
import java.util.List;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity;
import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.NodeResult;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.computationtree.AggregationNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import java.util.List;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.Confidence;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.NodeResult;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.computationtree.AggregationNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import java.util.List;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.NodeResult;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.computationtree.AggregationNode;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.computationtree.Node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.util.List;
import java.util.Objects;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
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.entity.Entity;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.NodeResult;

public abstract class Matcher extends Aggregation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import java.util.Objects;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureComponent;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureInterface;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureItem;
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.InterfaceUnit;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.NameComparisonUtils;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.Confidence;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import java.util.SortedSet;
import java.util.TreeSet;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureComponent;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureInterface;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureItem;
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.entity.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.EndpointTuple;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.NameComparisonUtils;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.Confidence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import java.util.List;
import java.util.Objects;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureComponent;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureInterface;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit;
import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.NameComparisonUtils;
import edu.kit.kastel.mcse.ardoco.tlr.codetraceability.informants.arcotl.computation.Confidence;

Expand Down
Loading

0 comments on commit 40af515

Please sign in to comment.