Skip to content

Commit

Permalink
replac ModelProviderAgent with ArCoTLModelProviderAgent and add HoldB…
Browse files Browse the repository at this point in the history
…ackElementsExtractor
  • Loading branch information
Laxraa committed Sep 25, 2023
1 parent e344ced commit 13006be
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 126 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl;

import edu.kit.kastel.mcse.ardoco.core.api.models.Entity;

import java.util.List;
import java.util.Objects;

public class HoldBackModel extends Model {

private final List<? extends Entity> content;
private final List<? extends Entity> endpoints;

public HoldBackModel(List<? extends Entity> content, List<? extends Entity> endpoints) {
this.content = content;
this.endpoints = endpoints;
}

@Override
public List<? extends Entity> getContent() {
return this.content;
}

@Override
public List<? extends Entity> getEndpoints() {
return this.endpoints;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (!super.equals(o))
return false;
HoldBackModel that = (HoldBackModel) o;
return Objects.equals(content, that.content) && Objects.equals(endpoints, that.endpoints);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), content, endpoints);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,35 @@
package edu.kit.kastel.mcse.ardoco.core.execution.runner;

import java.io.File;
import java.io.IOException;
import java.util.Map;

import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.common.util.CommonUtilities;
import edu.kit.kastel.mcse.ardoco.core.common.util.DataRepositoryHelper;
import edu.kit.kastel.mcse.ardoco.core.connectiongenerator.ConnectionGenerator;
import edu.kit.kastel.mcse.ardoco.core.execution.ArDoCo;
import edu.kit.kastel.mcse.ardoco.core.inconsistency.InconsistencyChecker;
import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;
import edu.kit.kastel.mcse.ardoco.core.recommendationgenerator.RecommendationGenerator;
import edu.kit.kastel.mcse.ardoco.core.text.providers.TextPreprocessingAgent;
import edu.kit.kastel.mcse.ardoco.core.textextraction.TextExtraction;

