Search in sources :

Example 6 with TaskBean

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

the class TaskDAO method getChildTasks.

public static ArrayList<TaskBean> getChildTasks(TaskBean parentTask) {
    PreparedStatement ps = null;
    String searchQuery = "select * from TASK where tid in (select tid from PREREQU_TASK where pretid=?)";
    ArrayList<TaskBean> result = new ArrayList<TaskBean>();
    try {
        ConnectionManager connect = new ConnectionManager();
        currentConnection = connect.getConnection();
        ps = currentConnection.prepareStatement(searchQuery);
        ps.setInt(1, parentTask.getTid());
        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 7 with TaskBean

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

the class TaskTreeServlet method appendChilds.

private String appendChilds(TaskBean parentTask, String html) {
    ArrayList<UserBean> employees = TaskDAO.getEmployeesWorksOn(parentTask);
    ArrayList<TaskBean> childTasks = TaskDAO.getChildTasks(parentTask);
    html += "<li>";
    html += "<a href=\"Task?tid=" + parentTask.getTid() + "\" class=\"task\">" + parentTask.getTid() + " " + parentTask.getTitle() + "</a>";
    if (!employees.isEmpty() || !childTasks.isEmpty())
        html += "<ul>";
    if (!employees.isEmpty()) {
        for (UserBean employee : employees) {
            html += "<li>" + "<a href=profile.jsp?username=" + employee.getUsername() + " class=\"employee\">" + employee.getUsername() + "</a> </li>";
        }
    }
    if (!childTasks.isEmpty()) {
        for (TaskBean task : childTasks) {
            html = appendChilds(task, html);
        }
    }
    html += "</li>";
    if (!employees.isEmpty() || !childTasks.isEmpty())
        html += "</ul>";
    return html;
}
Also used : UserBean(models.UserBean) TaskBean(models.TaskBean)

Example 8 with TaskBean

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

the class TaskTreeServlet method getTreeHTML.

private String getTreeHTML(ProjectBean project) {
    String html = "";
    ArrayList<TaskBean> roots = TaskDAO.getRootTasks(project);
    // for every prerequisite=null task(not prerequisite of anything) do
    for (TaskBean task : roots) {
        html += "<div class=\"tree\"> <ul>";
        // get tasks and employees that is child of that task(recursive)
        html = appendChilds(task, html);
        // return string
        html += "</ul> </div>";
    }
    return html;
}
Also used : TaskBean(models.TaskBean)

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