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;
}
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);
}
}
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);
}
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;
}
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();
}
Aggregations