use of aserg.gtf.model.authorship.FileAuthors in project Truck-Factor by aserg-ufmg.
the class RepositoryDAO method getFilesAuthorMap.
public Map<Long, Set<Long>> getFilesAuthorMap(String repositoryName) {
Map<Long, Set<Long>> map = new HashMap<Long, Set<Long>>();
String hql = "SELECT d.id, fi.id FROM repository_file rf " + "JOIN repository r ON r.id = rf.repository_id " + "JOIN file fi ON fi.id = rf.files_id " + "JOIN authorshipinfo ai ON ai.id = fi.bestauthorshipinfo_id " + "JOIN developer d ON ai.developer_id = d.id " + "WHERE r.fullname = \'" + repositoryName + "\' AND fi.removed = \'FALSE\' " + "ORDER BY fi.path;";
Query q = em.createNativeQuery(hql);
List<Object[]> authorsFiles = q.getResultList();
List<FileAuthors> fileAuthors = new ArrayList<FileAuthors>();
for (Object[] objects : authorsFiles) {
Long authorId = (Long) objects[0];
Long fileId = (Long) objects[1];
if (!map.containsKey(authorId))
map.put(authorId, new HashSet<Long>());
map.get(authorId).add(fileId);
}
return map;
}
use of aserg.gtf.model.authorship.FileAuthors in project Truck-Factor by aserg-ufmg.
the class RepositoryDAO method getFilesAuthorList.
public List<FileAuthors> getFilesAuthorList(String repositoryName) {
String hql = "SELECT d.newusername, fi.path FROM repository_file rf " + "JOIN repository r ON r.id = rf.repository_id " + "JOIN file fi ON fi.id = rf.files_id " + "JOIN authorshipinfo ai ON ai.id = fi.bestauthorshipinfo_id " + "JOIN developer d ON ai.developer_id = d.id " + "WHERE r.fullname = \'" + repositoryName + "\' " + "ORDER BY fi.path;";
Query q = em.createNativeQuery(hql);
List<Object[]> authorsFiles = q.getResultList();
List<FileAuthors> fileAuthors = new ArrayList<FileAuthors>();
for (Object[] objects : authorsFiles) {
fileAuthors.add(new FileAuthors((String) objects[1], (String) objects[0]));
}
return fileAuthors;
}
use of aserg.gtf.model.authorship.FileAuthors in project Truck-Factor by aserg-ufmg.
the class FormatDoaDistribution method main.
public static void main(String[] args) {
RepositoryDAO repDAO = new RepositoryDAO();
List<FileAuthors> fileAuthors = repDAO.getFilesAuthorList("activeadmin/activeadmin");
Directory mainDirectory = new Directory("Main");
for (FileAuthors fileAuthor : fileAuthors) {
String[] names = fileAuthor.getFileName().split("/");
insert(mainDirectory, names, fileAuthor.getMainAuthor());
}
System.out.println(mainDirectory.toJson());
}
Aggregations