Skip to content

Commit

Permalink
[KOGITO-9614] Updating to 0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Aug 1, 2023
1 parent 582f4b6 commit b50e0ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
2 changes: 1 addition & 1 deletion kogito-build/kogito-dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<version.net.thisptr.jackson-jq>1.0.0-preview.20220705</version.net.thisptr.jackson-jq>
<version.io.quarkiverse.jackson-jq>1.1.0</version.io.quarkiverse.jackson-jq>
<version.io.quarkiverse.openapi.generator>1.3.8</version.io.quarkiverse.openapi.generator>
<version.io.quarkiverse.asyncapi>0.0.4</version.io.quarkiverse.asyncapi>
<version.io.quarkiverse.asyncapi>0.0.5</version.io.quarkiverse.asyncapi>
<version.io.quarkiverse.reactivemessaging.http>1.1.5</version.io.quarkiverse.reactivemessaging.http>
<version.io.quarkiverse.embedded.postgresql>0.0.8</version.io.quarkiverse.embedded.postgresql>
<version.com.github.haifengl.smile>1.5.2</version.com.github.haifengl.smile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
package org.kie.kogito.quarkus.serverless.workflow.asyncapi;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -30,33 +27,18 @@

import io.quarkiverse.asyncapi.config.AsyncAPISpecInput;
import io.quarkiverse.asyncapi.config.AsyncAPISpecInputProvider;
import io.quarkiverse.asyncapi.config.AsyncAPIUtils;
import io.serverlessworkflow.api.functions.FunctionDefinition.Type;
import io.smallrye.config.ConfigSourceContext;

public class WorkflowAsyncAPISpecInputProvider implements AsyncAPISpecInputProvider {

@Override
public AsyncAPISpecInput read(ConfigSourceContext context) {
if (isSourceModule(context)) {
for (String dir : AsyncAPIUtils.getValues(context, "kogito.extensions.asyncAPI.scanDirs", Arrays.asList("src", "target"))) {
Path rootPath = Path.of(dir);
if (Files.isDirectory(rootPath)) {
try (Stream<Path> workflowFiles = Files.walk(rootPath)) {
return new AsyncAPISpecInput(WorkflowCodeGenUtils
.operationResources(workflowFiles, f -> f.getType() == Type.ASYNCAPI,
Optional.ofNullable(context.getValue(WorkflowOperationIdFactoryProvider.PROPERTY_NAME).getValue()))
.collect(Collectors.toMap(resource -> resource.getOperationId().getFileName(), AsyncAPIInputStreamSupplier::new, (key1, key2) -> key1)));
} catch (IOException io) {
throw new UncheckedIOException(io);
}
}
}
public AsyncAPISpecInput read(ConfigSourceContext context) throws IOException {
try (Stream<Path> workflowFiles = Files.walk(Path.of(System.getProperty("user.dir")))) {
return new AsyncAPISpecInput(WorkflowCodeGenUtils
.operationResources(workflowFiles, f -> f.getType() == Type.ASYNCAPI,
Optional.ofNullable(context.getValue(WorkflowOperationIdFactoryProvider.PROPERTY_NAME).getValue()))
.collect(Collectors.toMap(resource -> resource.getOperationId().getFileName(), AsyncAPIInputStreamSupplier::new, (key1, key2) -> key1)));
}
return new AsyncAPISpecInput(Collections.emptyMap());
}

protected boolean isSourceModule(ConfigSourceContext context) {
return !context.getValue("user.dir").getValue().equals(context.getValue("maven.multiModuleProjectDirectory").getValue());
}
}

0 comments on commit b50e0ae

Please sign in to comment.