Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.dataflowanalysis.analysis.core.AbstractTransposeFlowGraph;
import org.dataflowanalysis.analysis.core.AbstractVertex;
import org.dataflowanalysis.analysis.core.CharacteristicValue;
import org.dataflowanalysis.analysis.core.DataFlowVariable;
import org.dataflowanalysis.analysis.core.DataCharacteristic;
import org.dataflowanalysis.analysis.core.FlowGraphCollection;
import org.dataflowanalysis.analysis.pcm.PCMDataFlowConfidentialityAnalysisBuilder;
import org.dataflowanalysis.analysis.pcm.core.AbstractPCMVertex;
Expand Down Expand Up @@ -180,9 +180,9 @@ private void createFlowBetweenPreviousAndCurrentNode(Node source, Node dest, Abs
if (source == null || dest == null) {
return;
}
List<DataFlowVariable> flowVariables = pcmVertex.getAllDataFlowVariables();
for (DataFlowVariable flowVariable : flowVariables) {
String flowName = flowVariable.variableName();
List<DataCharacteristic> dataCharacteristics = pcmVertex.getAllDataCharacteristics();
for (DataCharacteristic dataCharacteristic : dataCharacteristics) {
String flowName = dataCharacteristic.variableName();

dataFlowDiagram.getFlows()
.stream()
Expand Down Expand Up @@ -262,7 +262,7 @@ private Node getDFDNode(AbstractPCMVertex<? extends Entity> pcmVertex) {
dfdNode = createDFDNode(pcmVertex);
}

addNodeCharacteristicsToNode(dfdNode, pcmVertex.getAllNodeCharacteristics());
addNodeCharacteristicsToNode(dfdNode, pcmVertex.getAllVertexCharacteristics());

return dfdNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ public AbstractTransposeFlowGraph evaluate() {
return new DFDTransposeFlowGraph(newSink);
}

@Override
public AbstractTransposeFlowGraph copy() {
DFDVertex copiedSink = ((DFDVertex) sink).clone();
copiedSink.unify(new HashSet<>());
return new DFDTransposeFlowGraph(copiedSink);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.stream.Collectors;
import org.dataflowanalysis.analysis.core.AbstractVertex;
import org.dataflowanalysis.analysis.core.CharacteristicValue;
import org.dataflowanalysis.analysis.core.DataFlowVariable;
import org.dataflowanalysis.analysis.core.DataCharacteristic;
import org.dataflowanalysis.dfd.datadictionary.AND;
import org.dataflowanalysis.dfd.datadictionary.AbstractAssignment;
import org.dataflowanalysis.dfd.datadictionary.Assignment;
Expand Down Expand Up @@ -50,7 +50,7 @@ public DFDVertex(Node node, Map<Pin, DFDVertex> pinDFDVertexMap, Map<Pin, Flow>
}

/**
* Evaluates the given vertex by determining incoming and outgoing data flow variables and node characteristics
* Evaluates the given vertex by determining incoming and outgoing data characteristics and node characteristics
*/
@Override
public void evaluateDataFlow() {
Expand All @@ -59,19 +59,19 @@ public void evaluateDataFlow() {
}
evaluatePreviousVertices();

List<CharacteristicValue> nodeCharacteristics = determineNodeCharacteristics();
List<CharacteristicValue> vertexCharacteristics = determineNodeCharacteristics();

Map<Pin, List<Label>> inputPinsIncomingLabelMap = new HashMap<>();
this.getPinFlowMap()
.keySet()
.forEach(pin -> this.fillMapOfIncomingLabelsPerPin(pin, inputPinsIncomingLabelMap));

List<DataFlowVariable> dataFlowVariables = new ArrayList<>(this.createDataFlowVariablesFromLabels(inputPinsIncomingLabelMap));
List<DataCharacteristic> dataCharacteristics = new ArrayList<>(this.createDataCharacteristicsFromLabels(inputPinsIncomingLabelMap));

Map<Pin, List<Label>> outputPinsOutgoingLabelMap = determineOutputPinOutgoingLabelMap(inputPinsIncomingLabelMap);

List<DataFlowVariable> outgoingDataFlowVariables = new ArrayList<>(this.createDataFlowVariablesFromLabels(outputPinsOutgoingLabelMap));
this.setPropagationResult(dataFlowVariables, outgoingDataFlowVariables, nodeCharacteristics);
List<DataCharacteristic> outgoingDataCharacteristics = new ArrayList<>(this.createDataCharacteristicsFromLabels(outputPinsOutgoingLabelMap));
this.setPropagationResult(dataCharacteristics, outgoingDataCharacteristics, vertexCharacteristics);
}

/**
Expand Down Expand Up @@ -120,16 +120,16 @@ private void evaluatePreviousVertices() {
private void fillMapOfIncomingLabelsPerPin(Pin pin, Map<Pin, List<Label>> inputPinsIncomingLabelMap) {
for (var previousVertex : this.getPinDFDVertexMap()
.values()) {
for (var dfv : previousVertex.getAllOutgoingDataFlowVariables()) {
if (dfv.variableName()
for (var dataFlowCharacteristics : previousVertex.getAllOutgoingDataCharacteristics()) {
if (dataFlowCharacteristics.getVariableName()
.equals(this.getPinFlowMap()
.get(pin)
.getSourcePin()
.getId())) {
inputPinsIncomingLabelMap.putIfAbsent(pin, new ArrayList<>());
for (var cv : dfv.getAllCharacteristics()) {
for (var characteristicValue : dataFlowCharacteristics.getAllCharacteristics()) {
inputPinsIncomingLabelMap.get(pin)
.add(((DFDCharacteristicValue) cv).getLabel());
.add(((DFDCharacteristicValue) characteristicValue).getLabel());
}
}
}
Expand Down Expand Up @@ -163,16 +163,16 @@ private void handleOutgoingAssignments(AbstractAssignment assignment, Map<Pin, L
}

/**
* Create Data Flow Variables from Map mapping Input/Output Pin to labels. Important: The name of the data flow variable
* is equal to the id of the pin. Any changes in the data flow variable naming scheme will require changes in the
* evaluation logic
* Create data characteristics from Map mapping Input/Output Pin to labels. Important: The name of the data
* characteristic is equal to the id of the pin. Any changes in the data characteristics naming scheme will require
* changes in the evaluation logic
* @param pinToLabelMap Map mapping Input/Output Pin to labels
* @return List of created Data Flow Variables
* @return List of created data characteristics
*/
private List<DataFlowVariable> createDataFlowVariablesFromLabels(Map<Pin, List<Label>> pinToLabelMap) {
private List<DataCharacteristic> createDataCharacteristicsFromLabels(Map<Pin, List<Label>> pinToLabelMap) {
return pinToLabelMap.keySet()
.stream()
.map(pin -> new DataFlowVariable(pin.getId(), this.getCharacteristicValuesForPin(pin, pinToLabelMap)))
.map(pin -> new DataCharacteristic(pin.getId(), this.getCharacteristicValuesForPin(pin, pinToLabelMap)))
.toList();
}

Expand Down Expand Up @@ -270,7 +270,7 @@ public void unify(Set<DFDVertex> vertices) {
}

/**
* Creates a clone of the vertex without considering data flow variables nor characteristics
* Creates a clone of the vertex without considering data characteristics nor vertex characteristics
*/
public DFDVertex clone() {
Map<Pin, DFDVertex> copiedPinDFDVertexMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.apache.log4j.Logger;
import org.dataflowanalysis.analysis.core.AbstractVertex;
import org.dataflowanalysis.analysis.core.CharacteristicValue;
import org.dataflowanalysis.analysis.core.DataFlowVariable;
import org.dataflowanalysis.analysis.core.DataCharacteristic;
import org.dataflowanalysis.analysis.resource.ResourceProvider;
import org.dataflowanalysis.pcm.extension.model.confidentiality.ConfidentialityVariableCharacterisation;
import org.palladiosimulator.pcm.core.composition.AssemblyContext;
Expand Down Expand Up @@ -50,19 +50,19 @@ public AbstractPCMVertex(T referencedElement, List<? extends AbstractPCMVertex<?
this.previousElements = previousElements;
}

public abstract AbstractPCMVertex<?> deepCopy(Map<AbstractPCMVertex<?>, AbstractPCMVertex<?>> vertexMapping);
public abstract AbstractPCMVertex<?> copy(Map<AbstractPCMVertex<?>, AbstractPCMVertex<?>> vertexMapping);

/**
* Sets the propagation result of the Vertex to the given result. This method should only be called once on elements
* that are not evaluated.
* @param incomingDataFlowVariables Incoming data flow variables that flow into the vertex
* @param outgoingDataFlowVariables Outgoing data flow variables that flow out of the vertex
* @param incomingDataCharacteristics Incoming data characteristics that flow into the vertex
* @param outgoingDataCharacteristics Outgoing data characteristics that flow out of the vertex
* @param vertexCharacteristics Vertex characteristics present at the node
*/
@Override
protected void setPropagationResult(List<DataFlowVariable> incomingDataFlowVariables, List<DataFlowVariable> outgoingDataFlowVariables,
protected void setPropagationResult(List<DataCharacteristic> incomingDataCharacteristics, List<DataCharacteristic> outgoingDataCharacteristics,
List<CharacteristicValue> vertexCharacteristics) {
super.setPropagationResult(incomingDataFlowVariables, outgoingDataFlowVariables, vertexCharacteristics);
super.setPropagationResult(incomingDataCharacteristics, outgoingDataCharacteristics, vertexCharacteristics);
}

@Override
Expand All @@ -74,7 +74,7 @@ public void setPreviousElements(List<? extends AbstractPCMVertex<?>> previousEle
this.previousElements = previousElements;
}

protected List<DataFlowVariable> getIncomingDataFlowVariables() {
protected List<DataCharacteristic> getIncomingDataCharacteristics() {
if (super.isSource())
return List.of();

Expand All @@ -84,7 +84,7 @@ protected List<DataFlowVariable> getIncomingDataFlowVariables() {
.forEach(AbstractVertex::evaluateDataFlow);
return this.getPreviousElements()
.stream()
.flatMap(it -> it.getAllOutgoingDataFlowVariables()
.flatMap(it -> it.getAllOutgoingDataCharacteristics()
.stream())
.collect(Collectors.toList());
}
Expand All @@ -100,15 +100,15 @@ protected List<CharacteristicValue> getVertexCharacteristics() {

/**
* Calculate the data characteristics for the vertex with the given vertex characteristics, variable characterizations
* and old data flow variables
* and old data characteristics
* @param vertexCharacteristics Vertex characteristics present at the vertex
* @param variableCharacterisations Variable characterizations present in the model
* @param oldDataFlowVariables Old data flow variables present at the node
* @param oldDataCharacteristics Old data characteristics present at the node
* @return Returns a list of data characteristics that are applied to the sequence element
*/
protected List<DataFlowVariable> getDataFlowVariables(List<CharacteristicValue> vertexCharacteristics,
List<ConfidentialityVariableCharacterisation> variableCharacterisations, List<DataFlowVariable> oldDataFlowVariables) {
PCMDataCharacteristicsCalculator dataCharacteristicsCalculator = new PCMDataCharacteristicsCalculator(oldDataFlowVariables,
protected List<DataCharacteristic> getDataCharacteristics(List<CharacteristicValue> vertexCharacteristics,
List<ConfidentialityVariableCharacterisation> variableCharacterisations, List<DataCharacteristic> oldDataCharacteristics) {
PCMDataCharacteristicsCalculator dataCharacteristicsCalculator = new PCMDataCharacteristicsCalculator(oldDataCharacteristics,
vertexCharacteristics, this.resourceProvider);
variableCharacterisations.forEach(dataCharacteristicsCalculator::evaluate);
return dataCharacteristicsCalculator.getCalculatedCharacteristics();
Expand Down Expand Up @@ -141,13 +141,13 @@ protected void checkCallParameter(OperationSignature callSignature, List<Confide

protected AbstractPCMVertex<?> updateCopy(AbstractPCMVertex<?> copy, Map<AbstractPCMVertex<?>, AbstractPCMVertex<?>> vertexMapping) {
if (this.isEvaluated()) {
copy.setPropagationResult(this.getAllIncomingDataFlowVariables(), this.getAllOutgoingDataFlowVariables(),
copy.setPropagationResult(this.getAllIncomingDataCharacteristics(), this.getAllOutgoingDataCharacteristics(),
this.getVertexCharacteristics());
}
vertexMapping.put(this, copy);

List<? extends AbstractPCMVertex<?>> clonedPreviousElements = this.previousElements.stream()
.map(it -> it.deepCopy(vertexMapping))
.map(it -> it.copy(vertexMapping))
.toList();

copy.setPreviousElements(clonedPreviousElements);
Expand Down
Loading