Skip to content

Commit ea41c76

Browse files
committed
[Fix_#359] Migration to 0.10 DSL
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
1 parent 48caa94 commit ea41c76

File tree

369 files changed

+1316
-19507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

369 files changed

+1316
-19507
lines changed

api/pom.xml

+11-10
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
<groupId>org.slf4j</groupId>
1818
<artifactId>slf4j-api</artifactId>
1919
</dependency>
20-
<dependency>
21-
<groupId>org.slf4j</groupId>
22-
<artifactId>jcl-over-slf4j</artifactId>
23-
</dependency>
2420
<dependency>
2521
<groupId>com.fasterxml.jackson.core</groupId>
2622
<artifactId>jackson-core</artifactId>
@@ -34,9 +30,10 @@
3430
<artifactId>jackson-dataformat-yaml</artifactId>
3531
</dependency>
3632
<dependency>
37-
<groupId>jakarta.validation</groupId>
38-
<artifactId>jakarta.validation-api</artifactId>
33+
<groupId>jakarta.validation</groupId>
34+
<artifactId>jakarta.validation-api</artifactId>
3935
</dependency>
36+
4037
<!-- test -->
4138
<dependency>
4239
<groupId>org.junit.jupiter</groupId>
@@ -77,16 +74,20 @@
7774
<groupId>org.jsonschema2pojo</groupId>
7875
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
7976
<configuration>
80-
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
77+
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
78+
<!-- <sourcePaths>
79+
<sourcePath>https://raw.githubusercontent.com/serverlessworkflow/specification/main/schema/workflow.yaml</sourcePath>
80+
</sourcePaths> -->
81+
<sourceType>yamlschema</sourceType>
8182
<targetPackage>io.serverlessworkflow.api.types</targetPackage>
8283
<outputDirectory>${project.build.directory}/generated-sources/src/main/java</outputDirectory>
8384
<includeJsr303Annotations>true</includeJsr303Annotations>
8485
<generateBuilders>true</generateBuilders>
85-
<initializeCollections>false</initializeCollections>
86-
<includeAdditionalProperties>false</includeAdditionalProperties>
86+
<initializeCollections>true</initializeCollections>
87+
<includeAdditionalProperties>true</includeAdditionalProperties>
8788
<includeToString>false</includeToString>
8889
<includeHashcodeAndEquals>false</includeHashcodeAndEquals>
89-
<includeConstructors>true</includeConstructors>
90+
<includeConstructors>false</includeConstructors>
9091
<constructorsRequiredPropertiesOnly>true</constructorsRequiredPropertiesOnly>
9192
<serializable>true</serializable>
9293
<targetVersion>${java.version}</targetVersion>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.api;
17+
18+
import com.fasterxml.jackson.databind.ObjectMapper;
19+
import com.fasterxml.jackson.databind.SerializationFeature;
20+
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
21+
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
22+
23+
class ObjectMapperFactory {
24+
25+
private static final ObjectMapper jsonMapper =
26+
configure(new ObjectMapper());
27+
28+
private static final ObjectMapper yamlMapper =
29+
configure(
30+
new ObjectMapper(new YAMLFactory().enable(Feature.MINIMIZE_QUOTES)));
31+
32+
33+
public static final ObjectMapper jsonMapper() {
34+
return jsonMapper;
35+
}
36+
37+
public static final ObjectMapper yamlMapper() {
38+
return yamlMapper;
39+
}
40+
41+
public static ObjectMapper configure(ObjectMapper mapper) {
42+
return mapper
43+
.configure(SerializationFeature.INDENT_OUTPUT, true)
44+
.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false)
45+
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
46+
}
47+
48+
49+
private ObjectMapperFactory() {}
50+
}

api/src/main/java/io/serverlessworkflow/api/mapper/JsonObjectMapperFactory.java renamed to api/src/main/java/io/serverlessworkflow/api/WorkflowFormat.java

+20-5
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,30 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.serverlessworkflow.api.mapper;
16+
package io.serverlessworkflow.api;
1717

