1
1
package org .folio .rest .camunda .service ;
2
2
3
- import com .fasterxml .jackson .core .JsonProcessingException ;
4
- import com .fasterxml .jackson .databind .JsonNode ;
5
- import com .fasterxml .jackson .databind .ObjectMapper ;
6
3
import java .util .ArrayList ;
7
4
import java .util .List ;
8
5
import java .util .Map ;
9
6
import java .util .Objects ;
10
7
import java .util .Optional ;
8
+
9
+ import com .fasterxml .jackson .core .JsonProcessingException ;
10
+ import com .fasterxml .jackson .databind .JsonNode ;
11
+ import com .fasterxml .jackson .databind .ObjectMapper ;
11
12
import org .apache .commons .lang3 .reflect .FieldUtils ;
12
13
import org .camunda .bpm .engine .delegate .Expression ;
13
14
import org .camunda .bpm .model .bpmn .Bpmn ;
@@ -150,8 +151,8 @@ private void eventSubprocess(ProcessBuilder processBuilder, Node node) throws Sc
150
151
String expression = ((StartEvent ) node ).getExpression ();
151
152
152
153
if (type != StartEventType .NONE && expression == null ) {
153
- // TODO: implement and ensure validation
154
- throw new RuntimeException (String .format ("%s start event requests an expression" , type ));
154
+ // TODO: create custom exception and controller advice to handle better
155
+ throw new RuntimeException (String .format ("%s start event requires an expression" , type ));
155
156
}
156
157
157
158
builder = ((StartEventBuilder ) builder ).id (node .getIdentifier ()).name (node .getName ());
@@ -406,9 +407,11 @@ private void expressions(BpmnModelInstance model, List<Node> nodes) {
406
407
407
408
FieldUtils .getAllFieldsList (delegate .get ().getClass ()).stream ()
408
409
.filter (df -> Expression .class .isAssignableFrom (df .getType ()))
409
- .map (df -> FieldUtils .getDeclaredField (node .getClass (), df .getName (), true )).forEach (f -> {
410
+ .map (df -> FieldUtils .getField (node .getClass (), df .getName (), true ))
411
+ .filter (f -> Objects .nonNull (f ))
412
+ .forEach (f -> {
410
413
try {
411
- Object value = f == null ? null : f .get (node );
414
+ Object value = f .get (node );
412
415
if (Objects .nonNull (value )) {
413
416
CamundaField field = model .newInstance (CamundaField .class );
414
417
field .setCamundaName (f .getName ());
@@ -432,7 +435,6 @@ private void expressions(BpmnModelInstance model, List<Node> nodes) {
432
435
// TODO: create custom exception and controller advice to handle better
433
436
throw new RuntimeException ("Task must have delegate representation!" );
434
437
}
435
-
436
438
}
437
439
});
438
440
}
0 commit comments