Search in sources :

Example 1 with TaskBean

use of models.TaskBean in project bil372-proje by mertserezli.

the class TaskDescriptionServlet method doGet.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    TaskBean task = new TaskBean();
    RequestDispatcher dispatcher;
    ServletContext context = getServletContext();
    int tid = Integer.parseInt(request.getParameter("tid"));
    task.setTid(tid);
    try {
        task = TaskDAO.getTask(task);
        request.setAttribute("task", task);
        dispatcher = context.getNamedDispatcher("task");
        dispatcher.forward(request, response);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ServletContext(javax.servlet.ServletContext) TaskBean(models.TaskBean) RequestDispatcher(javax.servlet.RequestDispatcher) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 2 with TaskBean

use of models.TaskBean in project bil372-proje by mertserezli.

the class TaskTreeServlet method doPost.

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    String action = req.getParameter("action");
    if (action.equals("addEmpToTask")) {
        int tid = Integer.parseInt(req.getParameter("tid"));
        String username = req.getParameter("username");
        boolean success = TaskDAO.addEmpToTask(username, tid);
        if (success)
            res.getWriter().append("Employee added succesfully");
    } else if (action.equals("addPreToTask")) {
        int ptid = Integer.parseInt(req.getParameter("ptid"));
        int ctid = Integer.parseInt(req.getParameter("ctid"));
        TaskDAO.addPreToTask(ptid, ctid);
        res.getWriter().append("Task prerequisite added succesfully");
    } else if (action.equals("addTask")) {
        TaskBean task = new TaskBean();
        task.setTitle(req.getParameter("title"));
        task.setDescription(req.getParameter("description"));
        task.setPerformanceCriteria(req.getParameter("criteria"));
        int upperbound = Integer.parseInt(req.getParameter("upperbound"));
        task.setPerformanceUpperbound(upperbound);
        String deadline = req.getParameter("deadline");
        String day = deadline.substring(0, deadline.indexOf("."));
        deadline = deadline.substring(deadline.indexOf(".") + 1);
        String month = deadline.substring(0, deadline.indexOf("."));
        deadline = deadline.substring(deadline.indexOf(".") + 1);
        String year = deadline;
        Date deadlineDate = new Date(Integer.parseInt(year) - 1900, Integer.parseInt(month) - 1, Integer.parseInt(day));
        task.setDeadline(deadlineDate);
        int pid = Integer.parseInt(req.getParameter("pid"));
        task.setPid(pid);
        TaskDAO.addTask(task);
        res.getWriter().append("Task added successfully");
    } else if (action.equals("deleteTask")) {
        int tid = Integer.parseInt(req.getParameter("tid"));
        TaskDAO.deleteTask(tid);
        res.getWriter().append("Task deleted successfully");
    } else if (action.equals("removeEmployee")) {
        int tid = Integer.parseInt(req.getParameter("tid"));
        String username = req.getParameter("username");
        TaskDAO.removeEmployee(tid, username);
        res.getWriter().append("Employee removed successfully");
    }
}
Also used : TaskBean(models.TaskBean) Date(java.sql.Date)

Example 3 with TaskBean

use of models.TaskBean in project bil372-proje by mertserezli.

the class TaskDAO method searchTasksForUser.

public static List<TaskBean> searchTasksForUser(String usernameRequest) throws SQLException {
    List<TaskBean> tasks = new ArrayList<TaskBean>();
    String searchQuery = "Select * From work_task_emp INNER JOIN task ON work_task_emp.tid=task.tid Where username='" + usernameRequest + "'";
    // deadline";// TODO: rewrite sql
    try {
        ConnectionManager connect = new ConnectionManager();
        currentConnection = connect.getConnection();
        ps = currentConnection.prepareStatement(searchQuery);
        // ps.setString(1, username);
        rs = ps.executeQuery();
        while (rs.next()) {
            TaskBean task = new TaskBean();
            // task.setUsername(username);
            task.setTid(rs.getInt("tid"));
            task.setPid(rs.getInt("pid"));
            task.setDescription(rs.getString("description"));
            task.setPerformanceCriteria(rs.getString("performancecriteria"));
            task.setPerformanceUpperbound(rs.getInt("performanceupperbound"));
            task.setPerfromanceValue(rs.getInt("performancevalue"));
            task.setDeadline(rs.getDate("deadline"));
            // task.setPrerequisite(rs.getInt("PRETID"));
            tasks.add(task);
        }
    } catch (Exception e) {
        e.printStackTrace();
        return tasks;
    } finally {
        finalizeConnection(currentConnection, ps, rs);
    }
    return tasks;
}
Also used : ArrayList(java.util.ArrayList) TaskBean(models.TaskBean)

Example 4 with TaskBean

use of models.TaskBean in project bil372-proje by mertserezli.

the class TaskDAO method getRootTasks.

public static ArrayList<TaskBean> getRootTasks(ProjectBean project) {
    PreparedStatement ps = null;
    String searchQuery = "select * from TASK as t where t.pid=? and NOT EXISTS(select * from prerequ_task as p where t.tid=p.tid)";
    ArrayList<TaskBean> result = new ArrayList<TaskBean>();
    try {
        ConnectionManager connect = new ConnectionManager();
        currentConnection = connect.getConnection();
        ps = currentConnection.prepareStatement(searchQuery);
        ps.setInt(1, project.getPid());
        rs = ps.executeQuery();
        while (rs.next()) {
            TaskBean task = new TaskBean();
            int tid = rs.getInt("tid");
            String title = rs.getString("title");
            String Description = rs.getString("description");
            task.setTid(tid);
            task.setTitle(title);
            task.setDescription(Description);
            result.add(task);
        }
    } catch (Exception ex) {
        System.out.println("Failed: An Exception has occurred! " + ex);
    } finally {
        finalizeConnection(currentConnection, ps, rs);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) TaskBean(models.TaskBean)

Example 5 with TaskBean

use of models.TaskBean 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;
}
Also used : NotificationBean(models.NotificationBean) ArrayList(java.util.ArrayList) TaskBean(models.TaskBean) Date(java.sql.Date) Date(java.sql.Date)

Aggregations

TaskBean (models.TaskBean)8 ArrayList (java.util.ArrayList)4 Date (java.sql.Date)2 IOException (java.io.IOException)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletContext (javax.servlet.ServletContext)1 ServletException (javax.servlet.ServletException)1 NotificationBean (models.NotificationBean)1 UserBean (models.UserBean)1