Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package smash.appointment.parse;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class DuplicateRemoveParser {
private SubjectDao subjectDao;
public void removeDuplicates(String filename) throws IOException {
try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
String line;
while ((line = br.readLine()) != null) {
String tmp[] = line.split("\t");
Subject subject = subjectDao.getByScreeningNumber(tmp[0]);
if (subject == null) {
throw new InvalidArgumentException("Cannot find subject with id: " + tmp[0]);
}
for (int i = 1; i < tmp.length; i++) {
Subject duplicate = subjectDao.getByScreeningNumber(tmp[i]);
if (duplicate == null) {
throw new InvalidArgumentException("Cannot find subject with id: " + tmp[i]);
}
subjectDao.removeDuplicate(subject, duplicate, "DUPLICATES: " + tmp[0] + ", " + tmp[i]);
}
}
}
}
/**
* @return the subjectDao
* @see #subjectDao
*/
public SubjectDao getSubjectDao() {
return subjectDao;
}
/**
* @param subjectDao
* the subjectDao to set
* @see #subjectDao
*/
public void setSubjectDao(SubjectDao subjectDao) {
this.subjectDao = subjectDao;
}
}