use of aserg.gtf.model.NewFileInfo 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());
}
}
use of aserg.gtf.model.NewFileInfo in project Truck-Factor by aserg-ufmg.
the class FileInfoExtractor method execute.
public List<NewFileInfo> execute() throws Exception {
List<NewFileInfo> files = new ArrayList<NewFileInfo>();
try {
LOGGER.info(repositoryName + ": Extracting file information...");
BufferedReader br = new BufferedReader(new FileReader(repositoryPath + fileName));
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
files.add(new NewFileInfo(repositoryName, sCurrentLine));
}
br.close();
} catch (Exception e) {
throw new Exception("Error in project " + repositoryName, e);
}
return files;
}
use of aserg.gtf.model.NewFileInfo in project Truck-Factor by aserg-ufmg.
the class GitTruckFactor method filterModule.
private static void filterModule(List<NewFileInfo> files, String module) {
int count = 0;
for (NewFileInfo file : files) {
if (file.getModule().equals(module)) {
file.setFiltered(true);
file.setFilterInfo("Module-filter");
} else if (!file.getFiltered())
count++;
}
LOGGER.info("Files without " + module + ": " + count);
}
use of aserg.gtf.model.NewFileInfo in project Truck-Factor by aserg-ufmg.
the class GitTruckFactor method applyRegexFilter.
private static void applyRegexFilter(List<NewFileInfo> files, String exp) {
int count = 0;
for (NewFileInfo newFileInfo : files) {
if (!newFileInfo.getFiltered()) {
if (newFileInfo.getPath().matches(exp)) {
count++;
newFileInfo.setFiltered(true);
newFileInfo.setFilterInfo("REGEX: " + exp);
}
}
}
LOGGER.info("REGEX FILTER = " + count);
}
use of aserg.gtf.model.NewFileInfo in project Truck-Factor by aserg-ufmg.
the class GitTruckFactor method filterByModule.
private static void filterByModule(List<NewFileInfo> files, String module) {
int count = 0;
for (NewFileInfo file : files) {
if (!file.getModule().equals(module)) {
file.setFiltered(true);
file.setFilterInfo("Module-filter");
} else if (!file.getFiltered())
count++;
}
LOGGER.info(module + " - files: " + count);
}
Aggregations