TSK-1957: exposed domain attribute via REST
This commit is contained in:
parent
80fdb4c85d
commit
45417f887d
|
@ -206,8 +206,9 @@ public interface User {
|
|||
/**
|
||||
* Returns the domains of the User.
|
||||
*
|
||||
* <p>The domains are derived from the workbasket permissions and the according Taskana property
|
||||
* {@linkplain TaskanaEngineConfiguration#getMinimalPermissionsToAssignDomains()}.
|
||||
* <p>The domains are derived from the {@linkplain pro.taskana.workbasket.api.WorkbasketPermission
|
||||
* WorkbasketPermissions} and the according TASKANA property {@linkplain
|
||||
* TaskanaEngineConfiguration#getMinimalPermissionsToAssignDomains()}.
|
||||
*
|
||||
* @return domains
|
||||
*/
|
||||
|
|
|
@ -32,6 +32,7 @@ public class UserRepresentationModelAssembler
|
|||
repModel.setOrgLevel2(entity.getOrgLevel2());
|
||||
repModel.setOrgLevel1(entity.getOrgLevel1());
|
||||
repModel.setData(entity.getData());
|
||||
repModel.setDomains(entity.getDomains());
|
||||
|
||||
return repModel;
|
||||
}
|
||||
|
@ -52,6 +53,7 @@ public class UserRepresentationModelAssembler
|
|||
user.setOrgLevel2(repModel.getOrgLevel2());
|
||||
user.setOrgLevel1(repModel.getOrgLevel1());
|
||||
user.setData(repModel.getData());
|
||||
user.setDomains(repModel.getDomains());
|
||||
|
||||
return user;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.user.rest.models;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
@ -11,33 +12,40 @@ import pro.taskana.user.api.models.User;
|
|||
public class UserRepresentationModel extends RepresentationModel<UserRepresentationModel> {
|
||||
|
||||
/** Unique Id. */
|
||||
@NotNull protected String userId;
|
||||
@NotNull private String userId;
|
||||
/** The groups of the User. */
|
||||
protected Set<String> groups;
|
||||
private Set<String> groups;
|
||||
/**
|
||||
* The domains of the User.
|
||||
*
|
||||
* <p>The domains are derived from the WorkbasketPermissions and the according TASKANA property
|
||||
* taskana.user.minimalPermissionsToAssignDomains
|
||||
*/
|
||||
private Set<String> domains = Collections.emptySet();
|
||||
/** The first name of the User. */
|
||||
protected String firstName;
|
||||
private String firstName;
|
||||
/** The last name of the User. */
|
||||
protected String lastName;
|
||||
private String lastName;
|
||||
/** The full name of the User. */
|
||||
protected String fullName;
|
||||
private String fullName;
|
||||
/** The long name of the User. */
|
||||
protected String longName;
|
||||
private String longName;
|
||||
/** The email of the User. */
|
||||
protected String email;
|
||||
private String email;
|
||||
/** The phone number of the User. */
|
||||
protected String phone;
|
||||
private String phone;
|
||||
/** The mobile phone number of the User. */
|
||||
protected String mobilePhone;
|
||||
private String mobilePhone;
|
||||
/** The fourth organisation level of the User. */
|
||||
protected String orgLevel4;
|
||||
private String orgLevel4;
|
||||
/** The third organisation level of the User. */
|
||||
protected String orgLevel3;
|
||||
private String orgLevel3;
|
||||
/** The second organisation level of the User. */
|
||||
protected String orgLevel2;
|
||||
private String orgLevel2;
|
||||
/** The first organisation level of the User. */
|
||||
protected String orgLevel1;
|
||||
private String orgLevel1;
|
||||
/** The data of the User. This field is used for additional information about the User. */
|
||||
protected String data;
|
||||
private String data;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
|
@ -151,12 +159,21 @@ public class UserRepresentationModel extends RepresentationModel<UserRepresentat
|
|||
this.data = data;
|
||||
}
|
||||
|
||||
public Set<String> getDomains() {
|
||||
return domains;
|
||||
}
|
||||
|
||||
public void setDomains(Set<String> domains) {
|
||||
this.domains = domains;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(
|
||||
super.hashCode(),
|
||||
userId,
|
||||
groups,
|
||||
domains,
|
||||
firstName,
|
||||
lastName,
|
||||
fullName,
|
||||
|
@ -176,18 +193,16 @@ public class UserRepresentationModel extends RepresentationModel<UserRepresentat
|
|||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
if (!(obj instanceof UserRepresentationModel)) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
UserRepresentationModel other = (UserRepresentationModel) obj;
|
||||
return userId.equals(other.userId)
|
||||
return Objects.equals(userId, other.userId)
|
||||
&& Objects.equals(groups, other.groups)
|
||||
&& Objects.equals(domains, other.domains)
|
||||
&& Objects.equals(firstName, other.firstName)
|
||||
&& Objects.equals(lastName, other.lastName)
|
||||
&& Objects.equals(fullName, other.fullName)
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import pro.taskana.common.test.rest.TaskanaSpringBootTest;
|
||||
import pro.taskana.user.api.UserService;
|
||||
import pro.taskana.user.api.models.User;
|
||||
import pro.taskana.user.internal.models.UserImpl;
|
||||
import pro.taskana.user.rest.models.UserRepresentationModel;
|
||||
|
||||
/** Test for {@linkplain UserRepresentationModelAssembler}. */
|
||||
|
@ -26,7 +27,7 @@ class UserRepresentationModelAssemblerTest {
|
|||
|
||||
@Test
|
||||
void should_ReturnRepresentationModel_When_ConvertingUserEntityToRepresentationModel() {
|
||||
User user = userService.newUser();
|
||||
UserImpl user = (UserImpl) userService.newUser();
|
||||
user.setId("user-1-2");
|
||||
user.setGroups(Set.of("group1", "group2"));
|
||||
user.setFirstName("Hans");
|
||||
|
@ -41,6 +42,7 @@ class UserRepresentationModelAssemblerTest {
|
|||
user.setOrgLevel2("Human Workflow");
|
||||
user.setOrgLevel1("TASKANA");
|
||||
user.setData("xy");
|
||||
user.setDomains(Set.of("DOMAIN_A", "DOMAIN_B"));
|
||||
|
||||
UserRepresentationModel repModel = assembler.toModel(user);
|
||||
testEquality(user, repModel);
|
||||
|
@ -63,6 +65,7 @@ class UserRepresentationModelAssemblerTest {
|
|||
repModel.setOrgLevel2("Human Workflow");
|
||||
repModel.setOrgLevel1("TASKANA");
|
||||
repModel.setData("xy");
|
||||
repModel.setDomains(Set.of("DOMAIN_A", "DOMAIN_B"));
|
||||
|
||||
User user = assembler.toEntityModel(repModel);
|
||||
testEquality(user, repModel);
|
||||
|
@ -70,7 +73,7 @@ class UserRepresentationModelAssemblerTest {
|
|||
|
||||
@Test
|
||||
void should_BeEqual_When_ConvertingEntityToRepModelAndBackToEntity() {
|
||||
User user = userService.newUser();
|
||||
UserImpl user = (UserImpl) userService.newUser();
|
||||
user.setId("user-1-2");
|
||||
user.setGroups(Set.of("group1", "group2"));
|
||||
user.setFirstName("Hans");
|
||||
|
@ -85,6 +88,7 @@ class UserRepresentationModelAssemblerTest {
|
|||
user.setOrgLevel2("Human Workflow");
|
||||
user.setOrgLevel1("TASKANA");
|
||||
user.setData("xy");
|
||||
user.setDomains(Set.of("DOMAIN_A", "DOMAIN_B"));
|
||||
|
||||
UserRepresentationModel repModel = assembler.toModel(user);
|
||||
User userAfterConversion = assembler.toEntityModel(repModel);
|
||||
|
@ -113,5 +117,6 @@ class UserRepresentationModelAssemblerTest {
|
|||
assertThat(entity.getOrgLevel2()).isEqualTo(repModel.getOrgLevel2());
|
||||
assertThat(entity.getOrgLevel1()).isEqualTo(repModel.getOrgLevel1());
|
||||
assertThat(entity.getData()).isEqualTo(repModel.getData());
|
||||
assertThat(entity.getDomains()).isEqualTo(repModel.getDomains());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue