package dataaccess;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
public class CVS_revision {
private String m_revision_id = null;
private long m_revision_modul_id;
private Date m_revision_date;
private String m_revision_author_name;
private long m_revision_user_id;
private final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
public CVS_revision(String mRevisionId, long mRevisionModulId,
Date mRevisionDate, String mRevisionAuthorName, long mRevisionUserId) {
super();
m_revision_id = mRevisionId;
m_revision_modul_id = mRevisionModulId;
m_revision_date = mRevisionDate;
m_revision_author_name = mRevisionAuthorName;
m_revision_user_id = mRevisionUserId;
}
public static LinkedList<CVS_revision> getRevisions(long modul_id, Date begin, Date end)
{
MysqlDataSource l_ds = DBAccess.ReturnDataSource();
Connection l_con = null;
Statement l_stat = null;
LinkedList<CVS_revision> l_revisions = new LinkedList<CVS_revision>();
try
{
l_con = l_ds.getConnection();
l_stat = l_con.createStatement();
String str ="select revision_id, revision_modul_id, from_unixtime(revision_date) revision_date, revision_author_name, revision_user_id "+
" from cvs_revision where revision_modul_id = " + modul_id + " and from_unixtime(revision_date) > '" +df.format(begin)
+ "' and from_unixtime(revision_date) < '"+ df.format(end) +"' and revision_user_id <> 0";
ResultSet s = l_stat.executeQuery("select revision_id, revision_modul_id, from_unixtime(revision_date) revision_date, revision_author_name, revision_user_id "+
" from cvs_revision where revision_modul_id = " + modul_id + " and from_unixtime(revision_date) > '" +df.format(begin)
+ "' and from_unixtime(revision_date) < '"+ df.format(end) +"' and revision_user_id <> 0");
while (s.next())
{
try
{
CVS_revision l_rev = new CVS_revision(s.getString("revision_id"), s.getLong("revision_modul_id"), s.getDate("revision_date"),
s.getString("revision_author_name"), s.getLong("revision_user_id"));
l_revisions.add(l_rev);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
try {
l_stat.close();
l_con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
catch (Exception e)
{
return null;
}
return l_revisions;
}
/**
* Getters and Setters
* @return
*/
public String getM_revision_id() {
return m_revision_id;
}
public void setM_revision_id(String mRevisionId) {
m_revision_id = mRevisionId;
}
public long getM_revision_modul_id() {
return m_revision_modul_id;
}
public void setM_revision_modul_id(long mRevisionModulId) {
m_revision_modul_id = mRevisionModulId;
}
public Date getM_revision_date() {
return m_revision_date;
}
public void setM_revision_date(Date mRevisionDate) {
m_revision_date = mRevisionDate;
}
public String getM_revision_author_name() {
return m_revision_author_name;
}
public void setM_revision_author_name(String mRevisionAuthorName) {
m_revision_author_name = mRevisionAuthorName;
}
public long getM_revision_user_id() {
return m_revision_user_id;
}
public void setM_revision_user_id(long mRevisionUserId) {
m_revision_user_id = mRevisionUserId;
}
}