Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/**
*
* @author Deea
* @author Deea, (Doly)
*/
@Stateless
public class CommentBean {
Expand All @@ -33,8 +33,6 @@ public class CommentBean {
public List<CommentDetails> getAllComments(Integer interviewId) {
LOG.info("getAllComments");
try {
//List<Comment> comments = (List<Comment>) em.createQuery("SELECT c FROM Comment c WHERE ").getResultList();
//return comments;
TypedQuery<Comment> typedQuery = em.createQuery("SELECT c FROM Comment c WHERE c.interview.id = :id", Comment.class)
.setParameter("id", interviewId);
List<Comment> comments = (List<Comment>)typedQuery.getResultList();
Expand Down Expand Up @@ -72,7 +70,8 @@ public void createComment(String username, String comment_text, Integer intervie
interview.getComments().add(comment);
if(interview.getStatus()==InterviewStatus.APPLIED_FOR){
interview.setStatus(InterviewStatus.WAITING_INTERVIEW_DATE);
}
}//the status of the interview is updated when the interviewer
//writes the first comment
comment.setInterview(interview);

em.persist(comment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@

import com.recruit.jobrecruiting.comment.ejb.CommentBean;
import com.recruit.jobrecruiting.common.CommentDetails;
import com.recruit.jobrecruiting.common.InterviewDetails;
import com.recruit.jobrecruiting.entity.Interview;
import com.recruit.jobrecruiting.entity.User;
import com.recruit.jobrecruiting.interviews.ejb.InterviewBean;
import com.recruit.jobrecruiting.user.ejb.UserBean;
import com.recruit.jobrecruiting.validators.InterviewValidator;
import com.recruit.jobrecruiting.validators.UserValidator;
import java.io.IOException;
import java.io.PrintWriter;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.annotation.security.DeclareRoles;
Expand All @@ -33,9 +27,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
/**Servlet that manages comments and interview
* Linked to comment-section.jsp
*
* @author Deea
* @author Deea, Doly, Robert
*/
@DeclareRoles({"AdminRole", "CandidateRole", "DepartmentDirectorRole", "GeneralDirectorRole", "HRDirectorRole", "RecruiterRole"})
@ServletSecurity(value = @HttpConstraint(rolesAllowed={"AdminRole", "CandidateRole", "DepartmentDirectorRole", "GeneralDirectorRole", "HRDirectorRole", "RecruiterRole"}))
Expand Down Expand Up @@ -76,18 +71,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
String username=request.getRemoteUser();
User user=userBean.getUserByUsername(username);
// String jobpost=request.getParameter("jobpost");
// String candidate=request.getParameter("candidate");
// String interviewer=request.getParameter("interviewer");
// String status=request.getParameter("status");

User user=userBean.getUserByUsername(username);
request.getSession().setAttribute("id", id);
request.getSession().setAttribute("user", user);
// request.getSession().setAttribute("jobpost", jobpost);
// request.getSession().setAttribute("candidate", candidate);
// request.getSession().setAttribute("interviewer", interviewer);
// request.getSession().setAttribute("status", status);
List<CommentDetails> comments = commentBean.getAllComments(id);
Interview interview = interviewBean.getInterviewById(id);
request.getSession().setAttribute("comments", comments);
Expand All @@ -105,17 +91,11 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("PPPPPPPOOOOOOOSSSSSSSSSTTTTTTT");
System.out.println (request.getParameter("form"));

throws ServletException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
String formPosted = request.getParameter("form");

if(formPosted.contentEquals("schedule")){
System.out.println("SCHEDULE");
System.out.println (request.getParameter("date"));
System.out.println (request.getParameter("time"));
if(formPosted.equals("schedule")){
LocalDate interviewDate = LocalDate.parse(request.getParameter("date"));
LocalTime interviewTime = LocalTime.parse(request.getParameter("time"));
HashMap<String, String> messageBag = new HashMap<>();
Expand All @@ -128,18 +108,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
else{
request.setAttribute("errors", messageBag);
request.getRequestDispatcher("/WEB-INF/pages/interview/comment-section.jsp").include(request, response);
}

}
}
else{
if(formPosted.contentEquals("change")){

}
else{ //comment
String username = request.getRemoteUser();
String comment = request.getParameter("comment");
commentBean.createComment(username, comment, id);
}
else{ //comment
String username = request.getRemoteUser();
String comment = request.getParameter("comment");
commentBean.createComment(username, comment, id);
}

response.sendRedirect(request.getContextPath()+"/Comment?id="+id.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@
package com.recruit.jobrecruiting.interviews.ejb;

import com.recruit.jobrecruiting.common.InterviewDetails;
import com.recruit.jobrecruiting.common.UserDetails;
import com.recruit.jobrecruiting.jobPost.ejb.JobPostBean;
import com.recruit.jobrecruiting.entity.Interview;
import com.recruit.jobrecruiting.entity.InterviewStatus;
import com.recruit.jobrecruiting.entity.JobPost;
import com.recruit.jobrecruiting.entity.User;
import com.recruit.jobrecruiting.user.ejb.UserBean;
import com.recruit.jobrecruiting.util.Util;
import java.sql.Time;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;
import javax.ejb.EJBException;
Expand All @@ -32,7 +29,7 @@

/**
*
* @author Doly, robert, denisa
* @author Andrei, Doly, robert, denisa
*/
@Stateless
public class InterviewBean {
Expand All @@ -48,17 +45,21 @@ public class InterviewBean {
@PersistenceContext
private EntityManager em;

public List<InterviewDetails> getAllInterviewsAsInterviewer(Integer userId)///////////doar cele pt care s-a stabilit interviul
/**
* Gets all interviews for a specific interviewer.
*
* @param userId the id of the Interviewer
* @return Returns the list of interview details
*/
public List<InterviewDetails> getAllInterviewsAsInterviewer(Integer userId)
{
try {
TypedQuery<Interview> typedQuery = em.createQuery("SELECT i FROM Interview i WHERE (i.interviewer.id = :id AND i.status <> :st)", Interview.class)
.setParameter("id", userId).setParameter("st", InterviewStatus.APPLIED_FOR);
List<Interview> interviews = (List<Interview>) typedQuery.getResultList();
for(Interview interview:interviews){
if(interview.checkAfterInterview()){
interview.setStatus(InterviewStatus.AFTER_INTERVIEW);
// TypedQuery<Interview> setStatus = em.createQuery("SELECT i FROM Interview i WHERE (i.interviewer.id = :id AND i.status <> :st)", Interview.class)
// UPDATE Interview i SET i.
interview.setStatus(InterviewStatus.AFTER_INTERVIEW);
em.persist(interview);
}
}
Expand All @@ -69,6 +70,12 @@ public List<InterviewDetails> getAllInterviewsAsInterviewer(Integer userId)/////
}
}

/**
* Gets all interviews for a specific candidate.
*
* @param userId the id of the Candidate
* @return Returns the list of interview details
*/
public List<InterviewDetails> getAllInterviewsAsCandidate(Integer userId) {
try {
TypedQuery<Interview> typedQuery = em.createQuery("SELECT i FROM Interview i WHERE i.candidate.id = :id", Interview.class)
Expand All @@ -87,6 +94,12 @@ public List<InterviewDetails> getAllInterviewsAsCandidate(Integer userId) {
}
}

/**
* Gets all interview details for an Interview list.
*
* @param interviews the list of interview objects
* @return Returns the list of interview details
*/
private List<InterviewDetails> copyInterviewToDetails(List<Interview> interviews) {
List<InterviewDetails> detailsList = new ArrayList<>();
for (Interview interview : interviews) {
Expand Down Expand Up @@ -207,6 +220,12 @@ private InterviewDetails copyInterviewToDetails(Interview interview) {
return interviewDetails;
}

/**
* Gets an interview by its id.
*
* @param id the id of the interview
* @return Returns the interview object
*/
public Interview getInterviewById(Integer id) {
return em.find(Interview.class, id);
}
Expand All @@ -215,6 +234,13 @@ public LocalDateTime toDateTime(LocalDate date, LocalTime time){
return LocalDateTime.of(date, time);
}

/**
* Sets the dateTime attribute of an interview.
*
* @param id the id of the interview
* @param date when the interview is scheduled
* @param time when the interview is scheduled
*/
public void setDateTime(Integer id, LocalDate date, LocalTime time){
try {
Interview interview = em.find(Interview.class, id);
Expand All @@ -227,6 +253,12 @@ public void setDateTime(Integer id, LocalDate date, LocalTime time){
}
}

/**
* Sets the place of the recently scheduled interview.
*
* @param id
* @param place
*/
public void setPlace(Integer id, String place){
try {
Interview interview = em.find(Interview.class, id);
Expand All @@ -238,18 +270,4 @@ public void setPlace(Integer id, String place){
}
}

//trebuie in clasa Interview
// public Boolean checkAfterInterview(Interview interview){
// if((interview.getStatus()==InterviewStatus.BEFORE_INTERVIEW) && (LocalDate.now().isAfter(interview.getDate())))
// return Boolean.TRUE;
// return Boolean.FALSE;
// }

// private String getDateTime() {
// DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
// Date date = new Date();
// return dateFormat.format(date);
//}
// var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Math.Round(1372061224000 / 1000d)).ToLocalTime();
//Console.WriteLine(dt); // Prints: 6/24/2013 10:07:04 AM
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/**
*
* @author Doly
* @author Doly,...
*/
@Stateless
public class ViewCandidatesBean {
Expand All @@ -46,29 +46,13 @@ public List<InterviewDetails> getAllCandidates() {
.setParameter("interviewStatus", InterviewStatus.APPLIED_FOR);

List<Interview> candidates = (List<Interview>) typedQuery.getResultList();
// Query query = em.createQuery("SELECT i FROM Interviews i WHERE i.status = :interviewStatus")
// .setParameter("interviewStatusid", InterviewStatus.WAITING_INTERVIEW_DATE);

//List<Interview> candidates = (List<Interview>)query.getResultList();
List<InterviewDetails> x = copyCandidateToDetails(candidates);
return x;
} catch (Exception ex) {
throw new EJBException(ex);
}
}

// public List<InterviewDetails> getAllInterviewsAsCandidate(Integer userId)
// {
// try {
// TypedQuery<Interview> typedQuery = em.createQuery("SELECT i FROM interviews i WHERE i.candidate_key = :id", Interview.class)
// .setParameter("id", userId);
// List<Interview> interviews = (List<Interview>)typedQuery.getResultList();
// List<InterviewDetails> x = copyInterviewToDetails(interviews);
// return x;
// } catch (Exception ex) {
// throw new EJBException(ex);
// }
// }
private List<InterviewDetails> copyCandidateToDetails(List<Interview> candidates) {
List<InterviewDetails> detailsList = new ArrayList<>();
for (Interview candidate : candidates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package com.recruit.jobrecruiting.interviews.servlet;

import com.recruit.jobrecruiting.common.InterviewDetails;
import com.recruit.jobrecruiting.entity.Position;
import com.recruit.jobrecruiting.entity.User;
import com.recruit.jobrecruiting.interviews.ejb.InterviewBean;
import com.recruit.jobrecruiting.user.ejb.UserBean;
Expand All @@ -15,15 +14,18 @@
import java.util.List;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
*
* @author Doly
/**Servlet that manages the interviews to be transmitted to interviews.jsp
* Candidate access is forbidden!!!
* @author Andrei, Doly
*/
@ServletSecurity(value = @HttpConstraint(rolesAllowed={"AdminRole","DepartmentDirectorRole","GeneralDirectorRole","HRDirectorRole","RecruiterRole"}))
@WebServlet(name = "Interviews", urlPatterns = {"/Interviews"})
public class Interviews extends HttpServlet {

Expand Down Expand Up @@ -72,41 +74,13 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("INTERVIEWS.JAVA");
String username=request.getRemoteUser();
User user=userBean.getUserByUsername(username);
Integer userId=user.getId();
//String userId=request.getParameter("id");
//userId=request.
//Integer userIdInt=Integer.parseInt(userId);
//String requestedBy=request.getParameter("requestedBy");/////////////////////params

List<InterviewDetails> interviews; //!!!!!!!!schimbare light details
// if(request.isUserInRole("CandidateRole"))
// interviews = interviewBean.getAllInterviewsAsCandidate(userId);
// else
// interviews = interviewBean.getAllInterviewsAsInterviewer(userId);
// Boolean candidate=Boolean.FALSE;
// if(user.getPosition().compareTo(Position.CANDIDATE)==0)
// {
// interviews = interviewBean.getAllInterviewsAsCandidate(userId);
// candidate=Boolean.TRUE;
// }
// else
// interviews = interviewBean.getAllInterviewsAsInterviewer(userId);
// if (request.getPathInfo().compareTo("/Profile")==0)
// {
interviews=interviewBean.getAllInterviewsAsInterviewer(userId);
// }
// else
// {
// interviews = interviewBean.getAllInterviewsAsCandidate(userId);
// }

//interv as candidate


List<InterviewDetails> interviews;
interviews=interviewBean.getAllInterviewsAsInterviewer(userId);
request.getSession().setAttribute("interviews", interviews);
//request.getSession().setAttribute("candidate", candidate);
request.getRequestDispatcher("/WEB-INF/pages/interview/interviews.jsp").forward(request, response);

}
Expand All @@ -122,18 +96,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// String id=request.getParameter("id");
// String jobpost=request.getParameter("jobpost");
// String candidate=request.getParameter("candidate");
// String interviewer=request.getParameter("interviewer");
// String status=request.getParameter("status");
//
// request.getSession().setAttribute("id", id);
// request.getSession().setAttribute("jobpost", jobpost);
// request.getSession().setAttribute("candidate", candidate);
// request.getSession().setAttribute("interviewer", interviewer);
// request.getSession().setAttribute("status", status);
// request.getRequestDispatcher("/WEB-INF/pages/interview/comment-section.jsp").forward(request, response);

}

Expand Down
Loading