<%#
 Copyright 2013-2024 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
package <%= packageName %>.service.dto;

<%_
const manyListName = ormTool !== 'mybatis' ? 'Set' : 'List';
const manyListType = ormTool !== 'mybatis' ? 'LinkedHashSet' : 'ArrayList';
_%>
import <%= packageName %>.config.Constants;
<% if (databaseTypeSql || databaseTypeMongodb || databaseTypeNeo4j) { %>
import <%= packageName %>.domain.Authority;<% } %>
<%_ if (!databaseTypeNo) { _%>
import <%= user.entityAbsoluteClass %>;
<%_ } _%>

import java.io.Serializable;
import <%= javaVersion === '17' ? 'jakarta' : 'javax'%>.validation.constraints.*;
<%_ if (generateSpringAuditor) { _%>
import java.time.Instant;
<%_ } _%>
<%_ if (ormTool === 'mybatis') { _%>
import java.util.ArrayList;
import java.util.List;
<%_ } else { _%>
import java.util.Set;
import java.util.LinkedHashSet;
<%_ } _%>
<%_ if (user.primaryKey.hasUUID) { _%>
import java.util.UUID;
<%_ } _%>
<%_ if (databaseTypeMongodb || databaseTypeNeo4j || databaseTypeSql) { _%>
import java.util.stream.Collectors;
<%_ } _%>

/**
 * A DTO representing a user, with his authorities.
 */
public class <%= user.adminUserDto %> implements Serializable {
    private static final long serialVersionUID = 1L;

    private <%= user.primaryKey.type %> 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;

    private String mobile;

<%_ if (!databaseTypeCassandra) { _%>

    @Size(max = 256)
    private String imageUrl;
<%_ } _%>

    private Boolean activated = false;

    @Size(min = 2, max = 10)
    private String langKey;
<%_ if (generateSpringAuditor) { _%>

    private <%= userIdTypeName %> createdBy;

    private Instant createdDate;

    private <%= userIdTypeName %> lastModifiedBy;

    private Instant lastModifiedDate;
<%_ } _%>

    private <%= manyListName%><AuthorityDTO> authorities = new <%= manyListType%><>();

    private DepartmentDTO department;

    private PositionDTO position;

<%_ if (!databaseTypeNo && false) { _%>
    public <%= user.adminUserDto %>() {
        // Empty constructor needed for Jackson.
    }

    public <%= user.adminUserDto %>(<%= user.persistClass %> 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();
  <%_ if (!databaseTypeCassandra) { _%>
        this.imageUrl = user.getImageUrl();
  <%_ } _%>
        this.langKey = user.getLangKey();
  <%_ if (generateSpringAuditor) { _%>
        this.createdBy = user.getCreatedBy();
        this.createdDate = user.getCreatedDate();
        this.lastModifiedBy = user.getLastModifiedBy();
        this.lastModifiedDate = user.getLastModifiedDate();
  <%_ } _%>
  <%_ if (databaseTypeMongodb || databaseTypeNeo4j || databaseTypeSql) { _%>
        this.authorities = user.getAuthorities().stream()
            .map(Authority::getName)
            .collect(Collectors.toSet());
  <%_ } else { _%>
        this.authorities = user.getAuthorities();
  <%_ } _%>
    }

<%_ } _%>
    public <%= user.primaryKey.type %> getId() {
        return id;
    }

    public void setId(<%= user.primaryKey.type %> 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 getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
<%_ if (!databaseTypeCassandra) { _%>

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }
<%_ } _%>

    public Boolean getActivated() {
        return activated;
    }

    public void setActivated(Boolean activated) {
        this.activated = activated;
    }

    public String getLangKey() {
        return langKey;
    }

    public void setLangKey(String langKey) {
        this.langKey = langKey;
    }
<%_ if (generateSpringAuditor) { _%>

    public <%= userIdTypeName %> getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(<%= userIdTypeName %> createdBy) {
        this.createdBy = createdBy;
    }

    public Instant getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Instant createdDate) {
        this.createdDate = createdDate;
    }

    public <%= userIdTypeName %> getLastModifiedBy() {
        return lastModifiedBy;
    }

    public void setLastModifiedBy(<%= userIdTypeName %> lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
    }

    public Instant getLastModifiedDate() {
        return lastModifiedDate;
    }

    public void setLastModifiedDate(Instant lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }
<%_ } _%>

    public <%= manyListName%><AuthorityDTO> getAuthorities() {
        return authorities;
    }

    public void setAuthorities(<%= manyListName%><AuthorityDTO> authorities) {
        this.authorities = authorities;
    }

    public DepartmentDTO getDepartment() {
        return department;
    }

    public void setDepartment(DepartmentDTO department) {
        this.department = department;
    }

    public PositionDTO getPosition() {
        return position;
    }

    public void setPosition(PositionDTO position) {
        this.position = position;
    }

    // prettier-ignore
    @Override
    public String toString() {
        return "<%= user.adminUserDto %>{" +
            "login='" + login + '\'' +
            ", firstName='" + firstName + '\'' +
            ", lastName='" + lastName + '\'' +
            ", email='" + email + '\'' +<% if (!databaseTypeCassandra) { %>
            ", imageUrl='" + imageUrl + '\'' +<% } %>
            ", activated=" + activated +
            ", langKey='" + langKey + '\'' +<% if (databaseTypeMongodb || databaseTypeCouchbase || databaseTypeSql) { %>
            ", createdBy=" + createdBy +
            ", createdDate=" + createdDate +
            ", lastModifiedBy='" + lastModifiedBy + '\'' +
            ", lastModifiedDate=" + lastModifiedDate +<% } %>
            ", authorities=" + authorities +
            ", department=" + department +
            ", position=" + position +
            "}";
    }
}
