tiagodolphine commented on code in PR #3358:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3358#discussion_r1456413779


##########
api/kogito-services/src/main/java/org/kie/kogito/services/registry/ProcessDefinitionEventRegistry.java:
##########
@@ -88,9 +98,16 @@ private Function<Process<?>, ProcessDefinitionDataEvent> 
mapProcessDefinition(Se
                     .setNodes(getNodesDefinitions(p))
                     .setAnnotations(annotations)
                     .setDescription(description)
-                    .setMetadata(metadata)
-                    .build());
-            return definitionDataEvent;
+                    .setMetadata(metadata);
+            sourceFilesProvider.flatMap(provider -> 
provider.getProcessSourceFile(p.id())).map(s -> {
+                try {
+                    return new String(s.readContents());
+                } catch (IOException e) {
+                    LOGGER.warn("Error reading source for process {}", p.id(), 
e);
+                    return null;
+                }
+            }).ifPresentOrElse(s -> builder.setSource(s), () -> 
LOGGER.warn("Not source found for process id {}", p.id()));

Review Comment:
   You can do like other fields using the builder, like 
`.setMetadata(metadata).source(getSource(...))...` just to extract this into a 
method, similar `.setNodes(getNodesDefinitions(p))` just to keep it cleaner.



-- 
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