package org.csiro.igsn.entity.postgres2_0;

// Generated 27/10/2015 10:58:13 AM by Hibernate Tools 4.3.1

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.vividsolutions.jts.geom.Geometry;


/**
 * Sample generated by hbm2java
 */
@Entity
@Table(name = "sample")
@NamedQueries({
	@NamedQuery(
			name="Sample.search",
		    query="SELECT s FROM Sample s where s.igsn = :igsn"
	),
	@NamedQuery(
			name="Sample.searchpublic",
		    query="SELECT s FROM Sample s where s.ispublic = true and s.igsn = :igsn"
	)
})	
public class Sample implements java.io.Serializable {

	private int sampleid;
	private CvSamplingmethod cvSamplingmethod;
	private Registrant registrant;
	private Status statusByPhysicalsamplestatus;
	private Status statusByRegistrationstatus;
	private String samplename;
	private String othername;
	private String igsn;
	private String landingpage;
	private String classification;
	private String classificationidentifier;
	private String purpose;
	private Geometry samplinglocgeom;
	private String samplinglocsrs;
	private String elevation;
	private String verticaldatum;
	private String locality;
	private Date samplingstart;
	private Date samplingend;
	private String samplingcampaign;
	private String comment;	
	private Date created;
	private Date modified;
	private Boolean ispublic;
	private String elevationUnits;
	private String samplinglocNilreason;
	private String samplingtimeNilreason;
	
	private Set<CvSampletype> cvSampletypes = new HashSet<CvSampletype>(0);
	private Set<Samplecuration> samplecurations = new HashSet<Samplecuration>(0);
	private Set<Samplingfeatures> samplingfeatures = new HashSet<Samplingfeatures>(
			0);
	private Set<SampleCollector> sampleCollectors = new HashSet<SampleCollector>(
			0);
	private Set<Sampleresources> sampleresourceses = new HashSet<Sampleresources>(
			0);
	private Set<CvSamplematerial> cvSamplematerials = new HashSet<CvSamplematerial>(
			0);

	public Sample() {
	}

	public Sample(Registrant registrant, String samplename, String igsn,
			String landingpage, Date created) {
		this.registrant = registrant;
		this.samplename = samplename;
		this.igsn = igsn;
		this.landingpage = landingpage;		
		this.created = created;
	}

	public Sample(CvSamplingmethod cvSamplingmethod, Registrant registrant,
			Status statusByPhysicalsamplestatus,
			Status statusByRegistrationstatus, String samplename,
			String othername, String igsn, String landingpage,
			String classification, String classificationidentifier,
			String purpose, Geometry samplinglocgeom,
			String samplinglocsrs, String elevation, String verticaldatum,
			String locality, Date samplingstart, Date samplingend,
			String samplingcampaign, String comment,
			Date created, Date modified, Boolean ispublic,
			Set<CvSampletype> cvSampletypes,
			Set<Samplecuration> samplecurations,
			Set<Samplingfeatures> samplingfeatures,
			Set<SampleCollector> sampleCollectors,
			Set<Sampleresources> sampleresourceses,
			Set<CvSamplematerial> cvSamplematerials,
			String elevationUnits) {
		this.cvSamplingmethod = cvSamplingmethod;
		this.registrant = registrant;
		this.statusByPhysicalsamplestatus = statusByPhysicalsamplestatus;
		this.statusByRegistrationstatus = statusByRegistrationstatus;
		this.samplename = samplename;
		this.othername = othername;
		this.igsn = igsn;
		this.landingpage = landingpage;
		this.classification = classification;
		this.classificationidentifier = classificationidentifier;
		this.purpose = purpose;
		this.samplinglocgeom = samplinglocgeom;
		this.samplinglocsrs = samplinglocsrs;
		this.elevation = elevation;
		this.verticaldatum = verticaldatum;
		this.locality = locality;
		this.samplingstart = samplingstart;
		this.samplingend = samplingend;
		this.samplingcampaign = samplingcampaign;
		this.comment = comment;	
		this.created = created;
		this.modified = modified;
		this.ispublic = ispublic;
		this.cvSampletypes = cvSampletypes;
		this.samplecurations = samplecurations;
		this.samplingfeatures = samplingfeatures;
		this.sampleCollectors = sampleCollectors;
		this.sampleresourceses = sampleresourceses;
		this.cvSamplematerials = cvSamplematerials;
		this.elevationUnits = elevationUnits;
	}

