Repository: urlaubsverwaltung/urlaubsverwaltung (java)

Issue:
[API|Persons] Ability to retrieve person active status via API
**Is this feature request dependent on another feature request?**
- [ ] #5125: While the API only returns active persons, we know by default that all persons are active.

**Is your feature request related to a problem? Please describe.**

In order for our [ConnId](https://github.com/Tirasa/ConnId) identity connector to properly display information about
accounts it created in the UV, we need a way to retrieve the active status from a person.


**Describe the solution you'd like**

ANY OF these ways:

- add an `isActive` flag to the returned PersonDto
- add the user's `roles` to the returned PersonDto
  - _Clarification:_ Depends on the internal representation that disabled persons have `roles = [DISABLED]`
  - _Outlook:_ Having the roles on the PersonDto may allow future versions to also update these roles via the API?
- make two separate calls that return a different set of persons
  - _Clarification:_ This may require the client to then compute set differences to infer which persons are active or inactive
  - _Possible Implementation:_ One call that returns all active persons and one that returns all inactive persons
  - _Possible Implementation:_ One call that returns all active persons and one that returns all persons

**Optionally describe alternatives you've considered**
N/A

**Optionally additional context**
N/A


Pull request:
feat: add active flag to UserDto
closes #5126


Still a draft since it does not make much sense without
- [x] #5028



Patch:
diff --git a/src/main/java/org/synyx/urlaubsverwaltung/person/api/PersonDto.java b/src/main/java/org/synyx/urlaubsverwaltung/person/api/PersonDto.java
index 3ad06a692..acd47d7b5 100644
--- a/src/main/java/org/synyx/urlaubsverwaltung/person/api/PersonDto.java
+++ b/src/main/java/org/synyx/urlaubsverwaltung/person/api/PersonDto.java
@@ -22,13 +22,15 @@ public class PersonDto extends RepresentationModel<PersonDto> {
     private String firstName;
     private String lastName;
     private String niceName;
+    private boolean active;
 
-    PersonDto(Long id, String email, String firstName, String lastName, String niceName) {
+    PersonDto(Long id, String email, String firstName, String lastName, String niceName, boolean active) {
         this.id = id;
         this.email = email;
         this.firstName = firstName;
         this.lastName = lastName;
         this.niceName = niceName;
+        this.active = active;
 
         this.add(linkTo(methodOn(PersonApiController.class).getPerson(id)).withSelfRel());
         this.add(linkTo(methodOn(AbsenceApiController.class).personsAbsences(id, null, null, List.of("vacation", "sick_note", "public_holiday", "no_workday"))).withRel(ABSENCES));
@@ -76,4 +78,12 @@ public class PersonDto extends RepresentationModel<PersonDto> {
     public void setNiceName(String niceName) {
         this.niceName = niceName;
     }
+
+    public boolean isActive() {
+        return active;
+    }
+
+    public void setActive(boolean active) {
+        this.active = active;
+    }
 }
diff --git a/src/main/java/org/synyx/urlaubsverwaltung/person/api/PersonMapper.java b/src/main/java/org/synyx/urlaubsverwaltung/person/api/PersonMapper.java
index 0fbe6b6b9..4e426028e 100644
--- a/src/main/java/org/synyx/urlaubsverwaltung/person/api/PersonMapper.java
+++ b/src/main/java/org/synyx/urlaubsverwaltung/person/api/PersonMapper.java
@@ -1,6 +1,7 @@
 package org.synyx.urlaubsverwaltung.person.api;
 
 import org.synyx.urlaubsverwaltung.person.Person;
+import org.synyx.urlaubsverwaltung.person.Role;
 
 public final class PersonMapper {
 
@@ -8,7 +9,7 @@ public final class PersonMapper {
         // prevents initialisation
     }
 
-    public static PersonDto mapToDto(Person person) {
-        return new PersonDto(person.getId(), person.getEmail(), person.getFirstName(), person.getLastName(), person.getNiceName());
+    public static PersonDto mapToDto(final Person person) {
+        return new PersonDto(person.getId(), person.getEmail(), person.getFirstName(), person.getLastName(), person.getNiceName(), person.isActive());
     }
 }


Test patch:
diff --git a/src/test/java/org/synyx/urlaubsverwaltung/person/api/PersonApiControllerIT.java b/src/test/java/org/synyx/urlaubsverwaltung/person/api/PersonApiControllerIT.java
index 09198ff18..674d457c6 100644
--- a/src/test/java/org/synyx/urlaubsverwaltung/person/api/PersonApiControllerIT.java
+++ b/src/test/java/org/synyx/urlaubsverwaltung/person/api/PersonApiControllerIT.java
@@ -63,6 +63,7 @@ class PersonApiControllerIT extends SingleTenantTestContainersBase {
                           "firstName": "shane",
                           "lastName": "last",
                           "niceName": "shane last",
+                          "active": true,
                           "_links":{
                             "self":{
                               "href":"http://localhost/api/persons/1"
@@ -119,6 +120,7 @@ class PersonApiControllerIT extends SingleTenantTestContainersBase {
                           "firstName": "shane",
                           "lastName": "shane",
                           "niceName": "shane shane",
+                          "active": true,
                           "_links":{
                             "self":{
                               "href":"http://localhost/api/persons/1"
@@ -170,6 +172,7 @@ class PersonApiControllerIT extends SingleTenantTestContainersBase {
                                "firstName": "shane",
                                "lastName": "shane",
                                "niceName": "shane shane",
+                               "active": true,
                                "_links": {
                                  "self": {
                                    "href": "http://localhost/api/persons/1"
@@ -198,6 +201,7 @@ class PersonApiControllerIT extends SingleTenantTestContainersBase {
                                "firstName": "carl",
                                "lastName": "carl",
                                "niceName": "carl carl",
+                               "active": true,
                                "_links": {
                                  "self": {
                                    "href": "http://localhost/api/persons/2"
@@ -250,6 +254,7 @@ class PersonApiControllerIT extends SingleTenantTestContainersBase {
                           "firstName": "shane",
                           "lastName": "last",
                           "niceName": "shane last",
+                          "active": true,
                           "_links":{
                             "self":{
                               "href":"http://localhost/api/persons/1"
diff --git a/src/test/java/org/synyx/urlaubsverwaltung/vacations/VacationApiControllerTest.java b/src/test/java/org/synyx/urlaubsverwaltung/vacations/VacationApiControllerTest.java
index ee5bbe45c..296b12f36 100644
--- a/src/test/java/org/synyx/urlaubsverwaltung/vacations/VacationApiControllerTest.java
+++ b/src/test/java/org/synyx/urlaubsverwaltung/vacations/VacationApiControllerTest.java
@@ -183,6 +183,7 @@ class VacationApiControllerTest {
                         "firstName": "Marlene",
                         "lastName": "Muster",
                         "niceName": "Marlene Muster",
+                        "active": true,
                         "links": [
                           {
                             "rel": "self",
@@ -220,6 +221,7 @@ class VacationApiControllerTest {
                         "firstName": "Marlene",
                         "lastName": "Muster",
                         "niceName": "Marlene Muster",
+                        "active": true,
                         "links": [
                           {
                             "rel": "self",