Skip to content

[NAE-2354] Include assignee userRealmId in task response#409

Merged
machacjozef merged 5 commits intorelease/7.0.0-rev10from
NAE-2354
Feb 6, 2026
Merged

[NAE-2354] Include assignee userRealmId in task response#409
machacjozef merged 5 commits intorelease/7.0.0-rev10from
NAE-2354

Conversation

@timbez
Copy link
Contributor

@timbez timbez commented Feb 3, 2026

Description

Implements NAE-2354

Blocking Pull requests

How Has Been This Tested?

manual testing in single node and cluster mode

Name Tested on
OS Windows 11
Runtime Oracle OpenJDK 21
Dependency Manager Maven 3.9.9
Framework version Spring boot 3.5.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

  • Refactor
    • Unified task assignee handling across search, assignment, persistence, and API responses.
    • Replaced separate user identifier fields with a single assignee reference throughout task flows.
    • Bulk actions and task queries now resolve by assignee, which may change which tasks are matched.
    • Task representations now include assignee identity and display-name fields for clearer attribution.

- refactor Task to contain ActorRef instead of just userId
@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

Walkthrough

Replaces per-task userId/userRealmId with a single ActorRef assignee across domain, repository, service, response, indexing, and tests; updates queries, assignment/clearing logic to use assignee; adds username and userFullName to ElasticTask.

Changes

Cohort / File(s) Summary
Domain model
nae-object-library/src/main/java/com/netgrif/application/engine/objects/workflow/domain/Task.java
Removed userId/userRealmId; added ActorRef assignee; getUserId()/getUserRealmId() now derive from assignee.
Spring adapter
nae-spring-core-adapter/src/main/java/com/netgrif/application/engine/adapter/spring/workflow/domain/Task.java
Constructor signature changed to accept ActorRef assignee (replacing userId/userRealmId) and adjusted super(...) call.
Response DTO
application-engine/src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/Task.java
Replaced public userId/userRealmId with assignee field; constructor now reads task.getAssignee().
Service & search logic
application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java, application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskSearchService.java
Assignment, delegation, token-clear, and finish flows now set/clear assignee (via ActorTransformer.toActorRef(user)); search predicates updated to use QTask.task.assignee.id.eq(...).
Repository API
application-engine/src/main/java/com/netgrif/application/engine/workflow/domain/repositories/TaskRepository.java
Query method names/params changed to reference assignee (e.g., findByAssignee_Id(...), findByAssignee_IdAndFinishDateNotNull(...), deleteAllByCaseIdAndAssignee_IdIsNull(...)).
Elastic indexing
nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticTask.java
Added username and userFullName fields; populate (and copy on update) from task.getAssignee() when present.
Tests
application-engine/src/test/groovy/com/netgrif/application/engine/ipc/TaskApiTest.groovy
Updated assertions to filter by assignee.id instead of userId in bulk-action test.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title claims to include assignee userRealmId in task response, but the changeset refactors user identification from userId/userRealmId fields to an ActorRef-based assignee model across multiple services and repositories. Update the title to reflect the main change: refactoring user identification to use ActorRef assignee instead of separate userId/userRealmId fields.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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.

tuplle
tuplle previously approved these changes Feb 3, 2026
Copy link
Contributor

@Retoocs Retoocs left a comment

Choose a reason for hiding this comment

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

tests are failing

# Conflicts:
#	application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java
- resolve conflicts with rev10 branch
@coderabbitai coderabbitai bot added improvement A change that improves on an existing feature Medium labels Feb 5, 2026
- fix TaskRepository methods dependent on removed attribute userId
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

Caution

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

⚠️ Outside diff range comments (2)
application-engine/src/main/java/com/netgrif/application/engine/workflow/web/responsebodies/Task.java (1)

78-115: ⚠️ Potential issue | 🟠 Major

Populate assignee for ElasticTask-based responses.

assignee is set only when constructed from domain Task; responses built from ElasticTask still return null, which defeats the requirement to include userRealmId for those code paths.

✅ Suggested fix
 public Task(ElasticTask entity) {
     _id = new ProcessResourceId(entity.getId());
     caseId = entity.getCaseId();
     transitionId = entity.getTransitionId();
     title = entity.getTitle().getDefaultValue();
     caseTitle = entity.getCaseTitle();
     priority = entity.getPriority();
+    if (entity.getUserId() != null || entity.getUserRealmId() != null) {
+        this.assignee = new ActorRef(
+                entity.getUserId(),
+                entity.getUserRealmId(),
+                entity.getUsername(),
+                entity.getUserFullName()
+        );
+    }
 }
nae-object-library/src/main/java/com/netgrif/application/engine/objects/elastic/domain/ElasticTask.java (1)

50-105: ⚠️ Potential issue | 🟡 Minor

Add explicit Elasticsearch @Field annotations for user identity fields in Spring ElasticTask.

The new userFullName and username fields lack explicit @Field annotations in the Spring adapter class. Note that userId and userRealmId also lack explicit mappings. While dynamic mapping will handle unmapped fields, explicit annotations should be added for consistency with the rest of the ElasticTask mapping definition (similar to how other string fields use @Field(type = Keyword)).

🤖 Fix all issues with AI agents
In
`@application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java`:
- Around line 399-403: The task unassignment clears assignee and startDate but
leaves the stale task.user field; in TaskService (around the block that calls
workflowService.updateMarking(useCase) and then task.setAssignee(null);
task.setStartDate(null);) also clear the user reference by calling the
appropriate setter (e.g., task.setUser(null)) or nulling the user property so
the task no longer retains the previous user when unassigned.

@coderabbitai coderabbitai bot added the breaking change Fix or feature that would cause existing functionality doesn't work as expected label Feb 5, 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: 2

🤖 Fix all issues with AI agents
In
`@application-engine/src/main/java/com/netgrif/application/engine/workflow/domain/repositories/TaskRepository.java`:
- Line 31: Rename the repository method to remove the extraneous underscore
before the connector so Spring can parse the derived query: change the method
name findByAssignee_Id_AndFinishDateNotNull to
findByAssignee_IdAndFinishDateNotNull in TaskRepository and update any call
sites accordingly; ensure the signature remains List<Task>
findByAssignee_IdAndFinishDateNotNull(String userId) and run a build/tests to
verify no further naming issues.

In
`@application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java`:
- Around line 571-576: The finish flow in TaskService leaves a stale task.user
after completing a task; update the finish logic to clear the user reference by
calling task.setUser(null) (in the same block that currently calls
task.setAssignee(null) and task.setFinishDate(...)), then save(task) and return
workflowService.save(useCase) as before so both assignee and user are cleared
consistently with the assignment code paths.

@netgrif netgrif deleted a comment from coderabbitai bot Feb 5, 2026
@machacjozef machacjozef requested review from Retoocs and tuplle February 5, 2026 11:15
@machacjozef machacjozef merged commit 822461d into release/7.0.0-rev10 Feb 6, 2026
6 of 7 checks passed
@machacjozef machacjozef deleted the NAE-2354 branch February 6, 2026 23:05
@coderabbitai coderabbitai bot mentioned this pull request Feb 7, 2026
18 tasks
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 improvement A change that improves on an existing feature Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants