use of models.UserBean in project bil372-proje by mertserezli.
the class UploadServlet method doPost.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
response.setContentType("text/html;charset=UTF-8");
Part part = request.getPart("file");
String fileName = extractFileName(part);
part.write(path + File.separator + fileName);
UserBean current = (UserBean) request.getSession().getAttribute("currentSessionUser");
current.setImage(fileName);
UploadDAO.uploadImage(current);
response.sendRedirect("profile.jsp?username=" + current.getUsername());
}
use of models.UserBean in project bil372-proje by mertserezli.
the class SearchDAO method searchForUserJobTitle.
public static List<UserBean> searchForUserJobTitle(String jobtitleRequest) throws SQLException {
List<UserBean> result = new ArrayList<UserBean>();
PreparedStatement ps = null;
String searchQuery = "Select DISTINCT * From EMPLOYEE Where UPPER(Jobtitle) LIKE UPPER('%" + jobtitleRequest + "%')";
try {
ConnectionManager connect = new ConnectionManager();
currentConnection = connect.getConnection();
ps = currentConnection.prepareStatement(searchQuery);
rs = ps.executeQuery();
while (rs.next()) {
UserBean user = new UserBean();
user.setUserName(rs.getString("Username"));
user.setPassword(rs.getString("Password"));
user.setJobTitle(rs.getString("JobTitle"));
user.setImage(rs.getString("Image"));
user.setFirstName(rs.getString("FirstName"));
user.setMiddleName(rs.getString("MiddleName"));
user.setLastName(rs.getString("LastName"));
user.setEmail(rs.getString("Email"));
user.setValid(true);
result.add(user);
}
} finally {
finalizeConnection(currentConnection, ps, rs);
}
return result;
}
use of models.UserBean in project bil372-proje by mertserezli.
the class TaskDAO method getEmployeesWorksOn.
public static ArrayList<UserBean> getEmployeesWorksOn(TaskBean task) {
PreparedStatement ps = null;
String searchQuery = "select * from WORK_TASK_EMP w, EMPLOYEE e where w.tid=? AND w.username=e.username";
ArrayList<UserBean> result = new ArrayList<UserBean>();
try {
ConnectionManager connect = new ConnectionManager();
currentConnection = connect.getConnection();
ps = currentConnection.prepareStatement(searchQuery);
ps.setInt(1, task.getTid());
rs = ps.executeQuery();
while (rs.next()) {
UserBean employee = new UserBean();
employee.setUserName(rs.getString("username"));
employee.setEmail(rs.getString("email"));
employee.setFirstName(rs.getString("firstname"));
employee.setJobTitle(rs.getString("jobtitle"));
employee.setLastName(rs.getString("lastname"));
employee.setMiddleName(rs.getString("middlename"));
result.add(employee);
}
} catch (Exception ex) {
System.out.println("Failed: An Exception has occurred! " + ex);
} finally {
finalizeConnection(currentConnection, ps, rs);
}
return result;
}
use of models.UserBean in project bil372-proje by mertserezli.
the class Work_Emp_ProDAO method getWorkers.
public static ArrayList<UserBean> getWorkers(ProjectBean project) {
ArrayList<UserBean> workers = new ArrayList<>();
int pid = project.getPid();
String query = "select username from work_emp_pro where pid=?";
try {
connect = new ConnectionManager();
currentConnection = connect.getConnection();
ps = currentConnection.prepareStatement(query);
ps.setInt(1, pid);
rs = ps.executeQuery();
while (rs.next()) {
UserBean worker = new UserBean();
worker.setUserName(rs.getString("username"));
workers.add(worker);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
finalizeConnection(currentConnection, ps, rs);
}
return workers;
}
use of models.UserBean 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;
}
Aggregations