Skip to content

[NAE-2439] Implement new filter data types#446

Open
Retoocs wants to merge 4 commits into
release/6.5.0from
NAE-2439
Open

[NAE-2439] Implement new filter data types#446
Retoocs wants to merge 4 commits into
release/6.5.0from
NAE-2439

Conversation

@Retoocs
Copy link
Copy Markdown
Contributor

@Retoocs Retoocs commented May 29, 2026

Description

Introduced new filter fields. Removed old FilterField. New filter fields are more simple

Implements NAE-2439

Dependencies

No new dependencies were introduced

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

Depends on petriflow/petriflow#30

How Has Been This Tested?

Manually and by unit test

FilterTest.groovy

Test Configuration

Name Tested on
OS Ubuntu 24.04.1 LTS
Runtime Java 11
Dependency Manager Maven 3.6.3
Framework version Spring Boot 2.7.8
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 @...
  • 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

  • New Features

    • Filter functionality now supports specialized filter types: case filters, task filters, and process filters for more targeted workflow management.
  • Improvements

    • Simplified filter configuration by streamlining metadata handling and network allowlist settings.
  • Tests

    • Added comprehensive test coverage for new filter field types and their behavior.

Review Change Stack

Retoocs added 4 commits May 27, 2026 14:48
- introduce new filter fields
- remove old filter field
- remove transactional in Importer
- handle deprecated filter data type when importing process
- remove use of deleted filter attributes
- force component use for dedicated filter fields
- fix cloning filter fields
@Retoocs Retoocs self-assigned this May 29, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Walkthrough

This PR decomposes a generic FilterField type into three specialized filter field types (CaseFilterField, TaskFilterField, ProcessFilterField) with corresponding changes across field construction, data state management, configuration, and response serialization layers.

Changes

Filter Field Architecture Refactoring

Layer / File(s) Summary
Domain model and type system foundation
src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/FieldType.groovy, src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/CaseFilterField.groovy, ProcessFilterField.groovy, TaskFilterField.groovy
FieldType enum replaces FILTER with CASE_FILTER, TASK_FILTER, PROCESS_FILTER; three new MongoDB-mapped filter field domain classes introduced; FilterField class deleted.
Field instantiation and import processing
src/main/java/com/netgrif/application/engine/importer/service/FieldFactory.java, Importer.java
FieldFactory routes filter types through dedicated builders; resolveFilterMetadata helper removed; Importer removes @Transactional annotations, updates addUserLogic(ActorRef) signature, and uses Field<?> generics in field construction.
Data field state and service updates
src/main/java/com/netgrif/application/engine/workflow/domain/DataField.java, DataService.java, Case.java
DataField removes filterMetadata field and setter; DataService removes metadata parsing and restricts allowedNets to caseRef types only; Case.populateDataSet replaces FilterField metadata logic with FieldWithAllowedNets handling.
Filter usage, DSL, and configuration
src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy, src/main/java/com/netgrif/application/engine/menu/domain/FilterBody.java, MenuItemService.java, FilterImportExportService.java, IFilterImportExportService.java, src/main/resources/petriNets/engine-processes/import_filters.xml
ActionDelegate removes defaultFilterMetadata helper and DSL support for allowedNets/filterMetadata updates; FilterBody removes allowedNets, icon, metadata fields; MenuItemService removes icon assignment; FilterImportExportService removes changeFilterField invocation and metadata export; import_filters.xml removes associated action trigger.
HTTP response layer and field localization
src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/LocalisedFieldFactory.java, LocalisedCaseFilterField.java, LocalisedTaskFilterField.java, LocalisedProcessFilterField.java
LocalisedFieldFactory.from routes three new filter types to dedicated factory methods; fromFilter method replaced by three type-specific factory methods; three new localized response classes added; LocalisedFilterField class removed.
Test validation and coverage
src/test/groovy/com/netgrif/application/engine/filters/FilterTest.groovy, FilterImportExportTest.groovy, src/test/resources/petriNets/filter_test.xml
New FilterTest integration test validates field type mappings and state management for all four filter field types; FilterImportExportTest disabled at class level; filter_test.xml test resource defines test Petri net with filter fields.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • netgrif/application-engine#400: Both PRs modify DataService.setData processing—main PR removes filterMetadata handling while retrieved PR adds runStrict security gating for TASK_REF/CASE_REF.
  • netgrif/application-engine#315: Both PRs touch ActionDelegate.groovy filter DSL—main removes filterMetadata/allowedNets support while retrieved PR adds type parameter validation.

Suggested labels

