// Path: src/main/java/com/jipasoft/domain/Authority.java
// @Data
// @Entity
// @Document(collection = "role")
// @NoArgsConstructor
// @AllArgsConstructor
// @Table(name = "role")
// public class Authority implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Id
// 	@NotNull
// 	@org.springframework.data.annotation.Id
// 	@Size(min = 1, max = 50)
// 	private String name;
// 
// }
// 
// Path: src/main/java/com/jipasoft/domain/User.java
// @Data
// @Entity
// @Document(collection = "account")
// @Table(name = "account")
// @ToString(exclude = { "password", "authorities" })
// @EqualsAndHashCode(callSuper = true)
// public class User extends AbstractAuditEntity implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Id
// 	@org.springframework.data.annotation.Id
// 	@GeneratedValue(generator = "uuid2")
// 	@GenericGenerator(name = "uuid2", strategy = "uuid2")
// 	private String id;
// 
// 	@NotNull
// 	@Pattern(regexp = "^[a-z0-9]*$|(anonymousUser)")
// 	@Size(min = 1, max = 100)
// 	@Column(unique = true)
// 	private String login;
// 
// 	@NotNull
// 	@Size(min = 60, max = 60)
// 	@Column(name = "password_hash")
// 	@JsonIgnore
// 	private String password;
// 
// 	@Size(max = 50)
// 	@Field("first_name")
// 	private String firstName;
// 
// 	@Size(max = 50)
// 	@Field("last_name")
// 	private String lastName;
// 
// 	@NotNull
// 	@Size(min = 1, max = 100)
// 	@Column(unique = true)
// 	private String email;
// 
// 	@NotNull
// 	private boolean activated = false;
// 
// 	@Size(max = 20)
// 	@Field("activation_key")
// 	@JsonIgnore
// 	private String activationKey;
// 
// 	@Size(max = 20)
// 	@Field("reset_key")
// 	@JsonIgnore
// 	private String resetKey;
// 
// 	@Field("reset_date")
// 	private ZonedDateTime resetDate = null;
// 
// 	@ManyToMany
// 	//@formatter:off
// 	@JoinTable(name = "user_role", inverseJoinColumns = {
// 			@JoinColumn(name = "role_name")
// 		}, joinColumns = {
// 			@JoinColumn(name = "account_id")
// 		}
// 	)
// 	//@formatter:on
// 	private Set<Authority> authorities;
// }


import java.time.ZonedDateTime;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.springframework.security.crypto.password.PasswordEncoder;
import com.jipasoft.domain.Authority;
import com.jipasoft.domain.User;
import lombok.Data;
	private String firstName;

	@NotNull
	@Size(min = 1, max = 50)
	private String lastName;

	@Email
	@NotNull
	@Size(min = 1, max = 100)
	private String email;

	@NotNull
	private boolean activated = false;

	@NotNull
	private String createdBy = "system";

	@NotNull
	private ZonedDateTime createdDate = ZonedDateTime.now();

	public User createUser(PasswordEncoder encoder) {
		User user = new User();
		user.setLogin(login);
		user.setPassword(encoder.encode(password));
		user.setFirstName(firstName);
		user.setLastName(lastName);
		user.setEmail(email);
		user.setActivated(activated);
		user.setCreatedBy(createdBy);
		user.setCreatedDate(createdDate);
// Path: src/main/java/com/jipasoft/domain/Authority.java
// @Data
// @Entity
// @Document(collection = "role")
// @NoArgsConstructor
// @AllArgsConstructor
// @Table(name = "role")
// public class Authority implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Id
// 	@NotNull
// 	@org.springframework.data.annotation.Id
// 	@Size(min = 1, max = 50)
// 	private String name;
// 
// }
// 
// Path: src/main/java/com/jipasoft/domain/User.java
// @Data
// @Entity
// @Document(collection = "account")
// @Table(name = "account")
// @ToString(exclude = { "password", "authorities" })
// @EqualsAndHashCode(callSuper = true)
// public class User extends AbstractAuditEntity implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Id
// 	@org.springframework.data.annotation.Id
// 	@GeneratedValue(generator = "uuid2")
// 	@GenericGenerator(name = "uuid2", strategy = "uuid2")
// 	private String id;
// 
// 	@NotNull
// 	@Pattern(regexp = "^[a-z0-9]*$|(anonymousUser)")
// 	@Size(min = 1, max = 100)
// 	@Column(unique = true)
// 	private String login;
// 
// 	@NotNull
// 	@Size(min = 60, max = 60)
// 	@Column(name = "password_hash")
// 	@JsonIgnore
// 	private String password;
// 
// 	@Size(max = 50)
// 	@Field("first_name")
// 	private String firstName;
// 
// 	@Size(max = 50)
// 	@Field("last_name")
// 	private String lastName;
// 
// 	@NotNull
// 	@Size(min = 1, max = 100)
// 	@Column(unique = true)
// 	private String email;
// 
// 	@NotNull
// 	private boolean activated = false;
// 
// 	@Size(max = 20)
// 	@Field("activation_key")
// 	@JsonIgnore
// 	private String activationKey;
// 
// 	@Size(max = 20)
// 	@Field("reset_key")
// 	@JsonIgnore
// 	private String resetKey;
// 
// 	@Field("reset_date")
// 	private ZonedDateTime resetDate = null;
// 
// 	@ManyToMany
// 	//@formatter:off
// 	@JoinTable(name = "user_role", inverseJoinColumns = {
// 			@JoinColumn(name = "role_name")
// 		}, joinColumns = {
// 			@JoinColumn(name = "account_id")
// 		}
// 	)
// 	//@formatter:on
// 	private Set<Authority> authorities;
// }


// Path: src/main/java/com/jipasoft/domain/dto/UserDTO.java
import java.time.ZonedDateTime;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.springframework.security.crypto.password.PasswordEncoder;
import com.jipasoft.domain.Authority;
import com.jipasoft.domain.User;
import lombok.Data;

	private String firstName;

	@NotNull
	@Size(min = 1, max = 50)
	private String lastName;

	@Email
	@NotNull
	@Size(min = 1, max = 100)
	private String email;

	@NotNull
	private boolean activated = false;

	@NotNull
	private String createdBy = "system";

	@NotNull
	private ZonedDateTime createdDate = ZonedDateTime.now();

	public User createUser(PasswordEncoder encoder) {
		User user = new User();
		user.setLogin(login);
		user.setPassword(encoder.encode(password));
		user.setFirstName(firstName);
		user.setLastName(lastName);
		user.setEmail(email);
		user.setActivated(activated);
		user.setCreatedBy(createdBy);
		user.setCreatedDate(createdDate);
		user.setAuthorities(Stream.of(new Authority("ROLE_USER")).collect(Collectors.toSet()));