1818
import com.fasterxml.jackson.databind.ObjectMapper;
19+
import java.nio.file.Path;
1920

20-
public class JsonObjectMapperFactory {
21+
public enum WorkflowFormat {
22+
JSON(ObjectMapperFactory.jsonMapper()),
23+
YAML(ObjectMapperFactory.yamlMapper());
2124

22-
private static final ObjectMapper instance = new JsonObjectMapper();
25+
private final ObjectMapper mapper;
2326

24-
public static final ObjectMapper mapper() {
25-
return instance;
27+
public static WorkflowFormat fromPath(Path path) {
28+
return fromFileName(path.getFileName().toString());
29+
}
30+
31+
public static WorkflowFormat fromFileName(String fileName) {
32+
return fileName.endsWith(".json") ? JSON : YAML;
33+
}
34+
35+
private WorkflowFormat(ObjectMapper mapper) {
36+
this.mapper = mapper;
37+
}
38+
39+
public ObjectMapper mapper() {
40+
return mapper;
2641
}
2742
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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.api;
17+
18+
import io.serverlessworkflow.api.types.Workflow;
19+
import java.io.FileNotFoundException;
20+
import java.io.IOException;
21+
import java.io.InputStream;
22+
import java.io.Reader;
23+
import java.nio.file.Files;
24+
import java.nio.file.Path;
25+
26+
public class WorkflowReader {
27+
28+
public static Workflow readWorkflow(InputStream input, WorkflowFormat format) throws IOException {
29+
return format.mapper().readValue(input, Workflow.class);
30+
}
31+
32+
public static Workflow readWorkflow(Reader input, WorkflowFormat format) throws IOException {
33+
return format.mapper().readValue(input, Workflow.class);
34+
}
35+
36+
public static Workflow readWorkflow(Path path, WorkflowFormat format) throws IOException {
37+
return format.mapper().readValue(Files.readAllBytes(path), Workflow.class);
38+
}
39+
40+
public static Workflow readWorkflowFromClasspath(String classpath) throws IOException {
41+
return readWorkflowFromClasspath(
42+
classpath,
43+
Thread.currentThread().getContextClassLoader(),
44+
WorkflowFormat.fromFileName(classpath));
45+
}
46+
47+
public static Workflow readWorkflowFromClasspath(
48+
String classpath, ClassLoader cl, WorkflowFormat format) throws IOException {
49+
try (InputStream in = cl.getResourceAsStream(classpath)) {
50+
if (in == null) {
51+
throw new FileNotFoundException(classpath);
52+
}
53+
return readWorkflow(in, format);
54+
}
55+
}
56+
57+
private WorkflowReader() {}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.api;
17+
18+
import io.serverlessworkflow.api.types.Workflow;
19+
import java.io.IOException;
20+
import java.io.OutputStream;
21+
import java.io.Writer;
22+
import java.nio.file.Files;
23+
import java.nio.file.Path;
24+
25+
public class WorkflowWriter {
26+
27+
public static void writeWorkflow(OutputStream output, Workflow workflow, WorkflowFormat format)
28+
throws IOException {
29+
format.mapper().writeValue(output, workflow);
30+
}
31+
32+
public static void writeWorkflow(Writer output, Workflow workflow, WorkflowFormat format)
33+
throws IOException {
34+
format.mapper().writeValue(output, workflow);
35+
}
36+
37+
public static void writeWorkflow(Path output, Workflow workflow) throws IOException {
38+
writeWorkflow(output, workflow, WorkflowFormat.fromPath(output));
39+
}
40+
41+
public static void writeWorkflow(Path output, Workflow workflow, WorkflowFormat format)
42+
throws IOException {
43+
try (OutputStream out = Files.newOutputStream(output)) {
44+
writeWorkflow(out, workflow, format);
45+
}
46+
}
47+
48+
private WorkflowWriter() {}
49+
}

api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDefinitionDeserializer.java

-80
This file was deleted.

0 commit comments

Comments
 (0)