Skip to content
Snippets Groups Projects

Duplicates removal

Merged Piotr Gawron requested to merge duplicates-removal into master
15 files
+ 267
25
Compare changes
  • Side-by-side
  • Inline
Files
15
 
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;
 
}
 
}
Loading