use of models.ProjectBean in project bil372-proje by mertserezli.
the class UploadDAO method loadProjects.
public static ArrayList<ProjectBean> loadProjects(UserBean user) {
ArrayList<ProjectBean> projects = new ArrayList<>();
ArrayList<Integer> projectIDs = new ArrayList<>();
String username = user.getUsername();
String SearchWork_Emp_Pro = "select pid from work_emp_pro where username=?";
String SearchProject = "select * from project where pid=?";
try {
ConnectionManager connect = new ConnectionManager();
currentConnection = connect.getConnection();
ps = currentConnection.prepareStatement(SearchWork_Emp_Pro);
ps.setString(1, username);
rs = ps.executeQuery();
while (rs.next()) {
projectIDs.add(rs.getInt("pid"));
}
ps = currentConnection.prepareStatement(SearchProject);
for (int pid : projectIDs) {
ps = currentConnection.prepareStatement(SearchProject);
ps.setInt(1, pid);
rs = ps.executeQuery();
while (rs.next()) {
ProjectBean project = new ProjectBean();
project.setPid(rs.getInt("pid"));
project.setState(rs.getString("state"));
project.setTitle(rs.getString("title"));
project.setDescription(rs.getString("description"));
project.setCreation_Date(rs.getDate("creation_date"));
project.setVotenum(rs.getInt("votenum"));
projects.add(project);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
finalizeConnection(currentConnection, ps, rs);
}
return projects;
}
use of models.ProjectBean in project bil372-proje by mertserezli.
the class NotificationDAO method getUpcomingMeetings.
public static List<NotificationBean> getUpcomingMeetings(String usernameRequest) {
List<NotificationBean> result = new ArrayList<NotificationBean>();
java.sql.Date dateNow = new java.sql.Date(Calendar.getInstance().getTime().getTime());
UserBean user = new UserBean();
user.setUserName(usernameRequest);
ArrayList<ProjectBean> projects = UploadDAO.loadProjects(user);
for (ProjectBean p : projects) {
ProjectDAO.getProject(p);
if (p.getMeeting_dates() != null) {
for (Date d : p.getMeeting_dates()) {
if (dateNow.getMonth() == d.getMonth() && dateNow.getYear() == d.getYear() && d.getDay() - dateNow.getDay() <= 7) {
int day = d.getDay() - dateNow.getDay();
NotificationBean n = new NotificationBean();
n.setDate(dateNow);
n.setNotification("(Project) " + p.getTitle() + " adli projenizin " + d + " tarihli meetingine " + day + " gün kalmistir");
n.setUsername(usernameRequest);
result.add(n);
}
}
}
}
return result;
}
use of models.ProjectBean in project bil372-proje by mertserezli.
the class NewProjectServlet method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
try {
PrintWriter pw = response.getWriter();
ProjectBean project = new ProjectBean();
project.setTitle(request.getParameter("title"));
project.setDescription(request.getParameter("description"));
String[] tags = request.getParameter("tags").split(",");
project.setTags(tags);
boolean success = ProjectDAO.createProject(project, (UserBean) request.getSession().getAttribute("currentSessionUser"));
if (success) {
pw.println("New Project Successfully Created");
return;
}
pw.println("New Project Could Not Be Created");
} catch (Exception e) {
e.printStackTrace();
}
}
use of models.ProjectBean in project bil372-proje by mertserezli.
the class SearchDAO method searchForProject.
public static List<ProjectBean> searchForProject(String projectRequest) throws SQLException {
List<ProjectBean> result = new ArrayList<ProjectBean>();
PreparedStatement ps = null;
String searchQuery = "Select DISTINCT * From PROJECT Where UPPER(Title) LIKE UPPER('%" + projectRequest + "%')";
try {
ConnectionManager connect = new ConnectionManager();
currentConnection = connect.getConnection();
ps = currentConnection.prepareStatement(searchQuery);
rs = ps.executeQuery();
while (rs.next()) {
ProjectBean project = new ProjectBean();
project.setTitle(rs.getString("Title"));
project.setDescription(rs.getString("Description"));
project.setPid(rs.getInt("Pid"));
project.setState(rs.getString("State"));
project.setVotenum(rs.getInt("Votenum"));
project.setCreation_Date(rs.getDate("Creation_Date"));
result.add(project);
}
} finally {
finalizeConnection(currentConnection, ps, rs);
}
return result;
}
use of models.ProjectBean in project bil372-proje by mertserezli.
the class ProfileLoader method GetProjects.
public static String GetProjects(UserBean user) {
String html = "";
ArrayList<ProjectBean> projects = UploadDAO.loadProjects(user);
for (ProjectBean project : projects) {
html += "<a href=\"project.jsp?pid=" + project.getPid() + "\"style=\"display:block\">" + project.getTitle() + "</a>";
}
return html;
}
Aggregations