new feature, breaking change, Large, refactoring

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'NAE-2439 Implement new filter data types' clearly and concisely summarizes the main change: introducing new filter field types, which aligns with the substantial refactoring across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@dpulls
Copy link
Copy Markdown

dpulls Bot commented May 29, 2026

⚠️ Dpulls not installed on repository petriflow/petriflow. Checkout our quickstart for how to install.

@Retoocs Retoocs marked this pull request as ready for review May 29, 2026 13:33
@coderabbitai coderabbitai Bot added new feature A change that introduces new functionality breaking change Fix or feature that would cause existing functionality doesn't work as expected Large Medium labels May 29, 2026
@dpulls
Copy link
Copy Markdown

dpulls Bot commented May 29, 2026

⚠️ Dpulls not installed on repository petriflow/petriflow. Checkout our quickstart for how to install.

Copy link
Copy Markdown

@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: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/netgrif/application/engine/menu/domain/FilterBody.java (1)

18-23: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Removing these fields also removes accessors that current callers still use.

This change drops the Lombok-generated setAllowedNets(...), setIcon(...), and setMetadata(...) methods, but ActionDelegate.groovy still calls them in the provided context (for example around Lines 1619-1622, 2036-2039, and 2466-2469). Those filter/menu creation paths will now fail at runtime in Groovy with a missing-method error unless the callers are migrated in the same PR or compatibility setters are kept temporarily.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/netgrif/application/engine/menu/domain/FilterBody.java`
around lines 18 - 23, The removal of fields from FilterBody removed
Lombok-generated setters (setAllowedNets, setIcon, setMetadata) that
ActionDelegate.groovy still invokes; restore binary compatibility by
reintroducing those setters on FilterBody (either add back the removed fields
with appropriate types or add explicit public setter methods named
setAllowedNets, setIcon, setMetadata that accept the same parameter types as
before) so ActionDelegate.groovy calls (around the spots that used those
setters) continue to work without runtime missing-method errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/netgrif/application/engine/importer/service/FieldFactory.java`:
- Around line 251-254: The code in FieldFactory currently maps the deprecated
FILTER token directly to buildCaseFilterField, which will misclassify legacy
filters; update the FILTER branch in the switch inside FieldFactory to inspect
the incoming legacy definition (e.g., a "filterType" discriminator or other
distinguishing attributes on the data object) and route to the correct builder
(e.g., buildCaseFilterField or the task/process-specific builder), and if the
discriminator is missing or ambiguous, fail fast by throwing a descriptive
exception rather than silently coercing; reference the FILTER and CASE_FILTER
enum values and the buildCaseFilterField method when implementing the
discriminator check and error path.

In `@src/main/java/com/netgrif/application/engine/importer/service/Importer.java`:
- Line 243: The method signature change to protected void
resolveUserRef(CaseActorRef userRef) and related uses reference types
(CaseActorRef, ActorRef) that don't exist in
com.netgrif.application.engine.importer.model in this branch; revert the
signature and any other changed method/type usages to the existing importer
model types (restore the original parameter/type declarations used before the
PR) or update imports to the regenerated importer model only if that regenerated
model is landed in this stack; specifically update resolveUserRef and any
methods referencing CaseActorRef/ActorRef to use the existing model classes
present in the branch (or postpone these signature changes until the new
importer model is merged).

In
`@src/test/groovy/com/netgrif/application/engine/filters/FilterImportExportTest.groovy`:
- Line 40: The test class FilterImportExportTest has been globally disabled with
`@Disabled` because it references removed DataField properties filterMetadata and
allowedNets; add a tracking reference so we don’t lose the TODO — insert a
concise TODO/JIRA comment next to the `@Disabled` annotation or at the top of the
class mentioning the ticket (e.g. TODO: RE-ENABLE after migrating to new filter
field architecture — JIRA-XXXX) and note which symbols need updating
(filterMetadata, allowedNets on DataField) so the future change and re-enabling
steps are clear.

In `@src/test/groovy/com/netgrif/application/engine/filters/FilterTest.groovy`:
- Line 61: The FileInputStream created for PROCESS_PATH when calling
petriNetService.importPetriNet(...) is never closed and may leak; wrap the
stream creation and the import call in a try-with-resources (or use Groovy's
withCloseable) so the FileInputStream is automatically closed after use.
Specifically, ensure the FileInputStream used to set PetriNet testProcess via
petriNetService.importPetriNet(new FileInputStream(PROCESS_PATH),
VersionType.MAJOR, superCreator.loggedSuper).getNet() is created inside a
try(resource) block (or passed through withCloseable) so the stream is closed
even on exceptions.

---

