Search in sources :

Example 6 with NewFileInfo

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());
    }
}
Also used : HashMap(java.util.HashMap) NewFileInfoDAO(aserg.gtf.dao.NewFileInfoDAO) Date(java.util.Date) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) List(java.util.List) FileReader(java.io.FileReader) NewFileInfo(aserg.gtf.model.NewFileInfo)

Example 7 with NewFileInfo

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;
}
Also used : ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) NewFileInfo(aserg.gtf.model.NewFileInfo)

Example 8 with NewFileInfo

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);
}
Also used : NewFileInfo(aserg.gtf.model.NewFileInfo)

Example 9 with NewFileInfo

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);
}
Also used : NewFileInfo(aserg.gtf.model.NewFileInfo)

Example 10 with NewFileInfo

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);
}
Also used : NewFileInfo(aserg.gtf.model.NewFileInfo)

Aggregations

NewFileInfo (aserg.gtf.model.NewFileInfo)16 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 LogCommitInfo (aserg.gtf.model.LogCommitInfo)3 Repository (aserg.gtf.model.authorship.Repository)3 DOACalculator (aserg.gtf.task.DOACalculator)3 BufferedReader (java.io.BufferedReader)3 FileReader (java.io.FileReader)3 HashMap (java.util.HashMap)3 GreedyTruckFactor (aserg.gtf.truckfactor.GreedyTruckFactor)2 TFInfo (aserg.gtf.truckfactor.TFInfo)2 TruckFactor (aserg.gtf.truckfactor.TruckFactor)2 LineInfo (aserg.gtf.util.LineInfo)2 FileNotFoundException (java.io.FileNotFoundException)2 Date (java.util.Date)2 NewFileInfoDAO (aserg.gtf.dao.NewFileInfoDAO)1 File (aserg.gtf.model.authorship.File)1 NewAliasHandler (aserg.gtf.task.NewAliasHandler)1 FileInfoExtractor (aserg.gtf.task.extractor.FileInfoExtractor)1