comparison src/main/java/edu/harvard/iq/dataverse/DataTable.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
7 package edu.harvard.iq.dataverse;
8
9 import java.io.Serializable;
10 import java.util.ArrayList;
11 import java.util.List;
12 import javax.persistence.CascadeType;
13 import javax.persistence.Entity;
14 import javax.persistence.GeneratedValue;
15 import javax.persistence.GenerationType;
16 import javax.persistence.Id;
17 import javax.persistence.JoinColumn;
18 import javax.persistence.ManyToOne;
19 import javax.persistence.OneToMany;
20 import javax.validation.constraints.Size;
21 import javax.persistence.OrderBy;
22 import org.hibernate.validator.constraints.NotBlank;
23 import org.hibernate.validator.constraints.URL;
24
25 import edu.harvard.iq.dataverse.datavariable.DataVariable;
26 import java.util.Objects;
27 import javax.persistence.Column;
28 import javax.persistence.Index;
29 import javax.persistence.Table;
30
31 /**
32 *
33 * @author Leonid Andreev
34 *
35 * Largely based on the the DataTable entity from the DVN v2-3;
36 * original author: Ellen Kraffmiller (2006).
37 *
38 */
39
40 @Entity
41 @Table(indexes = {@Index(columnList="datafile_id")})
42 public class DataTable implements Serializable {
43
44 /** Creates a new instance of DataTable */
45 public DataTable() {
46 }
47
48 private static final long serialVersionUID = 1L;
49 @Id
50 @GeneratedValue(strategy = GenerationType.IDENTITY)
51 private Long id;
52
53 /**
54 * unf: the Universal Numeric Signature of the
55 * data table.
56 */
57 @Column( nullable = false )
58 private String unf;
59
60 /*
61 * caseQuantity: Number of observations
62 */
63 private Long caseQuantity;
64
65
66 /*
67 * varQuantity: Number of variables
68 */
69 private Long varQuantity;
70
71 /*
72 * recordsPerCase: this property is specific to fixed-field data files
73 * in which rows of observations may represented by *multiple* lines.
74 * The only known use case (so far): the fixed-width data files from
75 * ICPSR.
76 */
77 private Long recordsPerCase;
78
79 /*
80 * DataFile that stores the data for this DataTable
81 */
82 @ManyToOne
83 @JoinColumn(nullable=false)
84 private DataFile dataFile;
85
86 /*
87 * DataVariables in this DataTable:
88 */
89 @OneToMany (mappedBy="dataTable", cascade={ CascadeType.REMOVE, CascadeType.MERGE,CascadeType.PERSIST})
90 @OrderBy ("fileOrder")
91 private List<DataVariable> dataVariables;
92
93 /*
94 * originalFileType: the format of the file from which this data table was
95 * extracted (STATA, SPSS, R, etc.)
96 * Note: this was previously stored in the StudyFile.
97 */
98 private String originalFileFormat;
99
100 /*
101 * originalFormatVersion: the version/release number of the original file
102 * format; for example, STATA 9, SPSS 12, etc.
103 */
104 private String originalFormatVersion;
105
106 /*
107 * Getter and Setter methods:
108 */
109 public Long getId() {
110 return this.id;
111 }
112
113 public void setId(Long id) {
114 this.id = id;
115 }
116
117 public String getUnf() {
118 return this.unf;
119 }
120
121 public void setUnf(String unf) {
122 this.unf = unf;
123 }
124
125 public Long getCaseQuantity() {
126 return this.caseQuantity;
127 }
128
129 public void setCaseQuantity(Long caseQuantity) {
130 this.caseQuantity = caseQuantity;
131 }
132
133 public Long getVarQuantity() {
134 return this.varQuantity;
135 }
136
137 public void setVarQuantity(Long varQuantity) {
138 this.varQuantity = varQuantity;
139 }
140
141 public Long getRecordsPerCase() {
142 return recordsPerCase;
143 }
144
145 public void setRecordsPerCase(Long recordsPerCase) {
146 this.recordsPerCase = recordsPerCase;
147 }
148
149 public DataFile getDataFile() {
150 return this.dataFile;
151 }
152
153 public void setDataFile(DataFile dataFile) {
154 this.dataFile = dataFile;
155 }
156
157
158 public List<DataVariable> getDataVariables() {
159 return this.dataVariables;
160 }
161
162
163 public void setDataVariables(List<DataVariable> dataVariables) {
164 this.dataVariables = dataVariables;
165 }
166
167 public String getOriginalFileFormat() {
168 return originalFileFormat;
169 }
170
171 public void setOriginalFileFormat(String originalFileType) {
172 this.originalFileFormat = originalFileType;
173 }
174
175
176 public String getOriginalFormatVersion() {
177 return originalFormatVersion;
178 }
179
180 public void setOriginalFormatVersion(String originalFormatVersion) {
181 this.originalFormatVersion = originalFormatVersion;
182 }
183
184 /*
185 * Custom overrides for hashCode(), equals() and toString() methods:
186 */
187
188 @Override
189 public int hashCode() {
190 int hash = 0;
191 hash += (this.id != null ? this.id.hashCode() : 0);
192 return hash;
193 }
194
195 @Override
196 public boolean equals(Object object) {
197 if (!(object instanceof DataTable)) {
198 return false;
199 }
200 DataTable other = (DataTable)object;
201 return !(!Objects.equals(this.id, other.id) && (this.id == null || !this.id.equals(other.id)));
202 }
203
204 @Override
205 public String toString() {
206 return "edu.harvard.iq.dataverse.DataTable[ id=" + id + " ]";
207 }
208
209 }