	@Id
	@Column(name = "sampleid", unique = true, nullable = false)
	@SequenceGenerator(name="sample_sampleid_seq",sequenceName="sample_sampleid_seq", allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="sample_sampleid_seq")
	public int getSampleid() {
		return this.sampleid;
	}

	public void setSampleid(int sampleid) {
		this.sampleid = sampleid;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "samplingmethod")
	public CvSamplingmethod getCvSamplingmethod() {
		return this.cvSamplingmethod;
	}

	public void setCvSamplingmethod(CvSamplingmethod cvSamplingmethod) {
		this.cvSamplingmethod = cvSamplingmethod;
	}

	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn( name = "registrant", referencedColumnName="registrantid")
	public Registrant getRegistrant() {
		return this.registrant;
	}

	public void setRegistrant(Registrant registrant) {
		this.registrant = registrant;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "physicalsamplestatus")
	public Status getStatusByPhysicalsamplestatus() {
		return this.statusByPhysicalsamplestatus;
	}

	public void setStatusByPhysicalsamplestatus(
			Status statusByPhysicalsamplestatus) {
		this.statusByPhysicalsamplestatus = statusByPhysicalsamplestatus;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "registrationstatus")
	public Status getStatusByRegistrationstatus() {
		return this.statusByRegistrationstatus;
	}

	public void setStatusByRegistrationstatus(Status statusByRegistrationstatus) {
		this.statusByRegistrationstatus = statusByRegistrationstatus;
	}

	@Column(name = "samplename", nullable = false)
	public String getSamplename() {
		return this.samplename;
	}

	public void setSamplename(String samplename) {
		this.samplename = samplename;
	}

	@Column(name = "othername")
	public String getOthername() {
		return this.othername;
	}

	public void setOthername(String othername) {
		this.othername = othername;
	}

	@Column(name = "igsn", unique = true, nullable = false)
	public String getIgsn() {
		return this.igsn;
	}

	public void setIgsn(String igsn) {
		this.igsn = igsn;
	}

	@Column(name = "landingpage", nullable = false, length = 250)
	public String getLandingpage() {
		return this.landingpage;
	}

	public void setLandingpage(String landingpage) {
		this.landingpage = landingpage;
	}

	@Column(name = "classification")
	public String getClassification() {
		return this.classification;
	}

	public void setClassification(String classification) {
		this.classification = classification;
	}

	@Column(name = "classificationidentifier")
	public String getClassificationidentifier() {
		return this.classificationidentifier;
	}

	public void setClassificationidentifier(String classificationidentifier) {
		this.classificationidentifier = classificationidentifier;
	}

	@Column(name = "purpose")
	public String getPurpose() {
		return this.purpose;
	}

	public void setPurpose(String purpose) {
		this.purpose = purpose;
	}

	
	@Column(name = "samplinglocgeom")
	@Type(type="org.hibernate.spatial.GeometryType")
	@JsonIgnore
	public Geometry getSamplinglocgeom() {
		return this.samplinglocgeom;
	}

	public void setSamplinglocgeom(Geometry samplinglocgeom) {
		this.samplinglocgeom = samplinglocgeom;
	}

	@Column(name = "samplinglocsrs", length = 20)
	public String getSamplinglocsrs() {
		return this.samplinglocsrs;
	}

	public void setSamplinglocsrs(String samplinglocsrs) {
		this.samplinglocsrs = samplinglocsrs;
	}

	@Column(name = "elevation", length = 30)
	public String getElevation() {
		return this.elevation;
	}

	public void setElevation(String elevation) {
		this.elevation = elevation;
	}

	@Column(name = "verticaldatum", length = 20)
	public String getVerticaldatum() {
		return this.verticaldatum;
	}

	public void setVerticaldatum(String verticaldatum) {
		this.verticaldatum = verticaldatum;
	}

	@Column(name = "locality", length = 300)
	public String getLocality() {
		return this.locality;
	}

