package com.acme.model.domain.ad.entity;


import com.acme.structure.BaseEntity;
import com.acme.structure.BaseEntityListener;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

@Entity(name = "Contact")
@Table(name = "CONTACTS")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "CONTACTTYPE", discriminatorType = DiscriminatorType.STRING, length = 30)
@DiscriminatorValue("Contact")
//this is for oracle db @SequenceGenerator(name = "CONTACT_SEQ", sequenceName = "CONTACT_SEQ", allocationSize = 1)
@EntityListeners( { BaseEntityListener.class })
public class Contact extends BaseEntity
{
    // 1:telephone, 2:email 3:fax 4:web
    private int type;
    private String value;
    private String contactType;

    public static final int TYPE_TELEPHONE = 0;
    public static final int TYPE_EMAIL = 1;
    public static final int TYPE_FAX = 2;
    public static final int TYPE_WEB = 3;

    public Contact()
    {
        entityName = "Contact";
        setContactType(this.getEntityName());
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO) //, this is for oracle db, generator = "CONTACT_SEQ")
    @Column(name = "ID")
    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    @Column(name = "TYPE")
    public int getType()
    {
        return type;
    }

    public void setType(int type)
    {
        this.type = type;
    }

    @Column(name = "VALUE", length = 50)
    public String getValue()
    {
        return value;
    }

    public void setValue(String value)
    {
        this.value = value;
    }

    public void setContactType(String contactType)
    {
        this.contactType = contactType;
    }

    @Column(name = "CONTACTTYPE")
    public String getContactType()
    {
        return contactType;
    }

    @Override
    public String toString()
    {
        return getValue();
    }
}
