Skip to content

Conversation

@renczesstefan
Copy link
Member

@renczesstefan renczesstefan commented Jan 14, 2026

Description

Fixes during testing.

Dependencies

No new dependencies were introduced

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

This was tested manually and with unit tests.

Test Configuration

Name Tested on
OS macOS Tahoe 26.0.1
Runtime Java 21
Dependency Manager Maven 3.9.9n
Framework version Spring Boot 3.4.4
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @Retoocs
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • Refactor
    • Consolidated action execution and event publication into a single, consistent flow for more reliable event handling.
    • Improved duplicate-import detection to reduce false duplicates and improve save behavior.
    • Switched index creation approach to make database index management more consistent and robust.

✏️ Tip: You can customize this high-level summary in your review settings.

Introduce `runActionAndPublishEvent` to centralize action execution and event publishing logic. Simplifies code by replacing duplicate logic with a reusable method, improving maintainability and reducing redundancy. Added `consumerMap` to support future event handling enhancements.
Replaces `findByImportId` with `findAllByImportId` for improved pagination handling in `ProcessRoleService`. Updates `ensureIndex` to `createIndex` in `AbstractMongoIndexesConfigurator` to align with updated MongoDB driver conventions.
@coderabbitai
Copy link

coderabbitai bot commented Jan 14, 2026

Walkthrough

Adds a new helper in PetriNetService to execute actions and publish a ProcessEvent in import flows; changes ProcessRoleService to detect duplicates via a paged query and filter nulls; switches Mongo index creation call from ensureIndex to createIndex.

Changes

