• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IQSS / dataverse / #22002

01 Apr 2024 07:56PM CUT coverage: 20.716% (+0.5%) from 20.173%
#22002

push

github

web-flow
Merge pull request #10453 from IQSS/develop

Merge 6.2 into master

704 of 2679 new or added lines in 152 files covered. (26.28%)

81 existing lines in 49 files now uncovered.

17160 of 82836 relevant lines covered (20.72%)

0.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

59.57
/src/main/java/edu/harvard/iq/dataverse/DataTable.java
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.List;
11
import jakarta.persistence.CascadeType;
12
import jakarta.persistence.Entity;
13
import jakarta.persistence.GeneratedValue;
14
import jakarta.persistence.GenerationType;
15
import jakarta.persistence.Id;
16
import jakarta.persistence.JoinColumn;
17
import jakarta.persistence.ManyToOne;
18
import jakarta.persistence.OneToMany;
19
import jakarta.validation.constraints.Size;
20
import jakarta.persistence.OrderBy;
21

22
import edu.harvard.iq.dataverse.datavariable.DataVariable;
23
import java.util.Objects;
24
import jakarta.persistence.Column;
25
import jakarta.persistence.Index;
26
import jakarta.persistence.Table;
27

28
/**
29
 *
30
 * @author Leonid Andreev
31
 * 
32
 * Largely based on the the DataTable entity from the DVN v2-3;
33
 * original author: Ellen Kraffmiller (2006).
34
 * 
35
 */
36

