|
41 | 41 | import io.serverlessworkflow.fluent.spec.EventFilterBuilder; |
42 | 42 | import io.serverlessworkflow.fluent.spec.ScheduleBuilder; |
43 | 43 | import io.serverlessworkflow.fluent.spec.TimeoutBuilder; |
| 44 | +import io.serverlessworkflow.fluent.spec.WorkflowTaskBuilder; |
44 | 45 | import io.serverlessworkflow.fluent.spec.configurers.AuthenticationConfigurer; |
| 46 | +import io.serverlessworkflow.fluent.spec.configurers.WorkflowConfigurer; |
45 | 47 | import io.serverlessworkflow.fluent.spec.dsl.DSL; |
46 | 48 | import io.serverlessworkflow.fluent.spec.dsl.UseSpec; |
| 49 | +import io.serverlessworkflow.fluent.spec.dsl.WorkflowSpec; |
47 | 50 | import io.serverlessworkflow.impl.TaskContextData; |
48 | 51 | import io.serverlessworkflow.impl.WorkflowContextData; |
49 | 52 | import java.net.URI; |
@@ -1133,6 +1136,107 @@ public static FuncTaskConfigurer set(Map<String, Object> map) { |
1133 | 1136 | return list -> list.set(s -> s.expr(map)); |
1134 | 1137 | } |
1135 | 1138 |
|
| 1139 | + /** |
| 1140 | + * Create a {@link FuncTaskConfigurer} that adds a sub-workflow call task using a {@link |
| 1141 | + * WorkflowConfigurer}. |
| 1142 | + * |
| 1143 | + * <pre>{@code |
| 1144 | + * tasks( |
| 1145 | + * subflow( |
| 1146 | + * workflow("org.acme", "sub-workflow", "0.1.0") |
| 1147 | + * .input("id", 99) |
| 1148 | + * .await(false) |
| 1149 | + * ) |
| 1150 | + * ); |
| 1151 | + * }</pre> |
| 1152 | + * |
| 1153 | + * @param configurer nested workflow configurer |
| 1154 | + * @return a {@link FuncTaskConfigurer} that adds a workflow task to the tasks list |
| 1155 | + */ |
| 1156 | + public static FuncTaskConfigurer subflow(WorkflowConfigurer configurer) { |
| 1157 | + Objects.requireNonNull(configurer, "configurer"); |
| 1158 | + return list -> list.subflow(configurer); |
| 1159 | + } |
| 1160 | + |
| 1161 | + /** |
| 1162 | + * Create a {@link FuncTaskConfigurer} that adds a named sub-workflow call task. |
| 1163 | + * |
| 1164 | + * @param name task name |
| 1165 | + * @param configurer nested workflow configurer |
| 1166 | + * @return a {@link FuncTaskConfigurer} that adds a workflow task to the tasks list |
| 1167 | + */ |
| 1168 | + public static FuncTaskConfigurer subflow(String name, Consumer<WorkflowTaskBuilder> configurer) { |
| 1169 | + Objects.requireNonNull(name, "name"); |
| 1170 | + Objects.requireNonNull(configurer, "configurer"); |
| 1171 | + return list -> list.subflow(name, configurer); |
| 1172 | + } |
| 1173 | + |
| 1174 | + /** |
| 1175 | + * Create a {@link FuncTaskConfigurer} that adds an unnamed sub-workflow call task. |
| 1176 | + * |
| 1177 | + * @param configurer nested workflow configurer |
| 1178 | + * @return a {@link FuncTaskConfigurer} that adds a workflow task to the tasks list |
| 1179 | + */ |
| 1180 | + public static FuncTaskConfigurer subflow(Consumer<WorkflowTaskBuilder> configurer) { |
| 1181 | + Objects.requireNonNull(configurer, "configurer"); |
| 1182 | + return list -> list.subflow(configurer); |
| 1183 | + } |
| 1184 | + |
| 1185 | + /** |
| 1186 | + * Alias for {@link #subflow(WorkflowConfigurer)}. |
| 1187 | + * |
| 1188 | + * @param configurer nested workflow configurer |
| 1189 | + * @return a {@link FuncTaskConfigurer} that adds a workflow task to the tasks list |
| 1190 | + */ |
| 1191 | + public static FuncTaskConfigurer workflowTask(WorkflowConfigurer configurer) { |
| 1192 | + return subflow(configurer); |
| 1193 | + } |
| 1194 | + |
| 1195 | + /** |
| 1196 | + * Create a {@link FuncTaskConfigurer} that adds a workflow subflow task. |
| 1197 | + * |
| 1198 | + * @param configurer configurer for the nested workflow task |
| 1199 | + * @return a {@link FuncTaskConfigurer} that adds a workflow task to the tasks list |
| 1200 | + * @deprecated use {@link #subflow(WorkflowConfigurer)} to avoid ambiguity with spec-side factory |
| 1201 | + * methods |
| 1202 | + */ |
| 1203 | + @Deprecated |
| 1204 | + public static FuncTaskConfigurer workflow(WorkflowConfigurer configurer) { |
| 1205 | + return subflow(configurer); |
| 1206 | + } |
| 1207 | + |
| 1208 | + /** |
| 1209 | + * Create a new {@link WorkflowSpec} to be used as a factory for workflow definitions. |
| 1210 | + * |
| 1211 | + * @param namespace workflow namespace |
| 1212 | + * @param name workflow name |
| 1213 | + * @param version workflow version |
| 1214 | + * @return a new {@link WorkflowSpec} instance |
| 1215 | + */ |
| 1216 | + public static WorkflowSpec workflow(String namespace, String name, String version) { |
| 1217 | + return DSL.workflow(namespace, name, version); |
| 1218 | + } |
| 1219 | + |
| 1220 | + /** |
| 1221 | + * Create a new {@link WorkflowSpec} to be used as a factory for workflow definitions. |
| 1222 | + * |
| 1223 | + * @param namespace workflow namespace |
| 1224 | + * @param name workflow name |
| 1225 | + * @return a new {@link WorkflowSpec} instance |
| 1226 | + */ |
| 1227 | + public static WorkflowSpec workflow(String namespace, String name) { |
| 1228 | + return DSL.workflow(namespace, name); |
| 1229 | + } |
| 1230 | + |
| 1231 | + /** |
| 1232 | + * Create a new {@link WorkflowSpec} to be used as a factory for workflow definitions. |
| 1233 | + * |
| 1234 | + * @return a new {@link WorkflowSpec} instance |
| 1235 | + */ |
| 1236 | + public static WorkflowSpec workflow() { |
| 1237 | + return DSL.workflow(); |
| 1238 | + } |
| 1239 | + |
1136 | 1240 | // --------------------------------------------------------------------------- |
1137 | 1241 | // HTTP / OpenAPI |
1138 | 1242 | // --------------------------------------------------------------------------- |
|
0 commit comments