Cohort / File(s) Summary
PetriNetService helper
application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
Adds runActionAndPublishEvent(ImportPetriNetEventOutcome, PetriNet, List<Action>, Map<String,String>, ProcessEvent) and replaces direct eventService.runActions + publisher.publishEvent calls in import flow with this consolidated helper.
ProcessRoleService query change
application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/ProcessRoleService.java
Replaces repository.findByImportId(importId).isEmpty() with findAllByImportId(importId, Pageable.ofSize(1)).isEmpty() and adds .filter(Objects::nonNull) when collecting results.
Mongo index API change
nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/configuration/AbstractMongoIndexesConfigurator.java
Uses indexOps.createIndex instead of indexOps.ensureIndex when applying collected IndexDefinition objects.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title uses a generic, vague term 'Fixes during and after testing RC9.1' that does not clearly describe the specific technical changes made. The title lacks specificity about what was actually fixed. Replace the generic 'Fixes during and after testing' phrasing with a specific description of the main technical change, such as 'Refactor action execution and event publishing in PetriNetService' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added bugfix A change that fixes a bug Medium labels Jan 14, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java`:
- Around line 131-132: The protected field consumerMap in PetriNetService is
declared but never initialized or used; either remove the consumerMap
declaration entirely if not needed, or initialize it and/or annotate its
intended use (e.g., add a TODO comment) so it isn't a null-unused field — if
keeping it, initialize consumerMap = new ConcurrentHashMap<>() (or new
HashMap<>() as appropriate) and document its purpose for future event handling
within the PetriNetService class.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ca41cc and bc2c2d3.

📒 Files selected for processing (3)
  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/ProcessRoleService.java
  • nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/configuration/AbstractMongoIndexesConfigurator.java
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: Retoocs
Repo: netgrif/application-engine PR: 383
File: application-engine/src/main/java/com/netgrif/application/engine/startup/ApplicationRunnerOrderResolver.java:43-43
Timestamp: 2025-11-14T10:22:01.634Z
Learning: For the netgrif/application-engine repository, avoid flagging trivial or nitpick-level issues such as redundant null checks, minor code style improvements, or obvious simplifications that don't affect functionality or introduce bugs. Focus review comments on substantive issues like logic errors, security concerns, performance problems, or breaking changes.
Learnt from: machacjozef
Repo: netgrif/application-engine PR: 367
File: application-engine/src/main/resources/application.yaml:24-24
Timestamp: 2025-10-20T11:44:44.907Z
Learning: In the netgrif/application-engine project, the correction of the Elasticsearch task index name from "_taks" to "_task" in application.yaml was approved by maintainer machacjozef, indicating that any data migration concerns for this typo fix are handled separately or not applicable to their deployment scenario.
Learnt from: tuplle
Repo: netgrif/application-engine PR: 331
File: application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticPetriNetService.java:45-46
Timestamp: 2025-07-29T17:19:18.300Z
Learning: In ElasticPetriNetService class, petriNetService is properly initialized using Lazy setter injection rather than constructor injection. This pattern with Lazy Autowired setter methods is commonly used in Spring to resolve circular dependencies and is a valid alternative to constructor injection.
📚 Learning: 2025-11-04T11:47:03.897Z
Learnt from: renczesstefan
Repo: netgrif/application-engine PR: 378
File: nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/elastic/domain/ElasticCase.java:16-16
Timestamp: 2025-11-04T11:47:03.897Z
Learning: In the netgrif/application-engine project, ElasticsearchRunner is responsible for creating Elasticsearch indexes automatically based on configuration. Spring Data's automatic index creation via the Document annotation's createIndex attribute should be disabled (set to false) to prevent conflicts with this centralized index management approach.

Applied to files:

  • nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/configuration/AbstractMongoIndexesConfigurator.java
📚 Learning: 2025-12-19T09:06:38.316Z
Learnt from: Retoocs
Repo: netgrif/application-engine PR: 398
File: application-engine/src/main/java/com/netgrif/application/engine/importer/service/Importer.java:57-58
Timestamp: 2025-12-19T09:06:38.316Z
Learning: In the file `application-engine/src/main/java/com/netgrif/application/engine/importer/service/Importer.java`, the `definition` attribute of the `Action` class (from `com.netgrif.application.engine.objects.petrinet.domain.dataset.logic.action.Action`) is never null, so null checks for `action.getDefinition()` are not needed.

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/ProcessRoleService.java
  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
📚 Learning: 2025-07-31T23:40:46.499Z
Learnt from: tuplle
Repo: netgrif/application-engine PR: 334
File: application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java:204-214
Timestamp: 2025-07-31T23:40:46.499Z
Learning: In the PetriNetService.importPetriNet method, existingNet.getVersion() cannot be null because all existing nets in the system were deployed through processes that ensure every net always has a version assigned.

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/ProcessRoleService.java
  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
📚 Learning: 2026-01-13T16:33:27.510Z
Learnt from: renczesstefan
Repo: netgrif/application-engine PR: 348
File: application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/interfaces/IPetriNetService.java:4-4
Timestamp: 2026-01-13T16:33:27.510Z
Learning: In the netgrif/application-engine repository, wildcard imports are preferred for the com.netgrif.application.engine.objects.petrinet.domain package. Do not suggest replacing wildcard imports with explicit imports for this package.

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/ProcessRoleService.java
  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
📚 Learning: 2025-12-12T12:36:06.651Z
Learnt from: Retoocs
Repo: netgrif/application-engine PR: 397
File: application-engine/src/main/resources/petriNets/engine-processes/org_group.xml:36-39
Timestamp: 2025-12-12T12:36:06.651Z
Learning: In the org_group.xml file (application-engine/src/main/resources/petriNets/engine-processes/org_group.xml), variable names in action blocks like userField and user_selection should be kept as-is even when the field type changes from "user" to "actor".

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
📚 Learning: 2025-07-29T17:19:18.300Z
Learnt from: tuplle
Repo: netgrif/application-engine PR: 331
File: application-engine/src/main/java/com/netgrif/application/engine/elastic/service/ElasticPetriNetService.java:45-46
Timestamp: 2025-07-29T17:19:18.300Z
Learning: In ElasticPetriNetService class, petriNetService is properly initialized using Lazy setter injection rather than constructor injection. This pattern with Lazy Autowired setter methods is commonly used in Spring to resolve circular dependencies and is a valid alternative to constructor injection.

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (4)
application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java (2)

215-224: LGTM! Clean consolidation of action execution and event publishing.

The refactoring to use runActionAndPublishEvent correctly handles both PRE and POST phases:

  • PRE phase (line 215): saveProcess is null since the net hasn't been persisted yet
  • POST phase (line 223): saveProcess is the actual saved PetriNet

This reduces code duplication and improves maintainability.


229-246: Well-documented helper method.

The runActionAndPublishEvent method is well-documented with clear parameter descriptions. The implementation correctly:

  1. Executes actions via eventService.runActions
  2. Updates the outcome with results
  3. Publishes the event
application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/ProcessRoleService.java (1)

209-216: LGTM! Consistent use of paginated query for duplicate detection.

The refactoring to use findAllByImportId with pagination is consistent with patterns used elsewhere in the codebase (e.g., DefaultRoleRunner, AnonymousRoleRunner). The short-circuit evaluation ensures findAllByImportId is only called for global roles, which consistently have non-null importId values in this codebase. The null filter at line 215 correctly handles roles skipped due to duplicate detection.

nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/configuration/AbstractMongoIndexesConfigurator.java (1)

54-54: The change from ensureIndex to createIndex is correct.

ensureIndex was deprecated in Spring Data MongoDB 4.5 with planned removal. createIndex is the recommended replacement method and this change properly aligns with current Spring Data MongoDB conventions.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 14, 2026
Remove the unused `consumerMap` field from `PetriNetService`, simplifying the class structure. This change enhances maintainability by eliminating unnecessary code. No functional impact as the field was not used.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java`:
- Line 64: Remove the unused import of java.util.function.Consumer from the
PetriNetService class; locate the import line referencing Consumer in the
imports of class PetriNetService and delete it so only used imports remain,
ensuring no other references to Consumer exist in methods or fields before
removing.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc2c2d3 and 2a64060.

