@@ -113,13 +113,13 @@ public static WebEditorDfd analyzeAnnotate(WebEditorDfd webEditorDfd) {
113113 var webEditorconverter = new Web2DFDConverter ();
114114 var dd = webEditorconverter .convert (new WebEditorConverterModel (webEditorDfd ));
115115 var dfdConverter = new DFD2WebConverter ();
116- var newJson = dfdConverter .convert (dd ).getModel ();
117- if (webEditorDfd .constraints () != null && !webEditorDfd .constraints ().isEmpty ()) {
116+ if (webEditorDfd .constraints () != null && !webEditorDfd .constraints ().isEmpty ()) {
118117 var constraints = parseConstraints (webEditorDfd );
119- var violations = runAnalysis (dd , constraints );
120- newJson .constraints ().addAll (webEditorDfd .constraints ()); //Reapply constraints
121- return annotateViolations (newJson , violations );
118+ dfdConverter .setConditions (constraints );
122119 }
120+ var newJson = dfdConverter .convert (dd ).getModel ();
121+ if (webEditorDfd .constraints () != null && !webEditorDfd .constraints ().isEmpty ())
122+ newJson .constraints ().addAll (webEditorDfd .constraints ()); //Reapply constraints
123123 return newJson ;
124124 } catch (Exception e ) {
125125 e .printStackTrace ();
@@ -183,17 +183,16 @@ private static List<DSLResult> runAnalysis(DataFlowDiagramAndDictionary dfd, Lis
183183 }
184184
185185 private static WebEditorDfd annotateViolations (WebEditorDfd webEditorDfd , List <DSLResult > violations ) {
186- Map <Child , List <String >> nodeToAnnotationMap = new HashMap <>();
186+ Map <Child , List <Annotation >> nodeToAnnotationMap = new HashMap <>();
187187
188188 for (int i = 0 ; i < violations .size (); i ++) {
189189 var violation = violations .get (i );
190190 violation .getMatchedVertices ().stream ().forEach (it -> {
191191 var node = webEditorDfd .model ().children ().stream ()
192192 .filter (child -> child .id ().equals (((Node )it .getReferencedElement ()).getId ())).findFirst ().orElseThrow ();
193193 nodeToAnnotationMap .putIfAbsent (node , new ArrayList <>());
194- if (nodeToAnnotationMap .containsKey (node )) {
195- nodeToAnnotationMap .get (node ).add ("Constraint " + violation .getName () + " violated" );
196- }
194+ String message = "Constraint " + violation .getName () + " violated" ;
195+ nodeToAnnotationMap .get (node ).add (new Annotation (message , "bolt" , stringToColorHex (message ), violation .getTransposeFlowGraph ().hashCode ()));
197196 });
198197 }
199198
@@ -202,11 +201,8 @@ private static WebEditorDfd annotateViolations(WebEditorDfd webEditorDfd, List<D
202201 for (Child child : webEditorDfd .model ().children ()) {
203202 if (nodeToAnnotationMap .containsKey (child )) {
204203 var annotations = child .annotations ();
205- nodeToAnnotationMap .get (child ).forEach (annotation -> {
206- annotations .add (new Annotation (annotation , "bolt" , stringToColorHex (annotation )));
207- });
208-
209204
205+ annotations .addAll (nodeToAnnotationMap .get (child ));
210206
211207 var newChild = new Child (child .text (), child .labels (), child .ports (), child .id (), child .type (), null , null , annotations , child .children ());
212208 newChildren .add (newChild );
@@ -230,7 +226,7 @@ private static WebEditorDfd annotateViolations(WebEditorDfd webEditorDfd, List<D
230226 return webEditorDfd ;
231227 }
232228
233- public static String stringToColorHex (String input ) {
229+ private static String stringToColorHex (String input ) {
234230 byte [] hash ;
235231 try {
236232 MessageDigest md = MessageDigest .getInstance ("MD5" );
0 commit comments