1
1
/**
2
2
* BSD 3-Clause License
3
- * <p>
3
+ *
4
4
* Copyright © 2019, viadee Unternehmensberatung AG
5
5
* All rights reserved.
6
- * <p>
6
+ *
7
7
* Redistribution and use in source and binary forms, with or without
8
8
* modification, are permitted provided that the following conditions are met:
9
- * <p>
9
+ *
10
10
* * Redistributions of source code must retain the above copyright notice, this
11
- * list of conditions and the following disclaimer.
12
- * <p>
11
+ * list of conditions and the following disclaimer.
12
+ *
13
13
* * Redistributions in binary form must reproduce the above copyright notice,
14
- * this list of conditions and the following disclaimer in the documentation
15
- * and/or other materials provided with the distribution.
16
- * <p>
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
17
* * Neither the name of the copyright holder nor the names of its
18
- * contributors may be used to endorse or promote products derived from
19
- * this software without specific prior written permission.
20
- * <p>
18
+ * contributors may be used to endorse or promote products derived from
19
+ * this software without specific prior written permission.
20
+ *
21
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
22
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
23
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -67,7 +67,7 @@ private enum ModelVersionEnum {
67
67
* Implementation, so the we have to scan the xml of the model for the
68
68
* implementation
69
69
* <p>
70
- * * @param path
70
+ * @param path
71
71
* path to model
72
72
*/
73
73
public BpmnScanner (String path ) {
@@ -334,7 +334,7 @@ public String getEventImplementation(String id) {
334
334
public ArrayList <String > getListener (String id , String listType , String extType ) {
335
335
336
336
// list to hold return values
337
- ArrayList <String > returnAttrList = new ArrayList <String >();
337
+ ArrayList <String > returnAttrList = new ArrayList <>();
338
338
339
339
// List for all Task elements
340
340
NodeList nodeListExtensionElements ;
@@ -395,7 +395,7 @@ private String checkAttributesOfNode(Node node, String listType) {
395
395
*/
396
396
public ArrayList <String > getScriptTypes (String id ) {
397
397
// bool to hold return values
398
- ArrayList <String > returnScriptType = new ArrayList <String >();
398
+ ArrayList <String > returnScriptType = new ArrayList <>();
399
399
400
400
// List for all Task elements
401
401
NodeList nodeList ;
@@ -440,10 +440,12 @@ public boolean checkStartEvent(String id) {
440
440
nodeList = null ;
441
441
}
442
442
443
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
444
- Element startEvent = (Element ) nodeList .item (i );
445
- if (id .equals (startEvent .getAttribute (BpmnConstants .ATTR_ID ))) {
446
- return isSubprocess (startEvent );
443
+ if (nodeList != null ) {
444
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
445
+ Element startEvent = (Element ) nodeList .item (i );
446
+ if (id .equals (startEvent .getAttribute (BpmnConstants .ATTR_ID ))) {
447
+ return isSubprocess (startEvent );
448
+ }
447
449
}
448
450
}
449
451
@@ -520,10 +522,12 @@ public boolean hasScriptInCondExp(String id) {
520
522
break ;
521
523
}
522
524
523
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
524
- Element sequenceElement = (Element ) nodeList .item (i );
525
- if (sequenceElement .getAttribute (BpmnConstants .ATTR_ID ).equals (id )) {
526
- return hasCondExp (sequenceElement );
525
+ if (nodeList != null ) {
526
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
527
+ Element sequenceElement = (Element ) nodeList .item (i );
528
+ if (sequenceElement .getAttribute (BpmnConstants .ATTR_ID ).equals (id )) {
529
+ return hasCondExp (sequenceElement );
530
+ }
527
531
}
528
532
}
529
533
@@ -648,16 +652,19 @@ public ArrayList<String> getSequenceFlowDef(String id) {
648
652
649
653
NodeList nodeList = getNodeListByVersion ();
650
654
651
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
652
- Element taskElement = (Element ) nodeList .item (i );
655
+ if (nodeList != null ) {
656
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
657
+ Element taskElement = (Element ) nodeList .item (i );
653
658
654
- // check if the ids are corresponding and retrieve the attributes for target and
655
- // source reference
656
- if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
657
- references .add (taskElement .getAttribute (BpmnConstants .SOURCE_REF ));
658
- references .add (taskElement .getAttribute (BpmnConstants .TARGET_REF ));
659
+ // check if the ids are corresponding and retrieve the attributes for target and
660
+ // source reference
661
+ if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
662
+ references .add (taskElement .getAttribute (BpmnConstants .SOURCE_REF ));
663
+ references .add (taskElement .getAttribute (BpmnConstants .TARGET_REF ));
664
+ }
659
665
}
660
666
}
667
+
661
668
return references ;
662
669
}
663
670
@@ -689,20 +696,23 @@ public ArrayList<Node> getOutgoingEdges(String id) {
689
696
break ;
690
697
}
691
698
692
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
693
- Element taskElement = (Element ) nodeList .item (i );
699
+ if (nodeList != null ) {
700
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
701
+ Element taskElement = (Element ) nodeList .item (i );
694
702
695
- // check if the ids are corresponding and retrieve the outgoing edges of the xor
696
- // gateway
697
- if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
698
- NodeList children = taskElement .getChildNodes ();
699
- for (int j = 0 ; j < children .getLength (); j ++) {
700
- if (children .item (j ).getNodeName ().equals (out )) {
701
- outgoingEdges .add (checkNamingOfEdges (children .item (j ).getTextContent ()));
703
+ // check if the ids are corresponding and retrieve the outgoing edges of the xor
704
+ // gateway
705
+ if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
706
+ NodeList children = taskElement .getChildNodes ();
707
+ for (int j = 0 ; j < children .getLength (); j ++) {
708
+ if (children .item (j ).getNodeName ().equals (out )) {
709
+ outgoingEdges .add (checkNamingOfEdges (children .item (j ).getTextContent ()));
710
+ }
702
711
}
703
712
}
704
713
}
705
714
}
715
+
706
716
return outgoingEdges ;
707
717
}
708
718
@@ -717,12 +727,15 @@ public Node checkNamingOfEdges(String id) {
717
727
Node edge = null ;
718
728
NodeList nodeList = getNodeListByVersion ();
719
729
720
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
721
- Element taskElement = (Element ) nodeList .item (i );
722
- if (taskElement .getAttribute (BpmnConstants .ATTR_ID ).equals (id )) {
723
- edge = taskElement ;
730
+ if (nodeList != null ) {
731
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
732
+ Element taskElement = (Element ) nodeList .item (i );
733
+ if (taskElement .getAttribute (BpmnConstants .ATTR_ID ).equals (id )) {
734
+ edge = taskElement ;
735
+ }
724
736
}
725
737
}
738
+
726
739
return edge ;
727
740
}
728
741
@@ -1084,18 +1097,21 @@ public Map<String, String> getErrorDef(String id) {
1084
1097
break ;
1085
1098
}
1086
1099
1087
- final Map <String , String > errorDef = new HashMap <String , String >();
1100
+ final Map <String , String > errorDef = new HashMap <>();
1088
1101
1089
- // iterate over list and check each item
1090
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
1091
- Element taskElement = (Element ) nodeList .item (i );
1102
+ if (nodeList != null ) {
1103
+ // iterate over list and check each item
1104
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
1105
+ Element taskElement = (Element ) nodeList .item (i );
1092
1106
1093
- // check if the ids are corresponding
1094
- if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
1095
- errorDef .put (taskElement .getAttribute (BpmnConstants .ATTR_NAME ),
1096
- taskElement .getAttribute (BpmnConstants .ATTR_ERROR_CODE ));
1107
+ // check if the ids are corresponding
1108
+ if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
1109
+ errorDef .put (taskElement .getAttribute (BpmnConstants .ATTR_NAME ),
1110
+ taskElement .getAttribute (BpmnConstants .ATTR_ERROR_CODE ));
1111
+ }
1097
1112
}
1098
1113
}
1114
+
1099
1115
return errorDef ;
1100
1116
}
1101
1117
@@ -1173,13 +1189,15 @@ public String getErrorEventMapping(String id) {
1173
1189
break ;
1174
1190
}
1175
1191
1176
- // iterate over list and check each item
1177
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
1178
- Element taskElement = (Element ) nodeList .item (i );
1192
+ if (nodeList != null ) {
1193
+ // iterate over list and check each item
1194
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
1195
+ Element taskElement = (Element ) nodeList .item (i );
1179
1196
1180
- // check if the ids are corresponding
1181
- if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
1182
- attachedToTask = taskElement .getAttribute (BpmnConstants .ATTACHED_TO_REF );
1197
+ // check if the ids are corresponding
1198
+ if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
1199
+ attachedToTask = taskElement .getAttribute (BpmnConstants .ATTACHED_TO_REF );
1200
+ }
1183
1201
}
1184
1202
}
1185
1203
@@ -1227,7 +1245,7 @@ public ArrayList<String> getMessageRefs(String id) {
1227
1245
}
1228
1246
1229
1247
private ArrayList <String > getMessageRefFromReceiveTask (String id ) {
1230
- ArrayList <String > messageRefs = new ArrayList <String >();
1248
+ ArrayList <String > messageRefs = new ArrayList <>();
1231
1249
NodeList nodeList = null ;
1232
1250
1233
1251
switch (modelVersion ) {
@@ -1244,12 +1262,15 @@ private ArrayList<String> getMessageRefFromReceiveTask(String id) {
1244
1262
break ;
1245
1263
}
1246
1264
1247
- // iterate over list and check each item
1248
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
1249
- Element taskElement = (Element ) nodeList .item (i );
1250
- if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID )))
1251
- messageRefs .add (taskElement .getAttribute (BpmnConstants .ATTR_MESSAGE_REF ));
1265
+ if (nodeList != null ) {
1266
+ // iterate over list and check each item
1267
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
1268
+ Element taskElement = (Element ) nodeList .item (i );
1269
+ if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID )))
1270
+ messageRefs .add (taskElement .getAttribute (BpmnConstants .ATTR_MESSAGE_REF ));
1271
+ }
1252
1272
}
1273
+
1253
1274
return messageRefs ;
1254
1275
}
1255
1276
@@ -1367,15 +1388,18 @@ public String getSignalName(String signalRef) {
1367
1388
private String getName (NodeList nodeList , String id ) {
1368
1389
String name = "" ;
1369
1390
1370
- // iterate over list and check each item
1371
- for (int i = 0 ; i < nodeList .getLength (); i ++) {
1372
- Element taskElement = (Element ) nodeList .item (i );
1391
+ if (nodeList != null ) {
1392
+ // iterate over list and check each item
1393
+ for (int i = 0 ; i < nodeList .getLength (); i ++) {
1394
+ Element taskElement = (Element ) nodeList .item (i );
1373
1395
1374
- // check if the ids are corresponding
1375
- if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
1376
- name = taskElement .getAttribute (BpmnConstants .ATTR_NAME );
1396
+ // check if the ids are corresponding
1397
+ if (id .equals (taskElement .getAttribute (BpmnConstants .ATTR_ID ))) {
1398
+ name = taskElement .getAttribute (BpmnConstants .ATTR_NAME );
1399
+ }
1377
1400
}
1378
1401
}
1402
+
1379
1403
return name ;
1380
1404
}
1381
1405
}
0 commit comments