Outside diff comments:
In `@src/main/java/com/netgrif/application/engine/menu/domain/FilterBody.java`:
- Around line 18-23: The removal of fields from FilterBody removed
Lombok-generated setters (setAllowedNets, setIcon, setMetadata) that
ActionDelegate.groovy still invokes; restore binary compatibility by
reintroducing those setters on FilterBody (either add back the removed fields
with appropriate types or add explicit public setter methods named
setAllowedNets, setIcon, setMetadata that accept the same parameter types as
before) so ActionDelegate.groovy calls (around the spots that used those
setters) continue to work without runtime missing-method errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9b66e756-f883-4739-bd3b-ff0706ec6d0e

📥 Commits

Reviewing files that changed from the base of the PR and between 7dabfe9 and 4fb5875.

📒 Files selected for processing (24)
  • src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/CaseFilterField.groovy
  • src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/FieldType.groovy
  • src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/FilterField.groovy
  • src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/ProcessFilterField.groovy
  • src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/TaskFilterField.groovy
  • src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/logic/action/ActionDelegate.groovy
  • src/main/java/com/netgrif/application/engine/importer/service/FieldFactory.java
  • src/main/java/com/netgrif/application/engine/importer/service/Importer.java
  • src/main/java/com/netgrif/application/engine/menu/domain/FilterBody.java
  • src/main/java/com/netgrif/application/engine/menu/services/MenuItemService.java
  • src/main/java/com/netgrif/application/engine/workflow/domain/Case.java
  • src/main/java/com/netgrif/application/engine/workflow/domain/DataField.java
  • src/main/java/com/netgrif/application/engine/workflow/service/DataService.java
  • src/main/java/com/netgrif/application/engine/workflow/service/FilterImportExportService.java
  • src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IFilterImportExportService.java
  • src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/LocalisedCaseFilterField.java
  • src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/LocalisedFieldFactory.java
  • src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/LocalisedFilterField.java
  • src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/LocalisedProcessFilterField.java
  • src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/LocalisedTaskFilterField.java
  • src/main/resources/petriNets/engine-processes/import_filters.xml
  • src/test/groovy/com/netgrif/application/engine/filters/FilterImportExportTest.groovy
  • src/test/groovy/com/netgrif/application/engine/filters/FilterTest.groovy
  • src/test/resources/petriNets/filter_test.xml
💤 Files with no reviewable changes (8)
  • src/main/groovy/com/netgrif/application/engine/petrinet/domain/dataset/FilterField.groovy
  • src/main/java/com/netgrif/application/engine/workflow/service/interfaces/IFilterImportExportService.java
  • src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/LocalisedFilterField.java
  • src/main/resources/petriNets/engine-processes/import_filters.xml
  • src/main/java/com/netgrif/application/engine/menu/services/MenuItemService.java
  • src/main/java/com/netgrif/application/engine/workflow/service/FilterImportExportService.java
  • src/main/java/com/netgrif/application/engine/workflow/domain/DataField.java
  • src/main/java/com/netgrif/application/engine/workflow/domain/Case.java

Comment on lines +251 to +254
case FILTER: // "FILTER" is deprecated
case CASE_FILTER:
field = buildCaseFilterField(data);
break;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Don't coerce every legacy FILTER import into a case filter.

Lines 251-254 currently map the deprecated FILTER type straight to CaseFilterField, so any legacy task/process filter imported through the old generic type will silently change behavior during migration. Please infer the dedicated filter field type from the legacy definition before constructing it, or fail fast when that information is unavailable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/netgrif/application/engine/importer/service/FieldFactory.java`
around lines 251 - 254, The code in FieldFactory currently maps the deprecated
FILTER token directly to buildCaseFilterField, which will misclassify legacy
filters; update the FILTER branch in the switch inside FieldFactory to inspect
the incoming legacy definition (e.g., a "filterType" discriminator or other
distinguishing attributes on the data object) and route to the correct builder
(e.g., buildCaseFilterField or the task/process-specific builder), and if the
discriminator is missing or ambiguous, fail fast by throwing a descriptive
exception rather than silently coercing; reference the FILTER and CASE_FILTER
enum values and the buildCaseFilterField method when implementing the
discriminator check and error path.


@Transactional
protected void resolveUserRef(CaseUserRef userRef) {
protected void resolveUserRef(CaseActorRef userRef) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

Use importer model types that actually exist in this branch.

These signature changes are a hard build break: the current com.netgrif.application.engine.importer.model package does not contain CaseActorRef or ActorRef, and the pipeline is already failing on both lines. If this PR depends on the Petriflow schema change, the regenerated importer model needs to land in the same stack before merge; otherwise keep these methods typed to the existing model classes.

Also applies to: 732-732

🧰 Tools
🪛 GitHub Actions: Pull Request / 1_Build.txt

[error] 243-243: Compilation error (cannot find symbol). Missing class 'CaseActorRef' referenced in com.netgrif.application.engine.importer.service.Importer.

🪛 GitHub Actions: Pull Request / Build

[error] 243-243: Compilation error in Maven compiler plugin: cannot find symbol. Symbol: class CaseActorRef, location: class com.netgrif.application.engine.importer.service.Importer.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/netgrif/application/engine/importer/service/Importer.java`
at line 243, The method signature change to protected void
resolveUserRef(CaseActorRef userRef) and related uses reference types
(CaseActorRef, ActorRef) that don't exist in
com.netgrif.application.engine.importer.model in this branch; revert the
signature and any other changed method/type usages to the existing importer
model types (restore the original parameter/type declarations used before the
PR) or update imports to the regenerated importer model only if that regenerated
model is landed in this stack; specifically update resolveUserRef and any
methods referencing CaseActorRef/ActorRef to use the existing model classes
present in the branch (or postpone these signature changes until the new
importer model is merged).