public class ArDoCoForInconsistencyDetection extends ArDoCoRunner {
private static final Logger logger = LoggerFactory.getLogger(ArDoCoForInconsistencyDetection.class);

public ArDoCoForInconsistencyDetection(String projectName) {
super(projectName);
}

public void setUp(File inputText, File inputModelArchitecture, ArchitectureModelType inputArchitectureModelType, File inputCode, Map<String, String> additionalConfigs,
public void setUp(File inputText, File inputModelArchitecture, ArchitectureModelType inputArchitectureModelType, Map<String, String> additionalConfigs,
File outputDir) {
try {
definePipeline(inputText, inputModelArchitecture, inputArchitectureModelType, inputCode, additionalConfigs);
} catch (IOException e) {
logger.error("Problem in initialising pipeline when loading data (IOException)", e.getCause());
isSetUp = false;
return;
}
definePipeline(inputText, inputModelArchitecture, inputArchitectureModelType, additionalConfigs);
setOutputDirectory(outputDir);
isSetUp = true;
}

public void setUp(String inputTextLocation, String inputArchitectureModelLocation, ArchitectureModelType architectureModelType,
String inputCodeLocation, Map<String, String> additionalConfigs, String outputDirectory) {
setUp(new File(inputTextLocation), new File(inputArchitectureModelLocation), architectureModelType, new File(inputCodeLocation), additionalConfigs, new File(outputDirectory));
Map<String, String> additionalConfigs, String outputDirectory) {
setUp(new File(inputTextLocation), new File(inputArchitectureModelLocation), architectureModelType, additionalConfigs, new File(outputDirectory));
}

/**
Expand All @@ -52,10 +40,8 @@ public void setUp(String inputTextLocation, String inputArchitectureModelLocatio
* @param inputArchitectureModel the input architecture file
* @param architectureModelType the type of the architecture (e.g., PCM, UML)
* @param additionalConfigs the additional configs
* @throws IOException When one of the input files cannot be accessed/loaded
*/
private void definePipeline(File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType, File inputCode, Map<String, String> additionalConfigs)
throws IOException {
private void definePipeline(File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType, Map<String, String> additionalConfigs) {
ArDoCo arDoCo = getArDoCo();
var dataRepository = arDoCo.getDataRepository();
var text = CommonUtilities.readInputText(inputText);
Expand All @@ -65,7 +51,7 @@ private void definePipeline(File inputText, File inputArchitectureModel, Archite
DataRepositoryHelper.putInputText(dataRepository, text);

arDoCo.addPipelineStep(TextPreprocessingAgent.get(additionalConfigs, dataRepository));
arDoCo.addPipelineStep(ArCoTLModelProviderAgent.get(inputArchitectureModel, architectureModelType, inputCode, additionalConfigs, dataRepository));
arDoCo.addPipelineStep(ArCoTLModelProviderAgent.get(inputArchitectureModel, architectureModelType, additionalConfigs, dataRepository));
arDoCo.addPipelineStep(TextExtraction.get(additionalConfigs, dataRepository));
arDoCo.addPipelineStep(RecommendationGenerator.get(additionalConfigs, dataRepository));
arDoCo.addPipelineStep(ConnectionGenerator.get(additionalConfigs, dataRepository));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
import java.io.IOException;
import java.util.Map;

import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.common.util.CommonUtilities;
import edu.kit.kastel.mcse.ardoco.core.common.util.DataRepositoryHelper;
import edu.kit.kastel.mcse.ardoco.core.connectiongenerator.ConnectionGenerator;
import edu.kit.kastel.mcse.ardoco.core.execution.ArDoCo;
import edu.kit.kastel.mcse.ardoco.core.inconsistency.InconsistencyChecker;
import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;
import edu.kit.kastel.mcse.ardoco.core.recommendationgenerator.RecommendationGenerator;
import edu.kit.kastel.mcse.ardoco.core.text.providers.TextPreprocessingAgent;
import edu.kit.kastel.mcse.ardoco.core.textextraction.TextExtraction;
Expand All @@ -25,28 +21,21 @@
* The Runner for the Linking Sketches and Software Architecture Approach (LiSSA)
*/
public class ArDoCoForLiSSA extends ArDoCoRunner {
private static final Logger logger = LoggerFactory.getLogger(ArDoCoForLiSSA.class);

public ArDoCoForLiSSA(String projectName) {
super(projectName);
}

public void setUp(File diagramDirectory, File inputText, File inputModelArchitecture, ArchitectureModelType inputArchitectureModelType,
File inputCode, Map<String, String> additionalConfigs, File outputDir) {
try {
definePipeline(diagramDirectory, inputText, inputModelArchitecture, inputArchitectureModelType, inputCode, additionalConfigs);
} catch (IOException e) {
logger.error("Problem in initialising pipeline when loading data (IOException)", e.getCause());
isSetUp = false;
return;
}
Map<String, String> additionalConfigs, File outputDir) {
definePipeline(diagramDirectory, inputText, inputModelArchitecture, inputArchitectureModelType, additionalConfigs);
setOutputDirectory(outputDir);
isSetUp = true;
}

public void setUp(String diagramDirectory, String inputTextLocation, String inputArchitectureModelLocation, ArchitectureModelType architectureModelType,
String inputCodeLocation, Map<String, String> additionalConfigs, String outputDirectory) {
setUp(new File(diagramDirectory), new File(inputTextLocation), new File(inputArchitectureModelLocation), architectureModelType, new File(inputCodeLocation),
Map<String, String> additionalConfigs, String outputDirectory) {
setUp(new File(diagramDirectory), new File(inputTextLocation), new File(inputArchitectureModelLocation), architectureModelType,
additionalConfigs, new File(outputDirectory));
}

Expand All @@ -61,7 +50,7 @@ public void setUp(String diagramDirectory, String inputTextLocation, String inpu
* @throws IOException When one of the input files cannot be accessed/loaded
*/
private void definePipeline(File diagramDirectory, File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType,
File inputCode, Map<String, String> additionalConfigs) throws IOException {
Map<String, String> additionalConfigs) {
ArDoCo arDoCo = getArDoCo();
var dataRepository = arDoCo.getDataRepository();
var text = CommonUtilities.readInputText(inputText);
Expand All @@ -73,7 +62,7 @@ private void definePipeline(File diagramDirectory, File inputText, File inputArc

arDoCo.addPipelineStep(DiagramRecognition.get(additionalConfigs, dataRepository));
arDoCo.addPipelineStep(TextPreprocessingAgent.get(additionalConfigs, dataRepository));
arDoCo.addPipelineStep(ArCoTLModelProviderAgent.get(inputArchitectureModel, architectureModelType, inputCode, additionalConfigs, dataRepository));
arDoCo.addPipelineStep(ArCoTLModelProviderAgent.get(inputArchitectureModel, architectureModelType, additionalConfigs, dataRepository));
arDoCo.addPipelineStep(TextExtraction.get(additionalConfigs, dataRepository));
arDoCo.addPipelineStep(RecommendationGenerator.get(additionalConfigs, dataRepository));
arDoCo.addPipelineStep(ConnectionGenerator.get(additionalConfigs, dataRepository));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import edu.kit.kastel.mcse.ardoco.core.connectiongenerator.ConnectionGenerator;
import edu.kit.kastel.mcse.ardoco.core.execution.runner.ArDoCoRunner;
import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;
import edu.kit.kastel.mcse.ardoco.core.models.ModelProviderAgent;
import edu.kit.kastel.mcse.ardoco.core.recommendationgenerator.RecommendationGenerator;
import edu.kit.kastel.mcse.ardoco.core.text.providers.TextPreprocessingAgent;
import edu.kit.kastel.mcse.ardoco.core.textextraction.TextExtraction;
Expand Down Expand Up @@ -43,7 +42,7 @@ private void definePipeline(File inputText, File inputArchitectureModel, Archite
ArCoTLModelProviderAgent arCoTLModelProviderAgent = ArCoTLModelProviderAgent.get(inputArchitectureModel, architectureModelType, inputCode,
additionalConfigs, dataRepository);
arDoCo.addPipelineStep(arCoTLModelProviderAgent);
arDoCo.addPipelineStep(ModelProviderAgent.getCodeProvider(dataRepository));
// arDoCo.addPipelineStep(ModelProviderAgent.getCodeProvider(dataRepository)); Todo: is this step needed?

arDoCo.addPipelineStep(TextPreprocessingAgent.get(additionalConfigs, dataRepository));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
package edu.kit.kastel.mcse.ardoco.core.execution;

import java.io.File;
import java.io.IOException;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.codetraceability.SadSamCodeTraceabilityLinkRecovery;
import edu.kit.kastel.mcse.ardoco.core.codetraceability.SamCodeTraceabilityLinkRecovery;
Expand All @@ -21,28 +17,20 @@
import edu.kit.kastel.mcse.ardoco.core.textextraction.TextExtraction;

public class ArDoCoForSadSamCodeTraceabilityLinkRecovery extends ArDoCoRunner {
private static final Logger logger = LoggerFactory.getLogger(ArDoCoForSadSamCodeTraceabilityLinkRecovery.class);

public ArDoCoForSadSamCodeTraceabilityLinkRecovery(String projectName) {
super(projectName);
}

public void setUp(File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType, File inputCode,
Map<String, String> additionalConfigs, File outputDir) {
try {
definePipeline(inputText, inputArchitectureModel, architectureModelType, inputCode, additionalConfigs);
} catch (IOException e) {
logger.error("Problem in initialising pipeline when loading data (IOException)", e.getCause());
isSetUp = false;
return;
}

definePipeline(inputText, inputArchitectureModel, architectureModelType, inputCode, additionalConfigs);
setOutputDirectory(outputDir);
isSetUp = true;
}

private void definePipeline(File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType, File inputCode,
Map<String, String> additionalConfigs) throws IOException {
Map<String, String> additionalConfigs) {
ArDoCo arDoCo = this.getArDoCo();
var dataRepository = arDoCo.getDataRepository();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,37 @@
package edu.kit.kastel.mcse.ardoco.core.execution;

import java.io.File;
import java.io.IOException;
import java.util.Map;

import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.common.util.CommonUtilities;
import edu.kit.kastel.mcse.ardoco.core.common.util.DataRepositoryHelper;
import edu.kit.kastel.mcse.ardoco.core.connectiongenerator.ConnectionGenerator;
import edu.kit.kastel.mcse.ardoco.core.execution.runner.ArDoCoRunner;
import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;
import edu.kit.kastel.mcse.ardoco.core.recommendationgenerator.RecommendationGenerator;
import edu.kit.kastel.mcse.ardoco.core.text.providers.TextPreprocessingAgent;
import edu.kit.kastel.mcse.ardoco.core.textextraction.TextExtraction;

public class ArDoCoForSadSamTraceabilityLinkRecovery extends ArDoCoRunner {
private static final Logger logger = LoggerFactory.getLogger(ArDoCoForSadSamTraceabilityLinkRecovery.class);

public ArDoCoForSadSamTraceabilityLinkRecovery(String projectName) {
super(projectName);
}

public void setUp(File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType, File inputCode, Map<String, String> additionalConfigs,
public void setUp(File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType, Map<String, String> additionalConfigs,
File outputDir) {
try {
definePipeline(inputText, inputArchitectureModel, architectureModelType, inputCode, additionalConfigs);
} catch (IOException e) {
logger.error("Problem in initialising pipeline when loading data (IOException)", e.getCause());
isSetUp = false;
return;
}
definePipeline(inputText, inputArchitectureModel, architectureModelType, additionalConfigs);
setOutputDirectory(outputDir);
isSetUp = true;
}

public void setUp(String inputTextLocation, String inputArchitectureModelLocation, ArchitectureModelType architectureModelType, String inputCodeLocation,
public void setUp(String inputTextLocation, String inputArchitectureModelLocation, ArchitectureModelType architectureModelType,
Map<String, String> additionalConfigs, String outputDirectory) {
setUp(new File(inputTextLocation), new File(inputArchitectureModelLocation), architectureModelType, new File(inputCodeLocation), additionalConfigs, new File(outputDirectory));
setUp(new File(inputTextLocation), new File(inputArchitectureModelLocation), architectureModelType, additionalConfigs, new File(outputDirectory));
}

private void definePipeline(File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType, File inputCode, Map<String, String> additionalConfigs)
throws IOException {
private void definePipeline(File inputText, File inputArchitectureModel, ArchitectureModelType architectureModelType, Map<String, String> additionalConfigs) {
var dataRepository = this.getArDoCo().getDataRepository();
var text = CommonUtilities.readInputText(inputText);
if (text.isBlank()) {
Expand All @@ -54,7 +41,7 @@ private void definePipeline(File inputText, File inputArchitectureModel, Archite
DataRepositoryHelper.putInputText(dataRepository, text);

this.getArDoCo().addPipelineStep(TextPreprocessingAgent.get(additionalConfigs, dataRepository));
this.getArDoCo().addPipelineStep(ArCoTLModelProviderAgent.get(inputArchitectureModel, architectureModelType, inputCode, additionalConfigs, dataRepository));
this.getArDoCo().addPipelineStep(ArCoTLModelProviderAgent.get(inputArchitectureModel, architectureModelType, additionalConfigs, dataRepository));

this.getArDoCo().addPipelineStep(TextExtraction.get(additionalConfigs, dataRepository));
this.getArDoCo().addPipelineStep(RecommendationGenerator.get(additionalConfigs, dataRepository));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,32 @@ public ArCoTLModelProviderAgent(DataRepository data, List<Extractor> extractors)

public static ArCoTLModelProviderAgent get(File inputArchitectureModel, ArchitectureModelType architectureModelType, File inputCode,
Map<String, String> additionalConfigs, DataRepository dataRepository) {
ArchitectureExtractor architectureExtractor = switch (architectureModelType) {
case PCM -> new PcmExtractor(inputArchitectureModel.getAbsolutePath());
case UML -> new UmlExtractor(inputArchitectureModel.getAbsolutePath());
};
ArchitectureExtractor architectureExtractor = getArchitectureExtractor(inputArchitectureModel, architectureModelType);

CodeItemRepository codeItemRepository = new CodeItemRepository();
CodeExtractor codeExtractor = new AllLanguagesExtractor(codeItemRepository, inputCode.getAbsolutePath());

ArCoTLModelProviderAgent agent = new ArCoTLModelProviderAgent(dataRepository, List.of(architectureExtractor, codeExtractor));
agent.applyConfiguration(additionalConfigs);
return agent;
}

public static ArCoTLModelProviderAgent get(File inputArchitectureModel, ArchitectureModelType architectureModelType,
Map<String, String> additionalConfigs, DataRepository dataRepository) {
ArchitectureExtractor architectureExtractor = getArchitectureExtractor(inputArchitectureModel, architectureModelType);

ArCoTLModelProviderAgent agent = new ArCoTLModelProviderAgent(dataRepository, List.of(architectureExtractor));
agent.applyConfiguration(additionalConfigs);
return agent;
}

private static ArchitectureExtractor getArchitectureExtractor(File inputArchitectureModel, ArchitectureModelType architectureModelType) {
return switch (architectureModelType) {
case PCM -> new PcmExtractor(inputArchitectureModel.getAbsolutePath());
case UML -> new UmlExtractor(inputArchitectureModel.getAbsolutePath());
};
}

@Override
protected void delegateApplyConfigurationToInternalObjects(Map<String, String> additionalConfiguration) {
// empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private ModelProviderAgent(DataRepository data, LegacyCodeModelInformant codeMod
}

/**
* Creates a {@link ModelProviderInformant} for PCM.
* Creates a {@link ModelProviderAgent} for PCM.
*
* @param inputArchitectureModel the path to the input PCM
* @param architectureModelType the architecture model to use
Expand Down
Loading

0 comments on commit 13006be

Please sign in to comment.