Search in sources :

Example 6 with ProjectBean

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;
}
Also used : ProjectBean(models.ProjectBean) ArrayList(java.util.ArrayList)

Example 7 with ProjectBean

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

Example 8 with ProjectBean

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();
    }
}
Also used : ProjectBean(models.ProjectBean) ServletException(javax.servlet.ServletException) PrintWriter(java.io.PrintWriter)

Example 9 with ProjectBean

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;
}
Also used : ProjectBean(models.ProjectBean) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement)

Example 10 with ProjectBean

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;
}
Also used : ProjectBean(models.ProjectBean)

Aggregations

ProjectBean (models.ProjectBean)11 ArrayList (java.util.ArrayList)6 UserBean (models.UserBean)5 PrintWriter (java.io.PrintWriter)4 PreparedStatement (java.sql.PreparedStatement)3 ServletException (javax.servlet.ServletException)3 NotificationBean (models.NotificationBean)3 IOException (java.io.IOException)1 Date (java.sql.Date)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletContext (javax.servlet.ServletContext)1 CommentBean (models.CommentBean)1 CompanyBean (models.CompanyBean)1