Skip to content
Open
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 @@ -14,7 +14,7 @@ public MemoryGDPRResourceProvider(GDPRModelBuilder modelBuilder) {
}

@Override
public LegalAssessmentFacts getModel() {
public LegalAssessmentFacts getGDPRModel() {
return modelBuilder.getGdprModel();
}

Expand Down
14 changes: 8 additions & 6 deletions bundles/mdpa.gdpr.analysis/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ Export-Package: mdpa.gdpr.analysis,
mdpa.gdpr.analysis.core,
mdpa.gdpr.analysis.core.resource,
mdpa.gdpr.analysis.dfd
Import-Package: org.antlr.runtime;version="3.2.0",
org.eclipse.xtext.parser.antlr
Require-Bundle: mdpa.gdpr.dfdconverter;bundle-version="1.0.0",
mdpa.gdpr.dfdconverter.tracemodel;bundle-version="0.1.0",
org.dataflowanalysis.analysis;bundle-version="2.0.0",
org.dataflowanalysis.analysis,
mdpa.gdpr.metamodel.contextproperties;bundle-version="0.1.0",
org.dataflowanalysis.analysis.dfd;bundle-version="2.0.0",
org.dataflowanalysis.analysis.dfd,
org.apache.log4j;bundle-version="1.2.24",
org.eclipse.core.runtime;bundle-version="3.26.100",
tools.mdsd.library.standalone.initialization;bundle-version="0.3.0",
tools.mdsd.library.standalone.initialization.log4j;bundle-version="0.3.0",
org.eclipse.emf.ecore.xmi;bundle-version="2.18.0"
org.eclipse.core.runtime,
tools.mdsd.library.standalone.initialization,
tools.mdsd.library.standalone.initialization.log4j,
org.eclipse.emf.ecore.xmi
Automatic-Module-Name: mdpa.gdpr.analysis
Bundle-RequiredExecutionEnvironment: JavaSE-17
68 changes: 68 additions & 0 deletions bundles/mdpa.gdpr.analysis/src/mdpa/gdpr/analysis/DFDUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package mdpa.gdpr.analysis;

import org.dataflowanalysis.dfd.datadictionary.AbstractAssignment;
import org.dataflowanalysis.dfd.datadictionary.Assignment;
import org.dataflowanalysis.dfd.datadictionary.Behavior;
import org.dataflowanalysis.dfd.datadictionary.Pin;
import org.dataflowanalysis.dfd.datadictionary.datadictionaryFactory;
import org.dataflowanalysis.dfd.dataflowdiagram.External;
import org.dataflowanalysis.dfd.dataflowdiagram.Node;
import org.dataflowanalysis.dfd.dataflowdiagram.Store;
import org.dataflowanalysis.dfd.dataflowdiagram.dataflowdiagramFactory;

import java.util.Objects;

public class DFDUtils {
public DFDUtils() {
}

/**
* Deep copies the given Node
*
* @param oldNode Given node that should be copied
* @return Copy of the given node
*/
public Node copyNode(Node oldNode) {
Node node;
if (oldNode instanceof External) {
node = dataflowdiagramFactory.eINSTANCE.createExternal();
} else if (oldNode instanceof Store) {
node = dataflowdiagramFactory.eINSTANCE.createStore();
} else {
node = dataflowdiagramFactory.eINSTANCE.createProcess();
}
node.setId(oldNode.getId());
node.setEntityName(oldNode.getEntityName());
node.getProperties().addAll(oldNode.getProperties());
Behavior behavior = datadictionaryFactory.eINSTANCE.createBehavior();
behavior.getInPin().addAll(oldNode.getBehavior().getInPin().stream().map(pin -> {
Pin copy = datadictionaryFactory.eINSTANCE.createPin();
copy.setId(pin.getId());
copy.setEntityName(pin.getEntityName());
return copy;
}).toList());
behavior.getOutPin().addAll(oldNode.getBehavior().getOutPin().stream().map(pin -> {
Pin copy = datadictionaryFactory.eINSTANCE.createPin();
copy.setId(pin.getId());
copy.setEntityName(pin.getEntityName());
return copy;
}).toList());
behavior.getAssignment().forEach(it -> {
AbstractAssignment copy;
if (it instanceof Assignment oldAssignment) {
Assignment newAssignment = datadictionaryFactory.eINSTANCE.createAssignment();
for (Pin inputPin : oldAssignment.getInputPins()) {
newAssignment.getInputPins().add(behavior.getInPin().stream().filter(pin -> Objects.equals(inputPin.getId(), pin.getId())).findFirst().orElseThrow());
}
copy = newAssignment;
} else {
copy = datadictionaryFactory.eINSTANCE.createForwardingAssignment();
}
copy.setId(it.getId());
copy.setEntityName(it.getEntityName());
copy.setOutputPin(behavior.getInPin().stream().filter(pin -> Objects.equals(it.getOutputPin().getId(), pin.getId())).findFirst().orElseThrow());
});
node.setBehavior(behavior);
return node;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
import tools.mdsd.library.standalone.initialization.StandaloneInitializationException;
import tools.mdsd.library.standalone.initialization.StandaloneInitializerBuilder;

/**
* Extension of the {@link DataFlowConfidentialityAnalysis} for usage with the GDPR metamodel that is able to resolve
* uncertain context dependent attributes.
* <p/>
* Inputs to the analysis are a metamodel instance of the GDPR model and the context properties model
* <p/>
* Note: Do not create an instance of this class manually, use the {@link GDPRLegalAssessmentAnalysisBuilder} instead
*/
public class GDPRLegalAssessmentAnalysis extends DataFlowConfidentialityAnalysis {
public static final String PLUGIN_PATH = "mdpa.gdpr.analysis";

Expand All @@ -21,6 +29,16 @@ public class GDPRLegalAssessmentAnalysis extends DataFlowConfidentialityAnalysis
private final Optional<Class<? extends Plugin>> modelProjectActivator;
private final String modelProjectName;

/**
* Create a new {@link GDPRLegalAssessmentAnalysis} with the given resource provider and optionally a modelling project
* with a plugin activator
* <p/>
* Note: Do not create an instance of this class manually, use the {@link GDPRLegalAssessmentAnalysisBuilder} instead
* @param resourceProvider {@link GDPRResourceProvider} providing a metamodel instance of the GDPR and Context Property
* model
* @param modelProjectActivator Optional model project activator
* @param modelProjectName Optional model project name
*/
public GDPRLegalAssessmentAnalysis(GDPRResourceProvider resourceProvider, Optional<Class<? extends Plugin>> modelProjectActivator,
String modelProjectName) {
this.resourceProvider = resourceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
import org.dataflowanalysis.analysis.utils.ResourceUtils;
import org.eclipse.core.runtime.Plugin;

/**
* Extension of the {@link DataFlowAnalysisBuilder} responsible for creating a valid {@link GDPRLegalAssessmentAnalysis}
* from the following:
* - A valid path to a .gdpr metamodel instance
* - A valid path to a .contextproperties metamodel
* instance
*/
public class GDPRLegalAssessmentAnalysisBuilder extends DataFlowAnalysisBuilder {
private final Logger logger = Logger.getLogger(GDPRLegalAssessmentAnalysisBuilder.class);

Expand Down
Loading