Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get node inherited property values #256

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/main/java/org/folio/rest/camunda/service/BpmnModelFactory.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.folio.rest.camunda.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.camunda.bpm.engine.delegate.Expression;
import org.camunda.bpm.model.bpmn.Bpmn;
Expand Down Expand Up @@ -150,8 +151,8 @@ private void eventSubprocess(ProcessBuilder processBuilder, Node node) throws Sc
String expression = ((StartEvent) node).getExpression();

if (type != StartEventType.NONE && expression == null) {
// TODO: implement and ensure validation
throw new RuntimeException(String.format("%s start event requests an expression", type));
// TODO: create custom exception and controller advice to handle better
throw new RuntimeException(String.format("%s start event requires an expression", type));
}

builder = ((StartEventBuilder) builder).id(node.getIdentifier()).name(node.getName());
Expand Down Expand Up @@ -406,9 +407,11 @@ private void expressions(BpmnModelInstance model, List<Node> nodes) {

FieldUtils.getAllFieldsList(delegate.get().getClass()).stream()
.filter(df -> Expression.class.isAssignableFrom(df.getType()))
.map(df -> FieldUtils.getDeclaredField(node.getClass(), df.getName(), true)).forEach(f -> {
.map(df -> FieldUtils.getField(node.getClass(), df.getName(), true))
.filter(f -> Objects.nonNull(f))
.forEach(f -> {
try {
Object value = f == null ? null : f.get(node);
Object value = f.get(node);
if (Objects.nonNull(value)) {
CamundaField field = model.newInstance(CamundaField.class);
field.setCamundaName(f.getName());
Expand All @@ -432,7 +435,6 @@ private void expressions(BpmnModelInstance model, List<Node> nodes) {
// TODO: create custom exception and controller advice to handle better
throw new RuntimeException("Task must have delegate representation!");
}

}
});
}
Expand Down