// Path: src/main/java/com/lyubenblagoev/postfixrest/entity/Account.java
// @Entity
// @Table(name = "accounts")
// public class Account extends BaseEntity {
// 	
// 	@ManyToOne(fetch = FetchType.LAZY)
// 	@JoinColumn(name = "domain_id")
// 	private Domain domain;
// 
// 	private String username;
// 	private String password;
// 	
// 	public Domain getDomain() {
// 		return domain;
// 	}
// 
// 	public void setDomain(Domain domain) {
// 		this.domain = domain;
// 	}
// 
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	public void setUsername(String email) {
// 		this.username = email;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// }
// 
// Path: src/main/java/com/lyubenblagoev/postfixrest/entity/Domain.java
// @Entity
// @Table(name="domains")
// public class Domain extends BaseEntity {
// 
// 	@Column(nullable = false)
// 	private String name;
// 
// 	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "domain")
// 	private List<Account> accounts = Collections.emptyList();
// 
// 	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "domain")
// 	private List<Alias> aliases = Collections.emptyList();
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public List<Account> getAccounts() {
// 		return accounts;
// 	}
// 
// 	public void setAccounts(List<Account> accounts) {
// 		this.accounts = accounts;
// 	}
// 
// 	public List<Alias> getAliases() {
// 		return aliases;
// 	}
// 
// 	public void setAliases(List<Alias> aliases) {
// 		this.aliases = aliases;
// 	}
// }


import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.lyubenblagoev.postfixrest.entity.Account;
import com.lyubenblagoev.postfixrest.entity.Domain;
package com.lyubenblagoev.postfixrest.service.model;



public class AccountResource {

	private Long id;
	
	private String username;
	
	private String domain;
	
	private Long domainId;
	
	@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ssZ")
	private Date created;
	
	@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ssZ")
	private Date updated;
	
	private boolean enabled;
	
	public static AccountResource fromAccount(Account account) {
		AccountResource resource = new AccountResource();
		resource.setId(account.getId());
		resource.setUsername(account.getUsername());
		resource.setDomain(account.getDomain().getName());
		resource.setDomainId(account.getDomain().getId());
		resource.setEnabled(account.isEnabled());
		resource.setCreated(account.getCreated());
		resource.setUpdated(account.getUpdated());
		return resource;
	}
	
// Path: src/main/java/com/lyubenblagoev/postfixrest/entity/Account.java
// @Entity
// @Table(name = "accounts")
// public class Account extends BaseEntity {
// 	
// 	@ManyToOne(fetch = FetchType.LAZY)
// 	@JoinColumn(name = "domain_id")
// 	private Domain domain;
// 
// 	private String username;
// 	private String password;
// 	
// 	public Domain getDomain() {
// 		return domain;
// 	}
// 
// 	public void setDomain(Domain domain) {
// 		this.domain = domain;
// 	}
// 
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	public void setUsername(String email) {
// 		this.username = email;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// }
// 
// Path: src/main/java/com/lyubenblagoev/postfixrest/entity/Domain.java
// @Entity
// @Table(name="domains")
// public class Domain extends BaseEntity {
// 
// 	@Column(nullable = false)
// 	private String name;
// 
// 	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "domain")
// 	private List<Account> accounts = Collections.emptyList();
// 
// 	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "domain")
// 	private List<Alias> aliases = Collections.emptyList();
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public List<Account> getAccounts() {
// 		return accounts;
// 	}
// 
// 	public void setAccounts(List<Account> accounts) {
// 		this.accounts = accounts;
// 	}
// 
// 	public List<Alias> getAliases() {
// 		return aliases;
// 	}
// 
// 	public void setAliases(List<Alias> aliases) {
// 		this.aliases = aliases;
// 	}
// }


// Path: src/main/java/com/lyubenblagoev/postfixrest/service/model/AccountResource.java
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.lyubenblagoev.postfixrest.entity.Account;
import com.lyubenblagoev.postfixrest.entity.Domain;

package com.lyubenblagoev.postfixrest.service.model;



public class AccountResource {

	private Long id;
	
	private String username;
	
	private String domain;
	
	private Long domainId;
	
	@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ssZ")
	private Date created;
	
	@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ssZ")
	private Date updated;
	
	private boolean enabled;
	
	public static AccountResource fromAccount(Account account) {
		AccountResource resource = new AccountResource();
		resource.setId(account.getId());
		resource.setUsername(account.getUsername());
		resource.setDomain(account.getDomain().getName());
		resource.setDomainId(account.getDomain().getId());
		resource.setEnabled(account.isEnabled());
		resource.setCreated(account.getCreated());
		resource.setUpdated(account.getUpdated());
		return resource;
	}
	
	public static Account toAccount(AccountResource account, Domain domain) {