Skip to content

Commit c2bfac2

Browse files
committed
Fixes #558
1 parent f00b829 commit c2bfac2

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

server/src/main/java/invite/api/RoleController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,13 @@ private List<Role> roleFromQuery(Page<Map<String, Object>> rolesPage, List<Map<S
253253
(Long) m.get("id"),
254254
(String) m.get("name"),
255255
(String) m.get("description"),
256-
(Long) m.get("userRoleCount")
256+
(Long) m.get("userRoleCount"),
257+
(Integer) m.get("defaultExpiryDays"),
258+
(boolean) m.get("enforceEmailEquality"),
259+
(boolean) m.get("eduIDOnly"),
260+
(boolean) m.get("overrideSettingsAllowed")
257261
)).toList();
262+
258263
//Now add all applications, note that we need to preserve ordering of the roles
259264
Map<Long, List<Map<String, Object>>> applicationGroupedByRoleId =
260265
applications.stream().collect(Collectors.groupingBy(m -> (Long) m.get("role_id")));

server/src/main/java/invite/model/Role.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package invite.model;
22

3-
import invite.provision.scim.GroupURN;
43
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import invite.provision.scim.GroupURN;
55
import jakarta.persistence.*;
66
import jakarta.validation.constraints.NotBlank;
77
import jakarta.validation.constraints.NotNull;
@@ -87,12 +87,22 @@ public class Role implements Serializable, Provisionable {
8787
public Role(Long id,
8888
String name,
8989
String description,
90-
Long userRoleCount) {
90+
Long userRoleCount,
91+
Integer defaultExpiryDays,
92+
boolean enforceEmailEquality,
93+
boolean eduIDOnly,
94+
boolean overrideSettingsAllowed
95+
) {
9196
//Only used after native query and returned for Role overview in the GUI
9297
this.id = id;
9398
this.name = name;
9499
this.description = description;
95100
this.userRoleCount = userRoleCount;
101+
this.defaultExpiryDays = defaultExpiryDays;
102+
this.enforceEmailEquality = enforceEmailEquality;
103+
this.eduIDOnly = eduIDOnly;
104+
this.overrideSettingsAllowed = overrideSettingsAllowed;
105+
96106
}
97107

98108
public Role(String name,

server/src/main/java/invite/repository/RoleRepository.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public interface RoleRepository extends JpaRepository<Role, Long>, QueryRewriter
2323

2424
@Query(value = """
2525
SELECT r.id as id, r.name as name, r.description as description,
26+
r.default_expiry_days as defaultExpiryDays,
27+
r.enforce_email_equality as enforceEmailEquality,
28+
r.edu_id_only as eduIDOnly,
29+
r.override_settings_allowed as overrideSettingsAllowed,
2630
(SELECT COUNT(*) FROM user_roles ur WHERE ur.role_id=r.id) as userRoleCount
2731
FROM roles r
2832
""",
@@ -35,6 +39,10 @@ SELECT COUNT(r.id) FROM roles r
3539

3640
@Query(value = """
3741
SELECT r.id as id, r.name as name, r.description as description,
42+
r.default_expiry_days as defaultExpiryDays,
43+
r.enforce_email_equality as enforceEmailEquality,
44+
r.edu_id_only as eduIDOnly,
45+
r.override_settings_allowed as overrideSettingsAllowed,
3846
(SELECT COUNT(*) FROM user_roles ur WHERE ur.role_id=r.id) as userRoleCount
3947
FROM roles r WHERE MATCH (name, description) against (?1 IN BOOLEAN MODE)
4048
""",
@@ -48,6 +56,10 @@ SELECT COUNT(r.id) FROM roles r WHERE MATCH (name, description) against (?1 IN B
4856

4957
@Query(value = """
5058
SELECT r.id AS id, r.name AS name, r.description AS description,
59+
r.default_expiry_days as defaultExpiryDays,
60+
r.enforce_email_equality as enforceEmailEquality,
61+
r.edu_id_only as eduIDOnly,
62+
r.override_settings_allowed as overrideSettingsAllowed,
5163
(SELECT COUNT(*) FROM user_roles ur WHERE ur.role_id=r.id) AS userRoleCount
5264
FROM roles r WHERE r.organization_guid = ?1
5365
""",

0 commit comments

Comments
 (0)