use of aserg.gtf.dao.NewFileInfoDAO in project Truck-Factor by aserg-ufmg.
the class LinguistExtractor method extractAndPersist.
public void extractAndPersist() throws IOException {
NewFileInfoDAO fiDAO = new NewFileInfoDAO();
fiDAO.setAllAsNotLinguist();
List<NewFileInfo> files = execute();
try {
Map<String, List<String>> languageMap = new HashMap<String, List<String>>();
System.out.format("%s (%s): Extracting file language information...", repositoryName, new Date());
BufferedReader br = new BufferedReader(new FileReader(repositoryPath + fileName));
String sCurrentLine;
String[] values;
while ((sCurrentLine = br.readLine()) != null) {
values = sCurrentLine.split(";");
String language = values[0];
if (language.contains("\'"))
language = language.replace("'", "''");
String path = values[1];
List<String> paths;
if (languageMap.containsKey(language))
paths = languageMap.get(language);
else {
paths = new ArrayList<String>();
languageMap.put(language, paths);
}
paths.add(path);
files.add(new NewFileInfo(repositoryName, path, language));
}
br.close();
for (Entry<String, List<String>> entry : languageMap.entrySet()) {
fiDAO.updateLanguageFileInfo(repositoryName, entry.getKey(), entry.getValue());
}
} catch (Exception e) {
System.err.println("Erro no projeto " + repositoryName);
System.err.println(e.getMessage());
}
}
Aggregations