Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 7342f7c

Browse files
committed
feat(bankbranches): add constraint and expected violations
1 parent 33859ea commit 7342f7c

29 files changed

+569
-174
lines changed

bundles/org.dataflowanalysis.examplemodels/scenarios/pcm/BankBranches/default.nodecharacteristics

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,43 @@
55
<type xsi:type="DataDictionaryCharacterized:EnumCharacteristicType" href="default.pddc#_Zf2gABPJEfC6H5LfCNvhSA-characteristicTypes@0"/>
66
<values href="default.pddc#[email protected]@1"/>
77
</characteristics>
8+
<characteristics id="__Oap4BVEEfC2EPNO18gXnw">
9+
<type xsi:type="DataDictionaryCharacterized:EnumCharacteristicType" href="default.pddc#_Zf2gABPJEfC6H5LfCNvhSA-characteristicTypes@2"/>
10+
<values href="default.pddc#[email protected]@0"/>
11+
</characteristics>
812
<usagescenario href="default.usagemodel#_qfEfUD6wEeuVUal8mM_jUA"/>
913
</assignee>
10-
<assignee xsi:type="nodecharacteristics:UsageAssignee" id="_3MaPgBPJEfC6H5LfCNvhSA" entityName="ClearUSA">
14+
<assignee xsi:type="nodecharacteristics:UsageAssignee" id="_3MaPgBPJEfC6H5LfCNvhSA" entityName="ClerkUSA">
1115
<characteristics id="_8INkYBU4EfCOUZsJeZYp9A">
1216
<type xsi:type="DataDictionaryCharacterized:EnumCharacteristicType" href="default.pddc#_Zf2gABPJEfC6H5LfCNvhSA-characteristicTypes@0"/>
1317
<values href="default.pddc#[email protected]@0"/>
1418
</characteristics>
19+
<characteristics id="_CNx-ABVFEfC2EPNO18gXnw">
20+
<type xsi:type="DataDictionaryCharacterized:EnumCharacteristicType" href="default.pddc#_Zf2gABPJEfC6H5LfCNvhSA-characteristicTypes@2"/>
21+
<values href="default.pddc#[email protected]@0"/>
22+
</characteristics>
1523
<usagescenario href="default.usagemodel#_oMuCMD6wEeuVUal8mM_jUA"/>
1624
</assignee>
1725
<assignee xsi:type="nodecharacteristics:UsageAssignee" id="_3mwCIBPJEfC6H5LfCNvhSA" entityName="ManagerAsia">
1826
<characteristics id="__wzbsBU4EfCOUZsJeZYp9A">
1927
<type xsi:type="DataDictionaryCharacterized:EnumCharacteristicType" href="default.pddc#_Zf2gABPJEfC6H5LfCNvhSA-characteristicTypes@0"/>
2028
<values href="default.pddc#[email protected]@1"/>
2129
</characteristics>
30+
<characteristics id="_FL4t4BVFEfC2EPNO18gXnw">
31+
<type xsi:type="DataDictionaryCharacterized:EnumCharacteristicType" href="default.pddc#_Zf2gABPJEfC6H5LfCNvhSA-characteristicTypes@2"/>
32+
<values href="default.pddc#[email protected]@1"/>
33+
</characteristics>
2234
<usagescenario href="default.usagemodel#_rcIkgD6wEeuVUal8mM_jUA"/>
2335
</assignee>
2436
<assignee xsi:type="nodecharacteristics:UsageAssignee" id="_B-yWMBU5EfCOUZsJeZYp9A" entityName="ManagerUSA">
2537
<characteristics id="_Dl3owBU5EfCOUZsJeZYp9A">
2638
<type xsi:type="DataDictionaryCharacterized:EnumCharacteristicType" href="default.pddc#_Zf2gABPJEfC6H5LfCNvhSA-characteristicTypes@0"/>
2739
<values href="default.pddc#[email protected]@0"/>
2840
</characteristics>
41+
<characteristics id="_HLq0UBVFEfC2EPNO18gXnw">
42+
<type xsi:type="DataDictionaryCharacterized:EnumCharacteristicType" href="default.pddc#_Zf2gABPJEfC6H5LfCNvhSA-characteristicTypes@2"/>
43+
<values href="default.pddc#[email protected]@1"/>
44+
</characteristics>
2945
<usagescenario href="default.usagemodel#_poSoUD6wEeuVUal8mM_jUA"/>
3046
</assignee>
3147
</nodecharacteristics:Assignments>

