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

Add support for JsonPointer notation in JsonFieldToMapPayloadExtractor #3778

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Collection;
import java.util.stream.Collectors;

import com.fasterxml.jackson.core.JsonPointer;
import org.flowable.eventregistry.api.InboundEventPayloadExtractor;
import org.flowable.eventregistry.api.model.EventPayloadTypes;
import org.flowable.eventregistry.api.runtime.EventPayloadInstance;
Expand All @@ -36,7 +37,10 @@ public class JsonFieldToMapPayloadExtractor implements InboundEventPayloadExtrac
@Override
public Collection<EventPayloadInstance> extractPayload(EventModel eventModel, JsonNode payload) {
return eventModel.getPayload().stream()
.filter(payloadDefinition -> payloadDefinition.isFullPayload() || payload.has(payloadDefinition.getName()))
.filter(payloadDefinition -> payloadDefinition.isFullPayload()
|| payload.has(payloadDefinition.getName())
|| (payloadDefinition.getName().startsWith("/")
&& !payload.at(JsonPointer.valueOf(payloadDefinition.getName())).isMissingNode()))
.map(payloadDefinition -> new EventPayloadInstanceImpl(payloadDefinition, getPayloadValue(payload,
payloadDefinition.getName(), payloadDefinition.getType(), payloadDefinition.isFullPayload())))
.collect(Collectors.toList());
Expand All @@ -46,8 +50,9 @@ protected Object getPayloadValue(JsonNode event, String definitionName, String d
if (isFullPayload) {
return event;
}

JsonNode parameterNode = event.get(definitionName);

JsonNode parameterNode = definitionName.startsWith("/")
? event.at(JsonPointer.valueOf(definitionName)) : event.get(definitionName);
Object value = null;

if (EventPayloadTypes.STRING.equals(definitionType)) {
Expand Down