use of models.ProjectBean 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.ProjectBean 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.ProjectBean in project bil372-proje by mertserezli.
the class SearchServlet method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
String searchType = request.getParameter("searchType");
String toSearch = request.getParameter("searchBar");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
if (searchType.equals("users")) {
List<UserBean> users = null;
String category = request.getParameter("userCategory");
if (category.equals("username")) {
try {
users = SearchDAO.searchForUser(toSearch);
} catch (SQLException e) {
throw new ServletException("Error when getting users from DB", e);
}
} else if (category.equals("jobtitle")) {
try {
users = SearchDAO.searchForUserJobTitle(toSearch);
} catch (SQLException e) {
throw new ServletException("Error when getting users from DB", e);
}
} else if (category.equals("qualifications")) {
try {
users = SearchDAO.searchForUserWithQualifications(toSearch);
} catch (SQLException e) {
throw new ServletException("Error when getting users from DB", e);
}
}
for (UserBean u : users) {
pw.println("<a href=\"profile.jsp?username=" + u.getUsername() + "\"style=\"display:block\">" + u.getUsername() + "</a>");
}
} else if (searchType.equals("projects")) {
List<ProjectBean> projects = null;
String category = request.getParameter("projectCategory");
if (category.equals("title")) {
try {
projects = SearchDAO.searchForProject(toSearch);
} catch (SQLException e) {
throw new ServletException("Error when getting projects from DB", e);
}
} else if (category.equals("description")) {
try {
projects = SearchDAO.searchForProjectDescription(toSearch);
} catch (SQLException e) {
throw new ServletException("Error when getting projects from DB", e);
}
} else if (category.equals("tags")) {
try {
projects = SearchDAO.searchForProjectWithTags(toSearch);
} catch (SQLException e) {
throw new ServletException("Error when getting projects from DB", e);
}
}
for (ProjectBean p : projects) {
pw.println("<a href=\"project.jsp?pid=" + p.getPid() + "\"style=\"display:block\">" + p.getTitle() + "</a>");
}
} else if (searchType.equals("companies")) {
List<CompanyBean> companies = null;
String category = request.getParameter("companyCategory");
if (category.equals("name")) {
try {
companies = SearchDAO.searchForCompany(toSearch);
} catch (SQLException e) {
throw new ServletException("Error when getting companies from DB", e);
}
} else if (category.equals("description")) {
try {
companies = SearchDAO.searchForCompanyDescription(toSearch);
} catch (SQLException e) {
throw new ServletException("Error when getting companies from DB", e);
}
}
for (CompanyBean c : companies) {
pw.println("<a href=\"company.jsp?name=" + c.getName() + "\"style=\"display:block\">" + c.getName() + "</a>");
}
}
}
use of models.ProjectBean in project bil372-proje by mertserezli.
the class TaskTreeServlet method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
ProjectBean project = new ProjectBean();
RequestDispatcher dispatcher;
ServletContext context = getServletContext();
int pid = Integer.parseInt(request.getParameter("pid"));
project.setPid(pid);
try {
project = ProjectDAO.getProject(project);
if (!project.getTitle().equals("Project Not Found")) {
String tree = getTreeHTML(project);
ArrayList<UserBean> employeeList = ProjectDAO.getEmployees(project);
request.setAttribute("employeeList", employeeList);
request.setAttribute("tree", tree);
request.setAttribute("project", project);
dispatcher = context.getNamedDispatcher("taskTree");
dispatcher.forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of models.ProjectBean in project bil372-proje by mertserezli.
the class SearchDAO method searchForProjectWithTags.
public static List<ProjectBean> searchForProjectWithTags(String tagsRequest) throws SQLException {
List<ProjectBean> result = new ArrayList<ProjectBean>();
PreparedStatement ps = null;
String searchQuery = "Select DISTINCT * From Project Where ";
String[] tRequests = tagsRequest.split(",");
for (String s : tRequests) {
searchQuery += "'" + s + "'=ANY(tags)";
if (!s.equals(tRequests[tRequests.length - 1]))
searchQuery += " AND ";
}
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;
}
Aggregations