	public void setLocality(String locality) {
		this.locality = locality;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "samplingstart", length = 29)
	public Date getSamplingstart() {
		return this.samplingstart;
	}

	public void setSamplingstart(Date samplingstart) {
		this.samplingstart = samplingstart;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "samplingend", length = 29)
	public Date getSamplingend() {
		return this.samplingend;
	}

	public void setSamplingend(Date samplingend) {
		this.samplingend = samplingend;
	}

	@Column(name = "samplingcampaign")
	public String getSamplingcampaign() {
		return this.samplingcampaign;
	}

	public void setSamplingcampaign(String samplingcampaign) {
		this.samplingcampaign = samplingcampaign;
	}

	@Column(name = "comment")
	public String getComment() {
		return this.comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}	

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created", nullable = false, length = 29)
	public Date getCreated() {
		return this.created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "modified", length = 29)
	public Date getModified() {
		return this.modified;
	}

	public void setModified(Date modified) {
		this.modified = modified;
	}

	@Column(name = "ispublic")
	public Boolean getIspublic() {
		return this.ispublic;
	}

	public void setIspublic(Boolean ispublic) {
		this.ispublic = ispublic;
	}

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "sample_types", joinColumns = { @JoinColumn(name = "sampleid", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "sampletypeid", nullable = false, updatable = false) })
	public Set<CvSampletype> getCvSampletypes() {
		return this.cvSampletypes;
	}

	public void setCvSampletypes(Set<CvSampletype> cvSampletypes) {
		this.cvSampletypes = cvSampletypes;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "sample",cascade={CascadeType.ALL},orphanRemoval=true)
	public Set<Samplecuration> getSamplecurations() {
		return this.samplecurations;
	}

	public void setSamplecurations(Set<Samplecuration> samplecurations) {
		this.samplecurations = samplecurations;
	}

	
	@ManyToMany(fetch = FetchType.EAGER, cascade={CascadeType.ALL})
	@JoinTable(name = "sample_features_mapping", joinColumns = { @JoinColumn(name = "sampleid", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "featureid", nullable = false, updatable = false) })
	public Set<Samplingfeatures> getSamplingfeatures() {
		return this.samplingfeatures;
	}

	public void setSamplingfeatures(
			Set<Samplingfeatures> samplingfeatures) {
		this.samplingfeatures = samplingfeatures;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "sample",cascade={CascadeType.ALL}, orphanRemoval=true)
	public Set<SampleCollector> getSampleCollectors() {
		return this.sampleCollectors;
	}

	public void setSampleCollectors(Set<SampleCollector> sampleCollectors) {
		this.sampleCollectors = sampleCollectors;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "sample", cascade={CascadeType.ALL}, orphanRemoval=true)
	public Set<Sampleresources> getSampleresourceses() {
		return this.sampleresourceses;
	}

	public void setSampleresourceses(Set<Sampleresources> sampleresourceses) {
		this.sampleresourceses = sampleresourceses;
	}

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "sample_material", joinColumns = { @JoinColumn(name = "sampleid", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "materialid", nullable = false, updatable = false) })
	public Set<CvSamplematerial> getCvSamplematerials() {
		return this.cvSamplematerials;
	}

	public void setCvSamplematerials(Set<CvSamplematerial> cvSamplematerials) {
		this.cvSamplematerials = cvSamplematerials;
	}
	
	@Column(name = "elevation_units", length = 100)
	public String getElevationUnits() {
		return this.elevationUnits;
	}

	public void setElevationUnits(String elevationUnits) {
		this.elevationUnits = elevationUnits;
	}
	
	@Column(name = "samplingloc_nilreason", length = 100)
	public String getSamplinglocNilreason() {
		return samplinglocNilreason;
	}

	public void setSamplinglocNilreason(String samplinglocNilreason) {
		this.samplinglocNilreason = samplinglocNilreason;
	}

	@Column(name = "samplingtime_nilreason", length = 100)
	public String getSamplingtimeNilreason() {
		return samplingtimeNilreason;
	}

	public void setSamplingtimeNilreason(String samplingtimeNilreason) {
		this.samplingtimeNilreason = samplingtimeNilreason;
	}
	


}