📒 Files selected for processing (1)
  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: Retoocs
Repo: netgrif/application-engine PR: 383
File: application-engine/src/main/java/com/netgrif/application/engine/startup/ApplicationRunnerOrderResolver.java:43-43
Timestamp: 2025-11-14T10:22:01.634Z
Learning: For the netgrif/application-engine repository, avoid flagging trivial or nitpick-level issues such as redundant null checks, minor code style improvements, or obvious simplifications that don't affect functionality or introduce bugs. Focus review comments on substantive issues like logic errors, security concerns, performance problems, or breaking changes.
Learnt from: tuplle
Repo: netgrif/application-engine PR: 334
File: application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java:204-214
Timestamp: 2025-07-31T23:40:46.499Z
Learning: In the PetriNetService.importPetriNet method, existingNet.getVersion() cannot be null because all existing nets in the system were deployed through processes that ensure every net always has a version assigned.
📚 Learning: 2025-12-19T09:06:38.316Z
Learnt from: Retoocs
Repo: netgrif/application-engine PR: 398
File: application-engine/src/main/java/com/netgrif/application/engine/importer/service/Importer.java:57-58
Timestamp: 2025-12-19T09:06:38.316Z
Learning: In the file `application-engine/src/main/java/com/netgrif/application/engine/importer/service/Importer.java`, the `definition` attribute of the `Action` class (from `com.netgrif.application.engine.objects.petrinet.domain.dataset.logic.action.Action`) is never null, so null checks for `action.getDefinition()` are not needed.

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
📚 Learning: 2026-01-13T16:33:27.510Z
Learnt from: renczesstefan
Repo: netgrif/application-engine PR: 348
File: application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/interfaces/IPetriNetService.java:4-4
Timestamp: 2026-01-13T16:33:27.510Z
Learning: In the netgrif/application-engine repository, wildcard imports are preferred for the com.netgrif.application.engine.objects.petrinet.domain package. Do not suggest replacing wildcard imports with explicit imports for this package.

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
📚 Learning: 2025-07-31T23:40:46.499Z
Learnt from: tuplle
Repo: netgrif/application-engine PR: 334
File: application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java:204-214
Timestamp: 2025-07-31T23:40:46.499Z
Learning: In the PetriNetService.importPetriNet method, existingNet.getVersion() cannot be null because all existing nets in the system were deployed through processes that ensure every net always has a version assigned.

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
📚 Learning: 2025-12-12T12:36:06.651Z
Learnt from: Retoocs
Repo: netgrif/application-engine PR: 397
File: application-engine/src/main/resources/petriNets/engine-processes/org_group.xml:36-39
Timestamp: 2025-12-12T12:36:06.651Z
Learning: In the org_group.xml file (application-engine/src/main/resources/petriNets/engine-processes/org_group.xml), variable names in action blocks like userField and user_selection should be kept as-is even when the field type changes from "user" to "actor".

Applied to files:

  • application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (2)
application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java (2)

213-222: LGTM! Refactoring to use the helper method is clean.

The consolidation of action execution and event publishing into runActionAndPublishEvent improves maintainability. The distinction between PRE phase (passing null for the net since it's not yet persisted) and POST phase (passing the saved net) is correctly preserved.


240-244: Well-structured helper method with clear documentation.

The implementation correctly consolidates action execution and event publishing. The Javadoc thoroughly explains the method's purpose. The design is sound: getPreUploadActions() and getPostUploadActions() always return a non-null List<Action> (possibly empty), and eventService.runActions() safely handles empty lists with an early return check.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@machacjozef machacjozef merged commit 59de828 into release/7.0.0-rev9 Jan 14, 2026
7 checks passed
@machacjozef machacjozef deleted the fix/rc9.1_test_fixes branch January 14, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix A change that fixes a bug Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants