use of models.NotificationBean in project bil372-proje by mertserezli.
the class ProjectServlet method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
PrintWriter pw = response.getWriter();
UserBean currentUser = (UserBean) request.getSession().getAttribute("currentSessionUser");
String date = request.getParameter("date");
ProjectBean currentProject = (ProjectBean) request.getSession().getAttribute("currentProject");
if (date == null) {
pw.println("Date cannot be empty!");
return;
}
ArrayList<UserBean> workers = Work_Emp_ProDAO.getWorkers(currentProject);
boolean found = false;
for (UserBean worker : workers) {
if (!worker.getUsername().equals(currentUser.getUsername())) {
found = true;
break;
}
}
if (!found) {
pw.println("You cannot set up a meeting!");
return;
}
ProjectDAO.setNewMeeting(currentProject, date);
for (UserBean worker : workers) {
NotificationBean n = new NotificationBean();
n.setDate(Date);
n.setNotification("(Project)" + currentProject.getTitle() + " adli projenizde " + date + " tarihine bir meeting set edildi");
n.setUsername(worker.getUsername());
NotificationDAO.sendNotification(n);
}
}
use of models.NotificationBean in project bil372-proje by mertserezli.
the class ProjectServlet method doPost.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
String click = request.getParameter("click");
PrintWriter pw = response.getWriter();
if (click.equals("Add Employee")) {
String username = request.getParameter("username");
ProjectBean currentProject = (ProjectBean) request.getSession().getAttribute("currentProject");
UserBean user = new UserBean();
user.setUserName(username);
ProfileDAO.loadUser(user);
boolean success = Work_Emp_ProDAO.addEmployee(user, currentProject);
if (success) {
ArrayList<UserBean> workers = Work_Emp_ProDAO.getWorkers(currentProject);
for (UserBean u : workers) {
NotificationBean n = new NotificationBean();
n.setDate(Date);
n.setNotification("(Project)-" + username + " adlı calisan" + currentProject.getTitle() + " adli projenize eklendi");
n.setUsername(u.getUsername());
NotificationDAO.sendNotification(n);
}
pw.println("New Employee has been added");
} else {
pw.println("New Employee could not be added");
}
} else if (click.equals("Add Comment")) {
UserBean user = (UserBean) request.getSession().getAttribute("currentuser");
ProjectBean currentProject = (ProjectBean) request.getSession().getAttribute("currentProject");
String content = request.getParameter("content");
CommentBean comment = new CommentBean();
comment.setContent(content);
comment.setPid(currentProject.getPid());
comment.setUsername(user.getUsername());
boolean success = CommentsDAO.addComment(currentProject, user, comment);
if (success) {
ArrayList<UserBean> workers = Work_Emp_ProDAO.getWorkers(currentProject);
for (UserBean u : workers) {
NotificationBean n = new NotificationBean();
n.setDate(Date);
n.setNotification("(Project)-" + user.getUsername() + " adli kullanici " + currentProject.getTitle() + " adli projenize yorum yapti");
n.setUsername(u.getUsername());
NotificationDAO.sendNotification(n);
}
pw.println("New Comment has been added");
} else {
pw.println("New Comment could not be added");
}
} else if (click.equals("upvote")) {
ProjectBean currentProject = (ProjectBean) request.getSession().getAttribute("currentProject");
boolean success = ProjectDAO.upvote(currentProject);
if (success) {
pw.println("Upvoted Project");
} else {
pw.println("Could not upvote Project");
}
} else if (click.equals("downvote")) {
ProjectBean currentProject = (ProjectBean) request.getSession().getAttribute("currentProject");
boolean success = ProjectDAO.downvote(currentProject);
if (success) {
pw.println("Downvoted Project");
} else {
pw.println("Could not Downvote Project");
}
}
}
use of models.NotificationBean 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.NotificationBean in project bil372-proje by mertserezli.
the class NotificationDAO method getUpcomingDeadlines.
public static List<NotificationBean> getUpcomingDeadlines(String usernameRequest) throws SQLException {
List<NotificationBean> result = new ArrayList<NotificationBean>();
java.sql.Date dateNow = new java.sql.Date(Calendar.getInstance().getTime().getTime());
List<TaskBean> tasks = TaskDAO.searchTasksForUser(usernameRequest);
for (TaskBean t : tasks) {
Date d = t.getDeadline();
if (d.getYear() == dateNow.getYear() && d.getMonth() == dateNow.getMonth() && d.getDay() - dateNow.getDay() <= 7) {
int day = d.getDay() - dateNow.getDay();
NotificationBean n = new NotificationBean();
n.setDate(dateNow);
n.setUsername(usernameRequest);
n.setNotification("(Task) " + t.getTitle() + " adli taskinizin " + d + " tarihli deadline tarihine " + day + " gün kalmistir");
result.add(n);
}
}
return result;
}
use of models.NotificationBean in project bil372-proje by mertserezli.
the class NotificationDAO method getNotifications.
public static List<NotificationBean> getNotifications(String usernameRequest) throws SQLException {
List<NotificationBean> result = new ArrayList<NotificationBean>();
String searchQuery = "Select * From emp_notification where username=?";
try {
ConnectionManager connect = new ConnectionManager();
currentConnection = connect.getConnection();
ps = currentConnection.prepareStatement(searchQuery);
ps.setString(1, usernameRequest);
rs = ps.executeQuery();
while (rs.next()) {
NotificationBean n = new NotificationBean();
n.setNid(rs.getInt("nid"));
n.setNotification(rs.getString("notification"));
n.setUsername(rs.getString("username"));
n.setDate(rs.getDate("date"));
result.add(n);
}
} finally {
finalizeConnection(currentConnection, ps, rs);
}
return result;
}
Aggregations