From 2f8e10e714509acb1e1a40e4039aed078152fd15 Mon Sep 17 00:00:00 2001 From: Martin Weiler Date: Thu, 23 May 2024 10:37:38 -0600 Subject: [PATCH] [incubator-kie-issues#1249] Fix REST call in process-rest-workitem-quarkus example (#1926) --- .../process-rest-workitem-quarkus/pom.xml | 4 -- ...rsRemoteService.java => UserResource.java} | 12 ++-- .../org/acme/travels/rest/UserService.java | 18 +++++ .../src/main/resources/application.properties | 3 - .../resources/org/acme/travels/users.bpmn | 65 +++++++++++++------ 5 files changed, 71 insertions(+), 31 deletions(-) rename kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/{UsersRemoteService.java => UserResource.java} (83%) create mode 100644 kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UserService.java diff --git a/kogito-quarkus-examples/process-rest-workitem-quarkus/pom.xml b/kogito-quarkus-examples/process-rest-workitem-quarkus/pom.xml index d785a78edf..e4a9cfef3a 100644 --- a/kogito-quarkus-examples/process-rest-workitem-quarkus/pom.xml +++ b/kogito-quarkus-examples/process-rest-workitem-quarkus/pom.xml @@ -79,10 +79,6 @@ io.quarkus quarkus-smallrye-openapi - - io.quarkus - quarkus-rest-client - io.quarkus quarkus-junit5 diff --git a/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UsersRemoteService.java b/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UserResource.java similarity index 83% rename from kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UsersRemoteService.java rename to kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UserResource.java index 9cf97fe664..9e8ee5c798 100644 --- a/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UsersRemoteService.java +++ b/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UserResource.java @@ -19,19 +19,23 @@ package org.acme.travels.rest; import org.acme.travels.User; -import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; +import jakarta.inject.Inject; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @Path("/v2") -@RegisterRestClient -public interface UsersRemoteService { +public class UserResource { + + @Inject + UserService userService; @GET @Path("/user/{username}") @Produces("application/json") - User get(@PathParam("username") String username); + public User getUser(@PathParam("username") String username) { + return userService.getUser(username); + } } diff --git a/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UserService.java b/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UserService.java new file mode 100644 index 0000000000..f4f89a0a00 --- /dev/null +++ b/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/java/org/acme/travels/rest/UserService.java @@ -0,0 +1,18 @@ +package org.acme.travels.rest; + +import org.acme.travels.User; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class UserService { + + public User getUser(String name) { + if ("test".equals(name)) { + User user = new User(); + user.setLastName(name); + return user; + } + return null; + } +} diff --git a/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/resources/application.properties b/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/resources/application.properties index 0bf4f46b1f..9553ee92e4 100644 --- a/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/resources/application.properties +++ b/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/resources/application.properties @@ -21,6 +21,3 @@ # quarkus.package.type=fast-jar quarkus.swagger-ui.always-include=true - -org.acme.travels.rest.UsersRemoteService/mp-rest/url=https://petstore.swagger.io -org.acme.travels.rest.UsersRemoteService/mp-rest/scope=javax.enterprise.context.ApplicationScoped \ No newline at end of file diff --git a/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/resources/org/acme/travels/users.bpmn b/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/resources/org/acme/travels/users.bpmn index 27a92410df..6be2d68d1c 100644 --- a/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/resources/org/acme/travels/users.bpmn +++ b/kogito-quarkus-examples/process-rest-workitem-quarkus/src/main/resources/org/acme/travels/users.bpmn @@ -1,13 +1,25 @@ - + + + + - + + + + - + + _E5D17755-D671-43ED-BD7D-F6538933069C_InMessage + _E5D17755-D671-43ED-BD7D-F6538933069C_OutMessage + + + + @@ -21,21 +33,21 @@ - + - + - + - + - + - + @@ -57,13 +69,15 @@ _DBA10C00-6407-4EF5-9D85-01177AE8F39F _1A98DE32-CF81-424B-A59E-6D22899E31C0 - + + - _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_EndpointInputX + _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_UrlInputX _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_usernameInputX + _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_PortInputX _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_TaskNameInputX @@ -71,16 +85,23 @@ - _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_EndpointInputX + _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_UrlInputX - + username _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_usernameInputX + + _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_PortInputX + + + + + _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_TaskNameInputX @@ -88,6 +109,10 @@ + + _296CCA4D-3C70-469C-A10E-2FF421D4D7A8_ResultOutputX + traveller + @@ -131,8 +156,8 @@ _1A98DE32-CF81-424B-A59E-6D22899E31C0 - _BF17E37C-6984-4F27-9B6A-A9880E95B019 _4EFC11AE-52BB-4EEF-B241-CFAAE4B7AE93 + _BF17E37C-6984-4F27-9B6A-A9880E95B019 @@ -171,15 +196,15 @@ + + + + - - - - @@ -241,7 +266,7 @@ - _1ztzQLGyEDmz-aPY8v7uEg - _1ztzQLGyEDmz-aPY8v7uEg + _yBVmwPqbEDyfjZKSxf4Vqg + _yBVmwPqbEDyfjZKSxf4Vqg \ No newline at end of file