Skip to content

Commit

Permalink
feat: write actual implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlukas committed Nov 27, 2024
1 parent 49cc2e7 commit ef47d74
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.camunda.community.migration.converter.visitor.AbstractListenerVisitor.ListenerImplementation.ClassImplementation;
import org.camunda.community.migration.converter.visitor.AbstractListenerVisitor.ListenerImplementation.DelegateExpressionImplementation;
import org.camunda.community.migration.converter.visitor.AbstractListenerVisitor.ListenerImplementation.ExpressionImplementation;
import org.camunda.community.migration.converter.visitor.AbstractListenerVisitor.ListenerImplementation.NullImplementation;
import org.camunda.community.migration.converter.visitor.AbstractListenerVisitor.ListenerImplementation.ScriptImplementation;

public abstract class AbstractListenerVisitor extends AbstractCamundaElementVisitor {
Expand Down Expand Up @@ -47,10 +48,10 @@ private ListenerImplementation findListenerImplementation(DomElementVisitorConte
.getAttribute("scriptFormat");
return new ScriptImplementation(listenerImplementation);
}
throw new IllegalStateException("Unknown listener implementation");
return new NullImplementation();
}

protected sealed interface ListenerImplementation {
public sealed interface ListenerImplementation {
String implementation();

record DelegateExpressionImplementation(String implementation)
Expand All @@ -61,5 +62,12 @@ record ClassImplementation(String implementation) implements ListenerImplementat
record ExpressionImplementation(String implementation) implements ListenerImplementation {}

record ScriptImplementation(String implementation) implements ListenerImplementation {}

record NullImplementation() implements ListenerImplementation {
@Override
public String implementation() {
return null;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.camunda.community.migration.converter.visitor.impl.element;

import static org.camunda.community.migration.converter.visitor.AbstractDelegateImplementationVisitor.*;

import java.util.regex.Matcher;
import org.camunda.community.migration.converter.DomElementVisitorContext;
import org.camunda.community.migration.converter.convertible.AbstractExecutionListenerConvertible;
import org.camunda.community.migration.converter.convertible.AbstractExecutionListenerConvertible.ZeebeExecutionListener;
Expand All @@ -23,10 +26,11 @@ protected Message visitListener(
SemanticVersion.parse(context.getProperties().getPlatformVersion()))) {
ZeebeExecutionListener executionListener = new ZeebeExecutionListener();
executionListener.setEventType(EventType.valueOf(event));
if(implementation instanceof DelegateExpressionImplementation){
// TODO get the pattern as soon as its on the main
executionListener.setListenerType();
}else{
if (implementation instanceof DelegateExpressionImplementation) {
Matcher matcher = DELEGATE_NAME_EXTRACT.matcher(implementation.implementation());
String delegateName = matcher.find() ? matcher.group(1) : implementation.implementation();
executionListener.setListenerType(delegateName);
} else {
executionListener.setListenerType(implementation.implementation());
}
context.addConversion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public String localName() {

@Override
protected Message visitListener(
DomElementVisitorContext context, String event, String implementation) {
return MessageFactory.taskListener(event, implementation);
DomElementVisitorContext context, String event, ListenerImplementation implementation) {
return MessageFactory.taskListener(event, implementation.implementation());
}

@Override
Expand Down

0 comments on commit ef47d74

Please sign in to comment.