From 69b4db4ce7838ef822f97f01cd1295c852466e1c Mon Sep 17 00:00:00 2001 From: Daniil Palagin Date: Wed, 25 Sep 2024 14:51:44 +0200 Subject: [PATCH] [kbss-cvut/record-manager-ui#202] Remove types from the user --- .../java/cz/cvut/kbss/study/model/User.java | 24 +------------------ .../repository/RepositoryUserService.java | 2 +- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/main/java/cz/cvut/kbss/study/model/User.java b/src/main/java/cz/cvut/kbss/study/model/User.java index 99b0ad67..498c8c28 100644 --- a/src/main/java/cz/cvut/kbss/study/model/User.java +++ b/src/main/java/cz/cvut/kbss/study/model/User.java @@ -1,27 +1,22 @@ package cz.cvut.kbss.study.model; import com.fasterxml.jackson.annotation.JsonProperty; -import cz.cvut.kbss.jopa.model.annotations.CascadeType; import cz.cvut.kbss.jopa.model.annotations.FetchType; import cz.cvut.kbss.jopa.model.annotations.Id; import cz.cvut.kbss.jopa.model.annotations.OWLClass; import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty; import cz.cvut.kbss.jopa.model.annotations.OWLObjectProperty; import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints; -import cz.cvut.kbss.jopa.model.annotations.Types; import cz.cvut.kbss.study.model.util.HasDerivableUri; import cz.cvut.kbss.study.util.Constants; import cz.cvut.kbss.study.util.IdentificationUtils; import org.springframework.security.crypto.password.PasswordEncoder; - import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Date; -import java.util.HashSet; -import java.util.Set; @OWLClass(iri = Vocabulary.s_c_Person) public class User implements HasDerivableUri, Serializable { @@ -65,12 +60,8 @@ public class User implements HasDerivableUri, Serializable { @OWLObjectProperty(iri = Vocabulary.s_p_has_role_group) private RoleGroup roleGroup; - @Types - private Set types; - public User() { - this.types = new HashSet<>(); - types.add(Vocabulary.s_c_doctor_role_group); + } @Override @@ -149,19 +140,6 @@ public void setRoleGroup(RoleGroup roleGroup) { this.roleGroup = roleGroup; } - public Set getTypes() { - return types; - } - - public void setTypes(Set types) { - this.types = types; - } - - public void addType(String type) { - assert types != null; - getTypes().add(type); - } - /** * Returns true if this user is an admin. *

diff --git a/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryUserService.java b/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryUserService.java index d402df8b..be04c2b2 100644 --- a/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryUserService.java +++ b/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryUserService.java @@ -203,7 +203,7 @@ protected void prePersist(User instance) { protected void preUpdate(User instance) { final User currentUser = securityUtils.getCurrentUser(); if (!currentUser.isAdmin() - && (!instance.getTypes().equals(currentUser.getTypes()) || (instance.getInstitution() != null + && (!instance.getRoleGroup().getRoles().equals(currentUser.getRoleGroup().getRoles()) || (instance.getInstitution() != null && !instance.getInstitution().getKey().equals(currentUser.getInstitution().getKey())))) { throw new UnauthorizedException("Cannot update user."); }