| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- package rocks.zipcode.io.service.dto;
-
- import rocks.zipcode.io.config.Constants;
-
- import rocks.zipcode.io.domain.Authority;
- import rocks.zipcode.io.domain.User;
-
- import javax.validation.constraints.Email;
- import javax.validation.constraints.NotBlank;
-
- import javax.validation.constraints.*;
- import java.time.Instant;
- import java.util.Set;
- import java.util.stream.Collectors;
-
- /**
- * A DTO representing a user, with his authorities.
- */
- public class UserDTO {
-
- private Long id;
-
- @NotBlank
- @Pattern(regexp = Constants.LOGIN_REGEX)
- @Size(min = 1, max = 50)
- private String login;
-
- @Size(max = 50)
- private String firstName;
-
- @Size(max = 50)
- private String lastName;
-
- @Email
- @Size(min = 5, max = 254)
- private String email;
-
- @Size(max = 256)
- private String imageUrl;
-
- private boolean activated = false;
-
- @Size(min = 2, max = 6)
- private String langKey;
-
- private String createdBy;
-
- private Instant createdDate;
-
- private String lastModifiedBy;
-
- private Instant lastModifiedDate;
-
- private Set<String> authorities;
-
- public UserDTO() {
- // Empty constructor needed for Jackson.
- }
-
- public UserDTO(User user) {
- this.id = user.getId();
- this.login = user.getLogin();
- this.firstName = user.getFirstName();
- this.lastName = user.getLastName();
- this.email = user.getEmail();
- this.activated = user.getActivated();
- this.imageUrl = user.getImageUrl();
- this.langKey = user.getLangKey();
- this.createdBy = user.getCreatedBy();
- this.createdDate = user.getCreatedDate();
- this.lastModifiedBy = user.getLastModifiedBy();
- this.lastModifiedDate = user.getLastModifiedDate();
- this.authorities = user.getAuthorities().stream()
- .map(Authority::getName)
- .collect(Collectors.toSet());
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getLogin() {
- return login;
- }
-
- public void setLogin(String login) {
- this.login = login;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getImageUrl() {
- return imageUrl;
- }
-
- public void setImageUrl(String imageUrl) {
- this.imageUrl = imageUrl;
- }
-
- public boolean isActivated() {
- return activated;
- }
-
- public void setActivated(boolean activated) {
- this.activated = activated;
- }
-
- public String getLangKey() {
- return langKey;
- }
-
- public void setLangKey(String langKey) {
- this.langKey = langKey;
- }
-
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public Instant getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Instant createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getLastModifiedBy() {
- return lastModifiedBy;
- }
-
- public void setLastModifiedBy(String lastModifiedBy) {
- this.lastModifiedBy = lastModifiedBy;
- }
-
- public Instant getLastModifiedDate() {
- return lastModifiedDate;
- }
-
- public void setLastModifiedDate(Instant lastModifiedDate) {
- this.lastModifiedDate = lastModifiedDate;
- }
-
- public Set<String> getAuthorities() {
- return authorities;
- }
-
- public void setAuthorities(Set<String> authorities) {
- this.authorities = authorities;
- }
-
- @Override
- public String toString() {
- return "UserDTO{" +
- "login='" + login + '\'' +
- ", firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", email='" + email + '\'' +
- ", imageUrl='" + imageUrl + '\'' +
- ", activated=" + activated +
- ", langKey='" + langKey + '\'' +
- ", createdBy=" + createdBy +
- ", createdDate=" + createdDate +
- ", lastModifiedBy='" + lastModifiedBy + '\'' +
- ", lastModifiedDate=" + lastModifiedDate +
- ", authorities=" + authorities +
- "}";
- }
- }
|