Skip to content

Commit d6e4f07

Browse files
no-issue: fix JavaFilterFunctionCallExecutor missing from context (#991)
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
1 parent 643460f commit d6e4f07

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.impl.executors.func;
17+
18+
import io.serverlessworkflow.api.types.TaskBase;
19+
import io.serverlessworkflow.api.types.func.CallJava;
20+
import io.serverlessworkflow.api.types.func.JavaFilterFunction;
21+
import io.serverlessworkflow.impl.TaskContext;
22+
import io.serverlessworkflow.impl.WorkflowContext;
23+
import io.serverlessworkflow.impl.WorkflowDefinition;
24+
import io.serverlessworkflow.impl.WorkflowModel;
25+
import io.serverlessworkflow.impl.WorkflowModelFactory;
26+
import io.serverlessworkflow.impl.executors.CallableTask;
27+
import java.util.Optional;
28+
import java.util.concurrent.CompletableFuture;
29+
30+
public class JavaFilterFunctionCallExecutor<T, V>
31+
implements CallableTask<CallJava.CallJavaFilterFunction<T, V>> {
32+
33+
private JavaFilterFunction<T, V> function;
34+
private Optional<Class<T>> inputClass = Optional.empty();
35+
36+
@Override
37+
public void init(CallJava.CallJavaFilterFunction<T, V> task, WorkflowDefinition definition) {
38+
this.function = task.function();
39+
this.inputClass = task.inputClass();
40+
}
41+
42+
@Override
43+
public CompletableFuture<WorkflowModel> apply(
44+
WorkflowContext workflowContext, TaskContext taskContext, WorkflowModel input) {
45+
WorkflowModelFactory mf = workflowContext.definition().application().modelFactory();
46+
T typedIn = JavaFuncUtils.convertT(input, inputClass);
47+
V out = function.apply(typedIn, workflowContext, taskContext);
48+
return CompletableFuture.completedFuture(mf.fromAny(input, out));
49+
}
50+
51+
@Override
52+
public boolean accept(Class<? extends TaskBase> clazz) {
53+
return CallJava.CallJavaFilterFunction.class.isAssignableFrom(clazz);
54+
}
55+
}

experimental/lambda/src/main/resources/META-INF/services/io.serverlessworkflow.impl.executors.CallableTask

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ io.serverlessworkflow.impl.executors.func.JavaLoopFunctionIndexCallExecutor
22
io.serverlessworkflow.impl.executors.func.JavaLoopFunctionCallExecutor
33
io.serverlessworkflow.impl.executors.func.JavaFunctionCallExecutor
44
io.serverlessworkflow.impl.executors.func.JavaConsumerCallExecutor
5-
io.serverlessworkflow.impl.executors.func.JavaContextFunctionCallExecutor
5+
io.serverlessworkflow.impl.executors.func.JavaContextFunctionCallExecutor
6+
io.serverlessworkflow.impl.executors.func.JavaFilterFunctionCallExecutor

0 commit comments

Comments
 (0)