bundles/org.dataflowanalysis.examplemodels/scenarios/pcm/BankBranches/default.repository

Lines changed: 142 additions & 5 deletions
Large diffs are not rendered by default.

bundles/org.dataflowanalysis.examplemodels/scenarios/pcm/BankBranches/default.usagemodel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
</lhs>
209209
<rhs xsi:type="expressions:True" id="_6T0Npj60EeulRPEeT0f8DQ"/>
210210
</variableCharacterisation_VariableUsage>
211-
<namedReference__VariableUsage xsi:type="stoex:VariableReference" referenceName="customerName"/>
211+
<namedReference__VariableUsage xsi:type="stoex:VariableReference" referenceName="customer"/>
212212
</inputParameterUsages_EntryLevelSystemCall>
213213
</actions_ScenarioBehaviour>
214214
</scenarioBehaviour_UsageScenario>

bundles/org.dataflowanalysis.examplemodels/scenarios/pcm/BankBranches/representations.aird

Lines changed: 204 additions & 36 deletions
Large diffs are not rendered by default.

bundles/org.dataflowanalysis.examplemodels/src/org/dataflowanalysis/examplemodels/results/ExampleModelResult.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package org.dataflowanalysis.examplemodels.results;
22

3+
import java.util.List;
34
import org.dataflowanalysis.analysis.dsl.AnalysisConstraint;
45
import org.dataflowanalysis.examplemodels.Activator;
56
import org.eclipse.core.runtime.Plugin;
67

