Search in sources :

Example 1 with AuthorshipInfo

use of aserg.gtf.model.authorship.AuthorshipInfo in project Truck-Factor by aserg-ufmg.

the class DOACalculator method setFileHistory.

private static boolean setFileHistory(File file, Repository repository, NewFileInfo fileInfo, Map<String, List<LogCommitFileInfo>> mapFiles) {
    List<LogCommitFileInfo> fileCommits = mapFiles.get(fileInfo.getPath());
    // Rarely, but some files do not have any commit. Should be verified each case to understand the impact. Normally is irrelevant. 
    if (fileCommits == null) {
        LOGGER.warn("No commits for " + file);
        return false;
    }
    List<LogCommitFileInfo> logFilesObjectInfo = expandCommitFileList(fileCommits, mapFiles);
    String firstAuthor = null;
    for (LogCommitFileInfo commitFile : logFilesObjectInfo) {
        //ci.name, ci.email, lcfi.oldfilename, lcfi.newfilename, lcfi.status, lcfi.id, username
        LogCommitInfo commitInfo = commitFile.getCommitInfo();
        AuthorshipInfo authorshipInfo = repository.getAuthorshipInfo(commitInfo.getAuthorName(), commitInfo.getAuthorEmail(), commitInfo.getUserName(), file);
        Status status = commitFile.getStatus();
        if (status == Status.ADDED) {
            if (firstAuthor == null) {
                //FIRST ADD
                firstAuthor = authorshipInfo.getDeveloper().getNewUserName();
                authorshipInfo.setAsFirstAuthor();
            } else if (!authorshipInfo.isFirstAuthor()) {
                //New ADD made by a different developer of the first add
                String debugStr = String.format("New add;%s;%s;%s;%s", repository.getFullName(), file.getPath(), firstAuthor, authorshipInfo.getDeveloper().getNewUserName());
                LOGGER.debug(debugStr);
                authorshipInfo.setAsSecondaryAuthor();
                authorshipInfo.addNewAddDelivery();
            } else {
                //Treat as delivery if the extra add was made by the first author 
                authorshipInfo.addNewAddDelivery();
            }
        } else if (status == Status.MODIFIED) {
            authorshipInfo.addNewDelivery();
        //file.addNewChange();					
        } else if (status == Status.RENAMED_TREATED) {
            // Considering a rename as a new delivery
            authorshipInfo.addNewDelivery();
        //file.addNewChange();		
        } else
            System.err.println("Invalid Status: " + status);
    }
    double bestDoaValue = 0;
    for (AuthorshipInfo authorshipInfo : file.getAuthorshipInfos()) {
        double authorshipDoa = authorshipInfo.getDOA();
        if (authorshipDoa > bestDoaValue) {
            bestDoaValue = authorshipDoa;
            file.setBestAuthorshipInfo(authorshipInfo);
        }
    }
    double bestDoaValueMult = 0;
    for (AuthorshipInfo authorshipInfo : file.getAuthorshipInfos()) {
        double authorshipDoaMult = authorshipInfo.getDoaMultAuthor();
        if (authorshipDoaMult > bestDoaValueMult) {
            bestDoaValueMult = authorshipDoaMult;
            file.setBestAuthorshipInfoMult(authorshipInfo);
        }
    }
    double bestDoaValueAddDeliveries = 0;
    for (AuthorshipInfo authorshipInfo : file.getAuthorshipInfos()) {
        double authorshipDoaAddDeliveries = authorshipInfo.getDoaAddDeliveries();
        if (authorshipDoaAddDeliveries > bestDoaValueAddDeliveries) {
            bestDoaValueAddDeliveries = authorshipDoaAddDeliveries;
            file.setBestAuthorshipAddDeliveries(authorshipInfo);
        }
    }
    return true;
}
Also used : RepositoryStatus(aserg.gtf.model.authorship.RepositoryStatus) Status(aserg.gtf.model.Status) AuthorshipInfo(aserg.gtf.model.authorship.AuthorshipInfo) LogCommitFileInfo(aserg.gtf.model.LogCommitFileInfo) LogCommitInfo(aserg.gtf.model.LogCommitInfo)

Example 2 with AuthorshipInfo

use of aserg.gtf.model.authorship.AuthorshipInfo in project Truck-Factor by aserg-ufmg.

the class DOACalculator method printFile.

