Skip to content

Commit

Permalink
Impact Assessment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinnloshausen committed Jan 15, 2019
1 parent 0106b87 commit e59887a
Show file tree
Hide file tree
Showing 3 changed files with 726 additions and 114 deletions.
25 changes: 25 additions & 0 deletions src/architecture/DataType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package architecture;

import java.util.Set;

public class DataType {

// class fields
private String name;
private Set<Variable> vars;

public DataType(String name, Set<Variable> vars) {
this.name = name;
this.vars = vars;
}

@Override
public String toString() {
return name;
}

// getter and setter methods
public Set<Variable> getVars() {
return vars;
}
}
172 changes: 171 additions & 1 deletion src/gui/ArchitectureFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public void finish() {
ded.getComp().setDeducSet(ded.getDeducSet());
}
// create arch
arch = new Architecture(cSet, interComponentActions, trustSet, composSet, purpHier); //TODO replace null with actual purp hier
arch = new Architecture(cSet, interComponentActions, trustSet, composSet, purpHier);
// create the verifier
//parserTd = new RulesOfInferenceParserTopdown(arch);
parserBu = new RulesOfInferenceParserBottomup(arch);
Expand Down Expand Up @@ -637,6 +637,54 @@ public void addPReceive(String comp1, String comp2, String purp, Set<String> var
System.out.println(aSet);
}

/**
* Method that adds a 'creceive' event to the architecture's set.
* @param comp1
* the receiving component
* @param comp2
* the sending component
* @param dt
* the data type condition
* @param varSet
* the set of variables
*/
public void addCReceive(String comp1, String comp2, String dt, Set<String> varSet) {
// TODO Auto-generated method stub
Component component1 = null;
Component component2 = null;
DataType dataType = null;
Set<Variable> variableSet = new LinkedHashSet<Variable>();
// go through the Sets and identify the right objects
for (Component c : cSet) {
if (comp1 != null && c.toString().equals(comp1)) {
component1 = c;
} else if (comp2 != null && c.toString().equals(comp2)) {
component2 = c;
}
}
for (String s : varSet) {
for (Variable v : vSet) {
if (v.toString().equals(s)) {
variableSet.add(v);
break;
}
}
}
for (DataType d : dtSet) {
if (d.toString().equals(dt)) {
dataType = d;
break;
}
}
if (component1 != null && component2 != null && !(dataType == null
|| variableSet.isEmpty())) {
aSet.add(
new Action(ActionType.CRECEIVE, component1, component2, dataType, variableSet));
}
// Debug
System.out.println(aSet);
}

/**
* Method that adds a 'check' event to the architecture's Set.
* @param comp
Expand Down Expand Up @@ -844,6 +892,72 @@ public void addDeduc(String name, Set<String> premises, String conclusion, Strin
System.out.println(deducs);
}

/**
* Method to add a Permission action to the set of actions.
* @param comp1
* String of the first component
* @param comp2
* String of the second component
* @param dt
* String of the data type
*/
public void addPermission(String comp1, String comp2, String dt) {
// TODO Auto-generated method stub
Component c1 = null;
Component c2 = null;
DataType dataType = null;
for (Component c : cSet) {
if (c.toString().equals(comp1)) {
c1 = c;
} else if (c.toString().equals(comp2)) {
c2 = c;
}
}
for (DataType d : dtSet) {
if (d.toString().equals(dt)) {
dataType = d;
}
}
if (c1 != null && c2 != null && dataType != null) {
aSet.add(new Action(ActionType.PERMISSION, c1, c2, dataType));
}
// DEBUG
System.out.println(aSet);
}

/**
* Method to add a Revoke action to the set of actions.
* @param comp1
* String of the first component
* @param comp2
* String of the second component
* @param dt
* String of the data type
*/
public void addRevoke(String comp1, String comp2, String dt) {
// TODO Auto-generated method stub
Component c1 = null;
Component c2 = null;
DataType dataType = null;
for (Component c : cSet) {
if (c.toString().equals(comp1)) {
c1 = c;
} else if (c.toString().equals(comp2)) {
c2 = c;
}
}
for (DataType d : dtSet) {
if (d.toString().equals(dt)) {
dataType = d;
}
}
if (c1 != null && c2 != null && dataType != null) {
aSet.add(new Action(ActionType.REVOKE, c1, c2, dataType));
}
// DEBUG
System.out.println(aSet);
}

public void addPurpose(String name, Set<String> varSet, Set<String> purpSet1, Set<String> purpSet2) {
// TODO Auto-generated method stub
Set<Variable> variables = new LinkedHashSet<Variable>();
Expand Down Expand Up @@ -943,6 +1057,24 @@ public void addProof(String comp, Set<String> ps) {
System.out.println(stSet);
}

public void addDataType(String name, Set<String> varSet) {
// TODO Auto-generated method stub
Set<Variable> vars = new LinkedHashSet<Variable>();
for (String s : varSet) {
for (Variable var : vSet) {
if (var.toString().equals(s)) {
vars.add(var);
break;
}
}
}
if (!varSet.isEmpty()) {
dtSet.add(new DataType(name, vars));
}
// Debug
System.out.println(dtSet);
}

/**
* Method that adds a 'has' property to the architecture's Set.
* @param comp
Expand Down Expand Up @@ -1142,6 +1274,28 @@ public void addPropPurp(String comp) {
System.out.println(pSet);
}

public void addPropConsent(String comp, String dt) {
// TODO test
Component component = null;
DataType dataType = null;
for (Component c : cSet) {
if (c.toString().equals(comp)) {
component = c;
}
}
for (DataType d : dtSet) {
if (d.toString().equals(dt)) {
dataType = d;
}
}

if (component != null && dataType != null) {
pSet.add(new Property(Property.PropertyType.CONSENTVIOLATED, component, dataType));
}
// Debug
System.out.println(pSet);
}

// remover methods
/**
* Method that removes an event from the architecture's Set.
Expand Down Expand Up @@ -1358,6 +1512,22 @@ public void removePurp(String purpose) {
}
}

public void removeDt(String dataType) {
// TODO Auto-generated method stub
DataType dt = null;
// go through the Sets and identify the right object
for (DataType d : dtSet) {
if (dataType != null && d.toString().equals(dataType)) {
dt = d;
}

if (dt != null) {
// remove the action
dtSet.remove(dt);
}
}
}


/**
* Method that sets the architecture's Set of properties to a given Set.
Expand Down

0 comments on commit e59887a

Please sign in to comment.