Search in sources :

Example 1 with FileAuthors

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;
}
Also used : FileAuthors(aserg.gtf.model.authorship.FileAuthors) HashSet(java.util.HashSet) Set(java.util.Set) Query(javax.persistence.Query) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 2 with FileAuthors

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;
}
Also used : FileAuthors(aserg.gtf.model.authorship.FileAuthors) Query(javax.persistence.Query) ArrayList(java.util.ArrayList)

Example 3 with 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());
}
Also used : RepositoryDAO(aserg.gtf.dao.authorship.RepositoryDAO) FileAuthors(aserg.gtf.model.authorship.FileAuthors)

Aggregations

FileAuthors (aserg.gtf.model.authorship.FileAuthors)3 ArrayList (java.util.ArrayList)2 Query (javax.persistence.Query)2 RepositoryDAO (aserg.gtf.dao.authorship.RepositoryDAO)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1