forked from eggnet/com2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
1 addition
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,6 @@ | ||
package db; | ||
|
||
import java.sql.Date; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Timestamp; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import comm.ComResources; | ||
|
||
import models.Commit; | ||
|
||
public class LinkerDb extends TechnicalDb | ||
{ | ||
public LinkerDb() { } | ||
|
||
public Set<Commit> getAllCommits() | ||
{ | ||
Set<Commit> commits = new HashSet<Commit>(); | ||
|
||
try { | ||
String sql = "SELECT commit_id, author, author_email, comments, commit_date, branch_id from commits where (branch_id is NULL OR branch_id=?)"; | ||
String[] parms = {branchID}; | ||
ResultSet rs = execPreparedQuery(sql, parms); | ||
while(rs.next()) | ||
{ | ||
commits.add(new Commit( | ||
rs.getString("commit_id"), | ||
rs.getString("author"), | ||
rs.getString("author_email"), | ||
rs.getString("comments"), | ||
rs.getTimestamp("commit_date"), | ||
rs.getString("branch_id") | ||
)); | ||
} | ||
} | ||
catch(SQLException e) | ||
{ | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
return commits; | ||
} | ||
|
||
public List<String> getFilesPathChangedOnCommit(Commit commit) { | ||
try { | ||
List<String> files = new ArrayList<String>(); | ||
String sql = "SELECT distinct file_id FROM file_diffs WHERE" + | ||
" new_commit_id=?"; | ||
String[] parms = {commit.getCommit_id()}; | ||
ResultSet rs = execPreparedQuery(sql, parms); | ||
while(rs.next()) | ||
{ | ||
files.add(rs.getString("file_id")); | ||
} | ||
return files; | ||
} | ||
catch(SQLException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
public List<String> getFilesAdded(String commitID) { | ||
try | ||
{ | ||
LinkedList<String> files = new LinkedList<String>(); | ||
String sql = "SELECT file_id, diff_type FROM file_diffs " + | ||
"WHERE new_commit_id=?"; | ||
String[] parms = {commitID}; | ||
ResultSet rs = execPreparedQuery(sql, parms); | ||
while(rs.next()) | ||
{ | ||
if(rs.getString("diff_type").equals("DIFF_ADD") && !files.contains(rs.getString("file_id"))) | ||
files.add(rs.getString("file_id")); | ||
} | ||
return files; | ||
} | ||
catch(SQLException e) | ||
{ | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
public List<String> getFilesDeleted(String commitID) { | ||
try | ||
{ | ||
LinkedList<String> files = new LinkedList<String>(); | ||
String sql = "SELECT file_id, diff_type FROM file_diffs " + | ||
"WHERE new_commit_id=?"; | ||
String[] parms = {commitID}; | ||
ResultSet rs = execPreparedQuery(sql, parms); | ||
while(rs.next()) | ||
{ | ||
if(rs.getString("diff_type").equals("DIFF_DELETE") && !files.contains(rs.getString("file_id"))) | ||
files.add(rs.getString("file_id")); | ||
} | ||
return files; | ||
} | ||
catch(SQLException e) | ||
{ | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
} |