private static void printFile(File file) {
    System.out.println("--File: " + file.getPath());
    Collections.sort(file.getAuthorshipInfos());
    Collections.reverse(file.getAuthorshipInfos());
    for (AuthorshipInfo authorshioinfo : file.getAuthorshipInfos()) {
        printAuthorshipInfo(authorshioinfo);
    }
}
Also used : AuthorshipInfo(aserg.gtf.model.authorship.AuthorshipInfo)

Example 3 with AuthorshipInfo

use of aserg.gtf.model.authorship.AuthorshipInfo in project Truck-Factor by aserg-ufmg.

the class AuthorshipInfoDAO method updateDOA.

public void updateDOA(AuthorshipInfo a) {
    AuthorshipInfo persistedAuthorshipInfo = this.em.find(AuthorshipInfo.class, a.getId());
    persistedAuthorshipInfo.updateDOA();
    super.merge(persistedAuthorshipInfo);
}
Also used : AuthorshipInfo(aserg.gtf.model.authorship.AuthorshipInfo)

Example 4 with AuthorshipInfo

use of aserg.gtf.model.authorship.AuthorshipInfo in project Truck-Factor by aserg-ufmg.

the class GreedyTruckFactor method getFilesAuthorMap.

private Map<Developer, Set<File>> getFilesAuthorMap(Repository repository) {
    Map<Developer, Set<File>> map = new HashMap<Developer, Set<File>>();
    List<Developer> developers = repository.getDevelopers();
    for (Developer developer : developers) {
        Set<File> devFiles = new HashSet<File>();
        List<AuthorshipInfo> authorships = developer.getAuthorshipInfos();
        for (AuthorshipInfo authorshipInfo : authorships) {
            if (authorshipInfo.isDOAAuthor())
                devFiles.add(authorshipInfo.getFile());
        }
        if (devFiles.size() > 0)
            map.put(developer, devFiles);
    }
    return map;
}
Also used : AuthorshipInfo(aserg.gtf.model.authorship.AuthorshipInfo) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Developer(aserg.gtf.model.authorship.Developer) File(aserg.gtf.model.authorship.File) HashSet(java.util.HashSet)

Example 5 with AuthorshipInfo

use of aserg.gtf.model.authorship.AuthorshipInfo in project Truck-Factor by aserg-ufmg.

the class AliasesIdentifier method mergeAliasesAuthorship.

private static void mergeAliasesAuthorship(Developer dev1, Developer dev2) {
    List<AuthorshipInfo> mergedList = new ArrayList<AuthorshipInfo>(dev1.getAuthorshipInfos());
    for (AuthorshipInfo authorshipInfo : dev2.getAuthorshipInfos()) {
        AuthorshipInfo mergeAuthorship = getAuthorship(authorshipInfo.getFile().getPath(), mergedList);
        if (mergeAuthorship == null) {
            authorshipInfo.setDeveloper(dev1);
            mergedList.add(authorshipInfo);
        } else {
            if (authorshipInfo.isFirstAuthor())
                mergeAuthorship.setAsFirstAuthor();
            if (authorshipInfo.isSecondaryAuthor() && !mergeAuthorship.isFirstAuthor())
                mergeAuthorship.setAsSecondaryAuthor();
            mergeAuthorship.setnDeliveries(mergeAuthorship.getnDeliveries() + authorshipInfo.getnDeliveries());
            mergeAuthorship.setnAddDeliveries(mergeAuthorship.getnAddDeliveries() + authorshipInfo.getnAddDeliveries());
            mergeAuthorship.updateDOA();
        }
    }
    dev1.setAuthorshipInfos(mergedList);
    dev1.setStatus(DevStatus.MERGED);
    dev1.addOrigemDeveloper(dev2);
    dev2.setAsRemoved();
}
Also used : AuthorshipInfo(aserg.gtf.model.authorship.AuthorshipInfo) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

AuthorshipInfo (aserg.gtf.model.authorship.AuthorshipInfo)5 LogCommitFileInfo (aserg.gtf.model.LogCommitFileInfo)1 LogCommitInfo (aserg.gtf.model.LogCommitInfo)1 Status (aserg.gtf.model.Status)1 Developer (aserg.gtf.model.authorship.Developer)1 File (aserg.gtf.model.authorship.File)1 RepositoryStatus (aserg.gtf.model.authorship.RepositoryStatus)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1