7-
import java.util.List;
8-
98
public interface ExampleModelResult {
109
default String getModelProjectName() {
1110
return "org.dataflowanalysis.examplemodels";

bundles/org.dataflowanalysis.examplemodels/src/org/dataflowanalysis/examplemodels/results/ExpectedCharacteristic.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
public record ExpectedCharacteristic(String characteristicType, String characteristicLiteral) {
44

5+
public static ExpectedCharacteristic of(String characteristicType, String characteristicLiteral) {
6+
return new ExpectedCharacteristic(characteristicType, characteristicLiteral);
7+
}
8+
59
@Override
610
public String toString() {
711
return String.format("%s.%s", characteristicType, characteristicLiteral);

bundles/org.dataflowanalysis.examplemodels/src/org/dataflowanalysis/examplemodels/results/ExpectedViolation.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
package org.dataflowanalysis.examplemodels.results;
22

3+
import java.util.*;
34
import org.dataflowanalysis.analysis.core.AbstractVertex;
45
import org.dataflowanalysis.analysis.core.CharacteristicValue;
56
import org.dataflowanalysis.analysis.core.DataCharacteristic;
67

7-
import java.util.*;
8-
98
public class ExpectedViolation {
109
private final int flowGraphIndex;
1110
private final Identifier identifier;
1211
private final List<ExpectedCharacteristic> vertexCharacteristics;
1312
private final Map<String, List<ExpectedCharacteristic>> dataCharacteristics;
1413

1514
public ExpectedViolation(int flowGraphIndex, Identifier identifier, List<ExpectedCharacteristic> vertexCharacteristics,
16-
Map<String, List<ExpectedCharacteristic>> dataCharacteristics) {
15+
Map<String, List<ExpectedCharacteristic>> dataCharacteristics) {
1716
this.flowGraphIndex = flowGraphIndex;
1817
this.identifier = identifier;
1918
this.vertexCharacteristics = vertexCharacteristics;
@@ -25,7 +24,9 @@ public boolean references(AbstractVertex<?> element, int flowGraphIndex) {
2524
}
2625

2726
public List<ExpectedCharacteristic> hasNodeCharacteristic(List<CharacteristicValue> actualCharacteristics) {
28-
return this.vertexCharacteristics.stream().filter(it -> !this.hasCharacteristicValue(it, actualCharacteristics)).toList();
27+
return this.vertexCharacteristics.stream()
28+
.filter(it -> !this.hasCharacteristicValue(it, actualCharacteristics))
29+
.toList();
2930
}
3031

3132
public List<CharacteristicValue> hasIncorrectNodeCharacteristics(List<CharacteristicValue> actualCharacteristics) {
@@ -38,7 +39,8 @@ public Map<String, List<ExpectedCharacteristic>> hasDataCharacteristics(List<Dat
3839
Map<String, List<ExpectedCharacteristic>> missingDataCharacteristics = new HashMap<>();
3940
for (var expectedDataCharacteristic : dataCharacteristics.entrySet()) {
4041
Optional<DataCharacteristic> actualDataCharacteristic = actualDataCharacteristics.stream()
41-
.filter(it -> it.getVariableName().equals(expectedDataCharacteristic.getKey()))
42+
.filter(it -> it.getVariableName()
43+
.equals(expectedDataCharacteristic.getKey()))
4244
.findAny();
4345
if (actualDataCharacteristic.isEmpty()) {
4446
missingDataCharacteristics.put(expectedDataCharacteristic.getKey(), expectedDataCharacteristic.getValue());
@@ -47,7 +49,8 @@ public Map<String, List<ExpectedCharacteristic>> hasDataCharacteristics(List<Dat
4749
List<ExpectedCharacteristic> expectedCharacteristics = expectedDataCharacteristic.getValue();
4850
List<ExpectedCharacteristic> missingCharacteristics = new ArrayList<>();
4951
for (var expectedCharacteristic : expectedCharacteristics) {
50-
if (!this.hasCharacteristicValue(expectedCharacteristic, actualDataCharacteristic.get().getAllCharacteristics())) {
52+
if (!this.hasCharacteristicValue(expectedCharacteristic, actualDataCharacteristic.get()
53+
.getAllCharacteristics())) {
5154
missingCharacteristics.add(expectedCharacteristic);
5255
}
5356
}
@@ -61,8 +64,10 @@ public Map<String, List<ExpectedCharacteristic>> hasDataCharacteristics(List<Dat
6164
public Map<String, List<CharacteristicValue>> hasMissingDataCharacteristics(List<DataCharacteristic> actualDataCharacteristics) {
6265
Map<String, List<CharacteristicValue>> missingDataCharacteristics = new HashMap<>();
6366
for (var actualDataCharacteristic : actualDataCharacteristics) {
64-
Optional<List<ExpectedCharacteristic>> expectedCharacteristics = this.dataCharacteristics.entrySet().stream()
65-
.filter(it -> it.getKey().equals(actualDataCharacteristic.getVariableName()))
67+
Optional<List<ExpectedCharacteristic>> expectedCharacteristics = this.dataCharacteristics.entrySet()
68+
.stream()
69+
.filter(it -> it.getKey()
70+
.equals(actualDataCharacteristic.getVariableName()))
6671
.map(Map.Entry::getValue)
6772
.findAny();
6873
if (expectedCharacteristics.isEmpty()) {
@@ -84,14 +89,18 @@ public Map<String, List<CharacteristicValue>> hasMissingDataCharacteristics(List
8489

8590
private boolean hasCharacteristicValue(ExpectedCharacteristic expectedCharacteristic, List<CharacteristicValue> actualCharacteristics) {
8691
return actualCharacteristics.stream()
87-
.filter(it -> expectedCharacteristic.characteristicType().equals(it.getTypeName()))
88-
.anyMatch(it -> expectedCharacteristic.characteristicLiteral().equals(it.getValueName()));
92+
.filter(it -> expectedCharacteristic.characteristicType()
93+
.equals(it.getTypeName()))
94+
.anyMatch(it -> expectedCharacteristic.characteristicLiteral()
95+
.equals(it.getValueName()));
8996
}
9097

9198
private boolean hasExpectedCharacteristic(List<ExpectedCharacteristic> expectedCharacteristics, CharacteristicValue actualCharacteristic) {
9299
return expectedCharacteristics.stream()
93-
.filter(it -> it.characteristicType().equals(actualCharacteristic.getTypeName()))
94-
.anyMatch(it -> it.characteristicLiteral().equals(actualCharacteristic.getValueName()));
100+
.filter(it -> it.characteristicType()
101+
.equals(actualCharacteristic.getTypeName()))
102+
.anyMatch(it -> it.characteristicLiteral()
103+
.equals(actualCharacteristic.getValueName()));
95104
}
96105

97106
public Identifier getIdentifier() {
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package org.dataflowanalysis.examplemodels.results.dfd;
22

3-
import org.dataflowanalysis.examplemodels.results.ExampleModelResult;
4-
53
import java.nio.file.Paths;
4+
import org.dataflowanalysis.examplemodels.results.ExampleModelResult;
65

76
public interface DFDExampleModelResult extends ExampleModelResult {
87
default String getDataFlowDiagram() {
9-
return Paths.get(this.getBaseFolderName(), "dfd", this.getModelName(), String.format("%s.dataflowdiagram", this.getFileName())).toString();
8+
return Paths.get(this.getBaseFolderName(), "dfd", this.getModelName(), String.format("%s.dataflowdiagram", this.getFileName()))
9+
.toString();
1010
}
1111

1212
default String getDataDictionary() {
13-
return Paths.get(this.getBaseFolderName(), "dfd", this.getModelName(), String.format("%s.datadictionary", this.getFileName())).toString();
13+
return Paths.get(this.getBaseFolderName(), "dfd", this.getModelName(), String.format("%s.datadictionary", this.getFileName()))
14+
.toString();
1415
}
1516
}

bundles/org.dataflowanalysis.examplemodels/src/org/dataflowanalysis/examplemodels/results/dfd/DFDIdentifier.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public boolean matches(AbstractVertex<?> vertex) {
1616
if (!(vertex instanceof DFDVertex dfdVertex)) {
1717
return false;
1818
}
19-
return dfdVertex.getReferencedElement().getId().equals(this.id);
19+
return dfdVertex.getReferencedElement()
20+
.getId()
21+
.equals(this.id);
2022
}
2123

2224
public static DFDIdentifier of(String id) {

bundles/org.dataflowanalysis.examplemodels/src/org/dataflowanalysis/examplemodels/results/dfd/models/BranchingResult.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package org.dataflowanalysis.examplemodels.results.dfd.models;
22

3+
import java.util.List;
34
import org.dataflowanalysis.analysis.dsl.AnalysisConstraint;
45
import org.dataflowanalysis.analysis.dsl.constraint.ConstraintDSL;
56
import org.dataflowanalysis.examplemodels.results.ExpectedViolation;
67
import org.dataflowanalysis.examplemodels.results.dfd.DFDExampleModelResult;
78

8-
import java.util.List;
9-
109
public class BranchingResult implements DFDExampleModelResult {
1110
@Override
1211
public String getModelName() {
@@ -15,11 +14,11 @@ public String getModelName() {
1514

1615
@Override
1716
public List<AnalysisConstraint> getDSLConstraints() {
18-
return List.of(new ConstraintDSL()
19-
.ofData()
17+
return List.of(new ConstraintDSL().ofData()
2018
.neverFlows()
2119
.toVertex()
22-
.with((vertex) -> vertex.getAllVertexCharacteristics().isEmpty())
20+
.with((vertex) -> vertex.getAllVertexCharacteristics()
21+
.isEmpty())
2322
.create());
2423
}
2524

0 commit comments

Comments
 (0)