elguardian commented on code in PR #1962:
URL: 
https://github.com/apache/incubator-kie-kogito-apps/pull/1962#discussion_r1462991998


##########
data-audit/kogito-addons-data-audit-quarkus/src/main/java/org/kie/kogito/app/audit/quarkus/GraphQLJPADataAuditRouter.java:
##########
@@ -46,22 +53,50 @@ public class GraphQLJPADataAuditRouter {
     @Inject
     DataAuditContextFactory dataAuditContextFactory;
 
+    private DataAuditQueryService dataAuditQueryService;
+
+    private DataAuditStoreProxyService dataAuditStoreProxyService;
+
     @PostConstruct
     public void init() {
-        graphQL = 
GraphQL.newGraphQL(DataAuditQueryService.newAuditQuerySerice().getGraphQLSchema()).build();
-        graphQLHandler = GraphQLHandler.create(graphQL, new 
GraphQLHandlerOptions());
+        
graphQLSchemaManagerInstance().rebuildDefinitions(dataAuditContextFactory.newDataAuditContext());
+        dataAuditQueryService = DataAuditQueryService.newAuditQuerySerice();
+        dataAuditStoreProxyService = 
DataAuditStoreProxyService.newAuditStoreService();
+        graphQLHandler = 
GraphQLHandler.create(dataAuditQueryService.getGraphQL(), new 
GraphQLHandlerOptions());
     }
 
-    @Route(path = DATA_AUDIT_PATH, type = Route.HandlerType.BLOCKING, order = 
2, methods = { GET })
+    @Route(path = DATA_AUDIT_QUERY_PATH, type = Route.HandlerType.BLOCKING, 
order = 2, methods = { GET })
     public void blockingGraphQLHandlerGet(RoutingContext rc) {
         graphQLHandler.beforeExecute(this::beforeExecuteHTTP).handle(rc);
     }
 
-    @Route(path = DATA_AUDIT_PATH, type = Route.HandlerType.BLOCKING, order = 
2, methods = { POST })
+    @Route(path = DATA_AUDIT_QUERY_PATH, type = Route.HandlerType.BLOCKING, 
order = 2, methods = { POST })
     public void blockingGraphQLHandlerPost(RoutingContext rc) {
         graphQLHandler.beforeExecute(this::beforeExecuteHTTP).handle(rc);
     }
 
+    @Route(path = DATA_AUDIT_REGISTRY_PATH, type = Route.HandlerType.BLOCKING, 
order = 2, methods = { POST })
+    public void blockingRegistryHandlerPost(RoutingContext rc) {
+        try {
+            JsonObject jsonObject = rc.body().asJsonObject();
+            DataAuditQuery dataAuditQuery = new DataAuditQuery();
+            dataAuditQuery.setIdentifier(jsonObject.getString("identifier"));
+            
dataAuditQuery.setGraphQLDefinition(jsonObject.getString("graphQLDefinition"));
+            dataAuditQuery.setQuery(jsonObject.getString("query"));
+            
dataAuditStoreProxyService.storeQuery(dataAuditContextFactory.newDataAuditContext(),
 dataAuditQuery);
+            graphQLHandler = 
GraphQLHandler.create(dataAuditQueryService.getGraphQL(), new 
GraphQLHandlerOptions());
+            rc.response().setStatusCode(200).end();
+        } catch (Exception e) {
+            rc.response().setStatusCode(400).end();
+        }
+
+    }
+

Review Comment:
   this will be addressed in another issue.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to