37
@Entity
38
@Table(indexes = {@Index(columnList="datafile_id")})
39
public class DataTable implements Serializable {
40
    
41
    /** Creates a new instance of DataTable */
42
    public DataTable() {
1✔
43
    }
1✔
44
    
45
    private static final long serialVersionUID = 1L;
46
    @Id
47
    @GeneratedValue(strategy = GenerationType.IDENTITY)
48
    private Long id;
49
    
50
    /**
51
     * unf: the Universal Numeric Signature of the 
52
     * data table.
53
     */
54
    @Column( nullable = false )
55
    private String unf;
56
    
57
    /*
58
     * caseQuantity: Number of observations
59
     */    
60
    private Long caseQuantity; 
61
    
62
    
63
    /*
64
     * varQuantity: Number of variables
65
     */
66
    private Long varQuantity;
67

68
    /*
69
     * recordsPerCase: this property is specific to fixed-field data files
70
     * in which rows of observations may represented by *multiple* lines.
71
     * The only known use case (so far): the fixed-width data files from 
72
     * ICPSR. 
73
     */
74
     private Long recordsPerCase;
75
     
76
     /*
77
      * DataFile that stores the data for this DataTable
78
      */
79
     @ManyToOne
80
     @JoinColumn(nullable=false)
81
     private DataFile dataFile;
82

83
     /*
84
      * DataVariables in this DataTable:
85
     */
86
    @OneToMany (mappedBy="dataTable", cascade={ CascadeType.REMOVE, CascadeType.MERGE,CascadeType.PERSIST})
87
    @OrderBy ("fileOrder")
88
    private List<DataVariable> dataVariables;
89
    
90
    /* 
91
     * originalFileType: the format of the file from which this data table was
92
     * extracted (STATA, SPSS, R, etc.)
93
     * Note: this was previously stored in the StudyFile. 
94
     */
95
    private String originalFileFormat;
96
    
97
    /*
98
     * originalFormatVersion: the version/release number of the original file
99
     * format; for example, STATA 9, SPSS 12, etc. 
100
     */
101
    private String originalFormatVersion;
102
    
103
    /* 
104
     * Size of the original file:
105
    */
106
    
107
    private Long originalFileSize; 
108
    
109
    /**
110
     * originalFileName: the file name upon upload/ingest
111
     */
112
    @Column( nullable = true )
113
    private String originalFileName;
114
    
115
    
116
    /**
117
     * The physical tab-delimited file is in storage with the list of variable
118
     * names saved as the 1st line. This means that we do not need to generate 
119
     * this line on the fly. (Also means that direct download mechanism can be
120
     * used for this file!)
121
     */
122
    @Column(nullable = false)
1✔
123
    private boolean storedWithVariableHeader = false;  
124
    
125
    /*
126
     * Getter and Setter methods:
127
     */
128
    public Long getId() {
129
        return this.id;
×
130
    }
131

132
    public void setId(Long id) {
133
        this.id = id;
×
134
    }
×
135

136
    public String getUnf() {
137
        return this.unf;
1✔
138
    }
139

140
    public void setUnf(String unf) {
141
        this.unf = unf;
1✔
142
    }
1✔
143

144
    public Long getCaseQuantity() {
145
        return this.caseQuantity;
1✔
146
    }    
147
    
148
    public void setCaseQuantity(Long caseQuantity) {
149
        this.caseQuantity = caseQuantity;
1✔
150
    }
1✔
151
    
152
    public Long getVarQuantity() {
153
        return this.varQuantity;
1✔
154
    }
155

156
    public void setVarQuantity(Long varQuantity) {
157
        this.varQuantity = varQuantity;
1✔
158
    }   
1✔
159
    
160
    public Long getRecordsPerCase() {
161
        return recordsPerCase;
×
162
    }
163

164
    public void setRecordsPerCase(Long recordsPerCase) {
165
        this.recordsPerCase = recordsPerCase;
×
166
    }
×
167
    
168
    public DataFile getDataFile() {
169
        return this.dataFile;
×
170
    }
171
    
172
    public void setDataFile(DataFile dataFile) {
173
        this.dataFile = dataFile;
1✔
174
    }
1✔
175

176
     
177
    public List<DataVariable> getDataVariables() {
178
        return this.dataVariables;
1✔
179
    }
180

181
    
182
    public void setDataVariables(List<DataVariable> dataVariables) {
183
        this.dataVariables = dataVariables;
1✔
184
    } 
1✔
185
    
186
    public String getOriginalFileFormat() {
187
        return originalFileFormat;
1✔
188
    }
189

190
    public void setOriginalFileFormat(String originalFileType) {
191
        this.originalFileFormat = originalFileType;
1✔
192
    }
1✔
193

194
    public Long getOriginalFileSize() {
195
        return originalFileSize; 
1✔
196
    }
197
    
198
    public void setOriginalFileSize(Long originalFileSize) {
199
        this.originalFileSize = originalFileSize;
×
200
    }
×
201
    
202
    
203
    public String getOriginalFormatVersion() {
204
        return originalFormatVersion;
1✔
205
    }
206

207
    public void setOriginalFormatVersion(String originalFormatVersion) {
208
        this.originalFormatVersion = originalFormatVersion;
1✔
209
    }
1✔
210
       
211
    public String getOriginalFileName() {
212
        return originalFileName;
1✔
213
    }
214

215
    public void setOriginalFileName(String originalFileName) {
216
        this.originalFileName = originalFileName;
1✔
217
    }
1✔
218
    
219
    public boolean isStoredWithVariableHeader() {
220
        return storedWithVariableHeader;
1✔
221
    }
222
    
223
    public void setStoredWithVariableHeader(boolean storedWithVariableHeader) {
NEW
224
        this.storedWithVariableHeader = storedWithVariableHeader;
×
NEW
225
    }
×
226
    
227
    /* 
228
     * Custom overrides for hashCode(), equals() and toString() methods:
229
     */
230
    
231
    @Override
232
    public int hashCode() {
233
        int hash = 0;
×
234
        hash += (this.id != null ? this.id.hashCode() : 0);
×
235
        return hash;
×
236
    }
237

238
    @Override
239
    public boolean equals(Object object) {
240
        if (!(object instanceof DataTable)) {
×
241
            return false;
×
242
        }
243
        DataTable other = (DataTable)object;
×
244
        return !(!Objects.equals(this.id, other.id) && (this.id == null || !this.id.equals(other.id)));
×
245
    }
246

247
    @Override
248
    public String toString() {
249
        return "edu.harvard.iq.dataverse.DataTable[ id=" + id + " ]";
×
250
    }
251
    
252
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc