use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class NewAliasHandler method execute.
public Map<String, LogCommitInfo> execute(String repositoryName, Map<String, LogCommitInfo> commits) {
setUsername(commits);
devUsernameMap = new HashMap<String, List<LogCommitInfo>>();
for (LogCommitInfo commit : commits.values()) {
String commitUsername = commit.getUserName();
if (!devUsernameMap.containsKey(commitUsername))
devUsernameMap.put(commitUsername, new ArrayList<LogCommitInfo>());
devUsernameMap.get(commitUsername).add(commit);
}
//Set<String> devNames = new HashSet<String>();
devNameMap = new HashMap<String, List<LogCommitInfo>>();
for (LogCommitInfo commit : commits.values()) {
//devNames.add(commit.getMainName());
String commitDevName = commit.getNormMainName();
if (!devNameMap.containsKey(commitDevName))
devNameMap.put(commitDevName, new ArrayList<LogCommitInfo>());
devNameMap.get(commitDevName).add(commit);
}
unifyUsernameByName();
if (fileAliases != null)
treatFileAlias();
return commits;
}
use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class NewAliasHandler method treatFileAlias.
private void treatFileAlias() {
for (LineInfo info : fileAliases) {
String rep = info.getRepositoryName();
String dev1 = info.getValues().get(0);
String dev2 = info.getValues().get(1);
String usernameDev1 = devNameMap.get(dev1.toUpperCase()).get(0).getUserName();
String usernameDev2 = devNameMap.get(dev2.toUpperCase()).get(0).getUserName();
String newUsername = usernameDev1.contains(usernameDev2) ? usernameDev1 : (usernameDev2.contains(usernameDev1) ? usernameDev2 : usernameDev1 + "$$" + usernameDev2);
for (LogCommitInfo commit : devUsernameMap.get(usernameDev1)) {
if (!commit.getUserName().equals(usernameDev2)) {
setNewUsername(commit, newUsername);
//commit.setUserName(newUsername);
}
}
for (LogCommitInfo commit : devUsernameMap.get(usernameDev2)) {
if (!commit.getUserName().equals(usernameDev1)) {
setNewUsername(commit, newUsername);
//commit.setUserName(newUsername);
}
}
}
}
use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class NewAliasHandler method unifyUsernameByEmail.
/** Treat different names for the same e-mail case */
private void unifyUsernameByEmail(Map<String, List<LogCommitInfo>> usernameMap) {
for (Entry<String, List<LogCommitInfo>> entry : usernameMap.entrySet()) {
List<String> names = getNamesList(entry.getValue());
String newUserName = names.get(0);
if (names.size() > 1)
newUserName = getNewName(names);
for (LogCommitInfo commit : entry.getValue()) {
commit.setUserName(newUserName);
}
}
}
use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class GitLogExtractor method execute.
public Map<String, LogCommitInfo> execute() throws Exception {
Map<String, LogCommitInfo> mapCommits = new HashMap<String, LogCommitInfo>();
int countcfs = 0;
try {
LOGGER.info("Extracting logCommits... " + repositoryPath);
BufferedReader br = new BufferedReader(new FileReader(repositoryPath + fileName));
String sCurrentLine;
String[] values;
while ((sCurrentLine = br.readLine()) != null) {
values = sCurrentLine.split(";");
if (values.length < 7)
LOGGER.error("Problem in line " + countcfs + ". Too much columns.");
Date authorDate = !values[3].isEmpty() ? new Timestamp(Long.parseLong(values[3]) * 1000L) : null;
Date commiterDate = !values[6].isEmpty() ? new Timestamp(Long.parseLong(values[6]) * 1000L) : null;
String msg = (values.length == 8) ? values[7] : "";
mapCommits.put(values[0], new LogCommitInfo(repositoryName, values[0], values[1], values[2], authorDate, values[4], values[5], commiterDate, msg));
countcfs++;
}
insertFiles(repositoryName, mapCommits);
br.close();
} catch (FileNotFoundException e) {
throw new Exception("File not found: " + repositoryPath + fileName, e);
} catch (Exception e) {
throw new Exception(String.format("Error in file %s, line %d%", repositoryName, countcfs));
}
return mapCommits;
}
use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class AliasHandler method getNamesList.
private List<String> getNamesList(Collection<LogCommitInfo> commits) {
HashSet<String> nameSet = new HashSet<String>();
List<String> names = new ArrayList<String>();
for (LogCommitInfo commit : commits) {
String simplifyedName = commit.getNormMainName().replace(" ", "");
if (!nameSet.contains(simplifyedName)) {
nameSet.add(simplifyedName);
names.add(commit.getMainName());
}
}
return names;
}
Aggregations