Mercurial > hg > LGDataverses
comparison src/main/java/edu/harvard/iq/dataverse/DataverseLinkingDataverse.java @ 10:a50cf11e5178
Rewrite LGDataverse completely upgrading to dataverse4.0
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Tue, 08 Sep 2015 17:00:21 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 9:5926d6419569 | 10:a50cf11e5178 |
|---|---|
| 1 /* | |
| 2 * To change this license header, choose License Headers in Project Properties. | |
| 3 * To change this template file, choose Tools | Templates | |
| 4 * and open the template in the editor. | |
| 5 */ | |
| 6 package edu.harvard.iq.dataverse; | |
| 7 | |
| 8 import java.io.Serializable; | |
| 9 import java.util.Date; | |
| 10 import javax.persistence.Entity; | |
| 11 import javax.persistence.GeneratedValue; | |
| 12 import javax.persistence.GenerationType; | |
| 13 import javax.persistence.Id; | |
| 14 import javax.persistence.Index; | |
| 15 import javax.persistence.JoinColumn; | |
| 16 import javax.persistence.OneToOne; | |
| 17 import javax.persistence.Table; | |
| 18 import javax.persistence.Temporal; | |
| 19 import javax.persistence.TemporalType; | |
| 20 | |
| 21 /** | |
| 22 * | |
| 23 * @author skraffmiller | |
| 24 */ | |
| 25 @Entity | |
| 26 @Table(indexes = { | |
| 27 @Index(columnList = "dataverse_id"), | |
| 28 @Index(columnList = "linkingDataverse_id") | |
| 29 }) | |
| 30 public class DataverseLinkingDataverse implements Serializable { | |
| 31 private static final long serialVersionUID = 1L; | |
| 32 @Id | |
| 33 @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| 34 private Long id; | |
| 35 | |
| 36 @OneToOne | |
| 37 @JoinColumn(nullable = false) | |
| 38 private Dataverse dataverse; | |
| 39 | |
| 40 @OneToOne | |
| 41 @JoinColumn(nullable = false) | |
| 42 private Dataverse linkingDataverse; | |
| 43 | |
| 44 @Temporal(value = TemporalType.TIMESTAMP) | |
| 45 private Date linkCreateTime; | |
| 46 | |
| 47 public Long getId() { | |
| 48 return id; | |
| 49 } | |
| 50 | |
| 51 public Dataverse getDataverse() { | |
| 52 return dataverse; | |
| 53 } | |
| 54 | |
| 55 public void setDataverse(Dataverse dataverse) { | |
| 56 this.dataverse = dataverse; | |
| 57 } | |
| 58 | |
| 59 public Dataverse getLinkingDataverse() { | |
| 60 return linkingDataverse; | |
| 61 } | |
| 62 | |
| 63 public void setLinkingDataverse(Dataverse linkingDataverse) { | |
| 64 this.linkingDataverse = linkingDataverse; | |
| 65 } | |
| 66 | |
| 67 public Date getLinkCreateTime() { | |
| 68 return linkCreateTime; | |
| 69 } | |
| 70 | |
| 71 public void setLinkCreateTime(Date linkCreateTime) { | |
| 72 this.linkCreateTime = linkCreateTime; | |
| 73 } | |
| 74 | |
| 75 public void setId(Long id) { | |
| 76 this.id = id; | |
| 77 } | |
| 78 | |
| 79 @Override | |
| 80 public int hashCode() { | |
| 81 int hash = 0; | |
| 82 hash += (id != null ? id.hashCode() : 0); | |
| 83 return hash; | |
| 84 } | |
| 85 | |
| 86 @Override | |
| 87 public boolean equals(Object object) { | |
| 88 // TODO: Warning - this method won't work in the case the id fields are not set | |
| 89 if (!(object instanceof DataverseLinkingDataverse)) { | |
| 90 return false; | |
| 91 } | |
| 92 DataverseLinkingDataverse other = (DataverseLinkingDataverse) object; | |
| 93 if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { | |
| 94 return false; | |
| 95 } | |
| 96 return true; | |
| 97 } | |
| 98 | |
| 99 @Override | |
| 100 public String toString() { | |
| 101 return "edu.harvard.iq.dataverse.DataverseLinkedDataverse[ id=" + id + " ]"; | |
| 102 } | |
| 103 | |
| 104 } |