import javax.xml.validation.Validator
import java.util.stream.Collectors

@Disabled
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add a tracking reference for re-enabling this test suite.

The entire test class is now disabled because it references removed functionality (Lines 185-186 reference filterMetadata and allowedNets on DataField). To track this technical debt, consider adding a TODO comment or JIRA ticket reference explaining when and how this test suite will be updated for the new filter field architecture.

📝 Suggested TODO comment
-@Disabled
+@Disabled("TODO(NAE-XXXX): Update filter import/export tests for new specialized filter field types")
 `@ExtendWith`(SpringExtension.class)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Disabled
`@Disabled`("TODO(NAE-XXXX): Update filter import/export tests for new specialized filter field types")
`@ExtendWith`(SpringExtension.class)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/groovy/com/netgrif/application/engine/filters/FilterImportExportTest.groovy`
at line 40, The test class FilterImportExportTest has been globally disabled
with `@Disabled` because it references removed DataField properties filterMetadata
and allowedNets; add a tracking reference so we don’t lose the TODO — insert a
concise TODO/JIRA comment next to the `@Disabled` annotation or at the top of the
class mentioning the ticket (e.g. TODO: RE-ENABLE after migrating to new filter
field architecture — JIRA-XXXX) and note which symbols need updating
(filterMetadata, allowedNets on DataField) so the future change and re-enabling
steps are clear.


@Test
void filterTest() {
PetriNet testProcess = petriNetService.importPetriNet(new FileInputStream(PROCESS_PATH), VersionType.MAJOR, superCreator.loggedSuper).getNet()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Close the FileInputStream to prevent resource leak.

The FileInputStream created on Line 61 is never explicitly closed, which can lead to a resource leak.

💧 Proposed fix to close the resource

Groovy supports try-with-resources syntax. Wrap the file operation:

-        PetriNet testProcess = petriNetService.importPetriNet(new FileInputStream(PROCESS_PATH), VersionType.MAJOR, superCreator.loggedSuper).getNet()
+        PetriNet testProcess
+        new FileInputStream(PROCESS_PATH).withCloseable { stream ->
+            testProcess = petriNetService.importPetriNet(stream, VersionType.MAJOR, superCreator.loggedSuper).getNet()
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
PetriNet testProcess = petriNetService.importPetriNet(new FileInputStream(PROCESS_PATH), VersionType.MAJOR, superCreator.loggedSuper).getNet()
PetriNet testProcess
new FileInputStream(PROCESS_PATH).withCloseable { stream ->
testProcess = petriNetService.importPetriNet(stream, VersionType.MAJOR, superCreator.loggedSuper).getNet()
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/groovy/com/netgrif/application/engine/filters/FilterTest.groovy` at
line 61, The FileInputStream created for PROCESS_PATH when calling
petriNetService.importPetriNet(...) is never closed and may leak; wrap the
stream creation and the import call in a try-with-resources (or use Groovy's
withCloseable) so the FileInputStream is automatically closed after use.
Specifically, ensure the FileInputStream used to set PetriNet testProcess via
petriNetService.importPetriNet(new FileInputStream(PROCESS_PATH),
VersionType.MAJOR, superCreator.loggedSuper).getNet() is created inside a
try(resource) block (or passed through withCloseable) so the stream is closed
even on exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Fix or feature that would cause existing functionality doesn't work as expected Large Medium new feature A change that introduces new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant