package org.mynonglam.entitys;

import java.io.Serializable;
import java.math.BigInteger;

import javax.persistence.*;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;


/**
 * The persistent class for the account database table.
 * 
 */
@Entity
public class Account implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String email;

	@Lob
	private String aboutus;

	private String avatar;

	private String country;

	private String coverphoto;

	private String dayofbirth;

	private String fullname;

	private boolean gender;

	private boolean isblock;

	private String orthername;

	private String password;

	@Lob
	private String slogan;

	//bi-directional many-to-one association to Album
	@OneToMany(mappedBy="account")
	private List<Album> albums;

	//bi-directional many-to-one association to AnotherAccount
	@OneToMany(mappedBy="account")
	private List<AnotherAccount> anotheraccounts;

	//bi-directional many-to-one association to CommentPhoto
	@OneToMany(mappedBy="account")
	private List<CommentPhoto> commentphotos;

	//bi-directional many-to-one association to CommentStatus
	@OneToMany(mappedBy="account")
	private List<CommentStatus> commentstatuses;

	//bi-directional one-to-one association to Liking
	@OneToOne(mappedBy="account")
	private Liking liking;

	//bi-directional many-to-many association to Group
	@ManyToMany
	@JoinTable(
		name="membergroup"
		, joinColumns={
			@JoinColumn(name="email")
			}
		, inverseJoinColumns={
			@JoinColumn(name="idgroup")
			}
		)
	private List<Group> groups;

	//bi-directional many-to-one association to MessageSend
	@OneToMany(mappedBy="account1")
	private List<MessageSend> messagesends1;

	//bi-directional many-to-one association to MessageSend
	@OneToMany(mappedBy="account2")
	private List<MessageSend> messagesends2;

	//bi-directional many-to-one association to Phone
	@OneToMany(mappedBy="account")
	private List<Phone> phones;

	//bi-directional many-to-one association to Place
	@OneToMany(mappedBy="account")
	private List<Place> places;

	//bi-directional many-to-one association to Professtion
	@OneToMany(mappedBy="account")
	private List<Professtion> professtions;

	//bi-directional many-to-one association to Relationship
	@OneToMany(mappedBy="account1")
	private List<Relationship> relationships1;

	//bi-directional many-to-one association to Relationship
	@OneToMany(mappedBy="account2")
	private List<Relationship> relationships2;

	//bi-directional many-to-one association to Status
	@OneToMany(mappedBy="account")
	private List<Status> statuses;

	//bi-directional many-to-one association to StatusLike
	@OneToMany(mappedBy="account")
	private List<StatusLike> statuslikes;

	public Account() {
	}
	
	public Account(String email, String aboutus, String avatar, String country,
			String coverphoto, String dayofbirth, String fullname, boolean gender,
			boolean isblock, String orthername, String password, String slogan) {
		this.email = email;
		this.aboutus = aboutus;
		this.avatar = avatar;
		this.country = country;
		this.coverphoto = coverphoto;
		this.dayofbirth = dayofbirth;
		this.fullname = fullname;
		this.gender = gender;
		this.isblock = isblock;
		this.orthername = orthername;
		this.password = password;
		this.slogan = slogan;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAboutus() {
		return this.aboutus;
	}

	public void setAboutus(String aboutus) {
		this.aboutus = aboutus;
	}

	public String getAvatar() {
		return this.avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getCoverphoto() {
		return this.coverphoto;
	}

	public void setCoverphoto(String coverphoto) {
		this.coverphoto = coverphoto;
	}

	public String getDayofbirth() {
		return this.dayofbirth;
	}

	public void setDayofbirth(String dayofbirth) {
		this.dayofbirth = dayofbirth;
	}

	public String getFullname() {
		return this.fullname;
	}

	public void setFullname(String fullname) {
		this.fullname = fullname;
	}

	public boolean getGender() {
		return this.gender;
	}

	public void setGender(boolean gender) {
		this.gender = gender;
	}

	public boolean getIsblock() {
		return this.isblock;
	}

	public void setIsblock(boolean isblock) {
		this.isblock = isblock;
	}

	public String getOrthername() {
		return this.orthername;
	}

	public void setOrthername(String orthername) {
		this.orthername = orthername;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSlogan() {
		return this.slogan;
	}

	public void setSlogan(String slogan) {
		this.slogan = slogan;
	}

	public List<Album> getAlbums() {
		return this.albums;
	}

	public void setAlbums(List<Album> albums) {
		this.albums = albums;
	}

	public List<AnotherAccount> getAnotheraccounts() {
		return this.anotheraccounts;
	}

	public void setAnotheraccounts(List<AnotherAccount> anotheraccounts) {
		this.anotheraccounts = anotheraccounts;
	}

	public List<CommentPhoto> getCommentphotos() {
		return this.commentphotos;
	}

	public void setCommentphotos(List<CommentPhoto> commentphotos) {
		this.commentphotos = commentphotos;
	}

	public List<CommentStatus> getCommentstatuses() {
		return this.commentstatuses;
	}

	public void setCommentstatuses(List<CommentStatus> commentstatuses) {
		this.commentstatuses = commentstatuses;
	}

	public Liking getLiking() {
		return this.liking;
	}

	public void setLiking(Liking liking) {
		this.liking = liking;
	}

	public List<Group> getGroups() {
		return this.groups;
	}

	public void setGroups(List<Group> groups) {
		this.groups = groups;
	}

	public List<MessageSend> getMessagesends1() {
		return this.messagesends1;
	}

	public void setMessagesends1(List<MessageSend> messagesends1) {
		this.messagesends1 = messagesends1;
	}

	public List<MessageSend> getMessagesends2() {
		return this.messagesends2;
	}

	public void setMessagesends2(List<MessageSend> messagesends2) {
		this.messagesends2 = messagesends2;
	}

	public List<Phone> getPhones() {
		return this.phones;
	}

	public void setPhones(List<Phone> phones) {
		this.phones = phones;
	}

	public List<Place> getPlaces() {
		return this.places;
	}

	public void setPlaces(List<Place> places) {
		this.places = places;
	}

	public List<Professtion> getProfesstions() {
		return this.professtions;
	}

	public void setProfesstions(List<Professtion> professtions) {
		this.professtions = professtions;
	}

	public List<Relationship> getRelationships1() {
		return this.relationships1;
	}

	public void setRelationships1(List<Relationship> relationships1) {
		this.relationships1 = relationships1;
	}

	public List<Relationship> getRelationships2() {
		return this.relationships2;
	}

	public void setRelationships2(List<Relationship> relationships2) {
		this.relationships2 = relationships2;
	}

	public List<Status> getStatuses() {
		return this.statuses;
	}

	public void setStatuses(List<Status> statuses) {
		this.statuses = statuses;
	}

	public List<StatusLike> getStatuslikes() {
		return this.statuslikes;
	}

	public void setStatuslikes(List<StatusLike> statuslikes) {
		this.statuslikes = statuslikes;
	}
	
	public static String md5(String str) {
		String text = "";
		try {
			MessageDigest md5 = MessageDigest.getInstance("MD5");
			md5.update(str.getBytes());
			BigInteger dis = new BigInteger(1, md5.digest());
			text = dis.toString(16);
		} catch (NoSuchAlgorithmException e) {
			System.out.print("Loi khong ma hoa duoc bang giai thuat MD5\n"
					+ e.getMessage());
		}

		return text;
	}

}