Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix_#3353] Adding source to process definition data event #3358

Merged
merged 2 commits into from
Jan 18, 2024

Conversation

fjtirado
Copy link
Contributor

@fjtirado fjtirado commented Jan 17, 2024

Fixes #3353
Integration test here apache/incubator-kie-kogito-apps#1958

@@ -37,9 +40,10 @@ public class ProcessDefinitionRegistration {
ProcessDefinitionEventRegistry processDefinitionRegistry;

@Inject
public ProcessDefinitionRegistration(Application application, KogitoRuntimeConfig runtimeConfig, Instance<Processes> processes) {
public ProcessDefinitionRegistration(Application application, KogitoRuntimeConfig runtimeConfig, Instance<Processes> processes, Instance<SourceFilesProvider> sourceFilesProvider) {
Copy link
Contributor Author

@fjtirado fjtirado Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep SourceFilesProvider optional, so source addon should still be present for source to be added to the event.
The alternative is to make this mandatory and move SourceFilesProviderFactory to quarkus common extension.
I wanted to be conservative since we are close to the release deadline

Copy link
Contributor

@tiagodolphine tiagodolphine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 102 to 109
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()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if source (in case the addon is not in the set of dependencies) is not there, getSource() will return null, and we will be setting source to null in the builder when it is not really needed.
However, I agree that this can be done more readable, please check the new version

@fjtirado
Copy link
Contributor Author

@fjtirado fjtirado merged commit b89e14d into apache:main Jan 18, 2024
6 of 11 checks passed
rgdoliveira pushed a commit to rgdoliveira/kogito-runtimes that referenced this pull request Jan 25, 2024
* [Fix_#3353] Adding source to process definition data event

* [Fix_#3353] Tiagos comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include source in ProcessDefinitionEvent
3 participants