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