-
Notifications
You must be signed in to change notification settings - Fork 0
/
HRCoordinator.java
159 lines (148 loc) · 6.69 KB
/
HRCoordinator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Scanner;
class HRCoordinator extends User implements Serializable {
private int company;
HRCoordinator(String name1, String password1) {
super(name1, password1);
}
HRCoordinator(String name1, String password1, int Company1, HRCoordinatorManager manager, Database d) {
super(name1, password1);
this.company = Company1;
manager.addCoordinator(this);
d.saveAllHRCoordinators(manager);
}
/**
* Method called when HRCoordinator logs in. Checks if there are any job postings that must be manually filled and
* then prompts the user to fill it.
*/
void logged_in(CompanyManager c, JobPostingManager j, ApplicantManager a) {
ArrayList<JobPosting> jobPostings = j.getJobPostings();
for (JobPosting jobPosting : jobPostings) {
if (jobPosting.getShouldManuallyFill()) {
jobPosting.manuallyFill(a);
}
}
}
/**
* Assign interviewers for a closed job posting. This action cannot be canceled.
*/
void assignInterviewers(JobPostingManager jpm, ApplicantManager a, InterviewerManager interviewerManager, CompanyManager companyManager) {
// assign interviewers from this company to all the applicants of a certain job posting at this company.
JobPosting jobPosting = this.selectClosedPosting(jpm, companyManager);
if (jobPosting == null) {
return;
}
CompanyArchives archives = companyManager.getCompanybyID(company).getArchives();
VerifyInput verifyInput = new VerifyInput();
archives.printInterviewers(interviewerManager);
for (Application application : jobPosting.getCurrentApplications()) {
application.read(a);
System.out.println("Enter an Interviewer's ID to assign to this application or -1 to go back.");
int interviewer = verifyInput.getValidNumber();
if (interviewer == -1) {
return;
}
while (!archives.hasInterviewer(interviewer)) {
System.out.println("Your company does not have that interviewer/ interviewer does not exist.");
interviewer = verifyInput.getValidNumber();
if (interviewer == -1) {
return;
}
}
Interviewer interviewer1 = interviewerManager.getInterviewer(interviewer);
interviewer1.assignApplicant(application.getId());
System.out.println("Interviewer assigned to this application.");
}
System.out.println("All applications have been assigned to an interviewer.");
}
/**
* Access applicant information for all applications in one job posting
*/
void accessApplicantInfo(ApplicantManager a, JobPostingManager b, CompanyManager companyManager) {
// access the information of an applicant (CV from applicant as well as cover letter).
VerifyInput verify = new VerifyInput();
Company company = companyManager.getCompanybyID(this.company);
CompanyArchives archives = company.getArchives();
ArrayList<Integer> Jps = new ArrayList<>();
for (JobPosting jobPosting : b.getJobPostings()) {
if (archives.hasJobPosting(jobPosting.getId())) {
Jps.add(jobPosting.getId());
System.out.println(jobPosting);
}
}
System.out.println("Please enter id for the job posting to access its current applicants' information or -1 to go back.");
int input = verify.getValidNumber();
if (input == -1) {
return;
}
while (!Jps.contains(input)) {
System.out.println("This job posting is not made by your company/ does not exist." +
" Please try again.");
input = verify.getValidNumber();
if (input == -1) {
return;
}
}
JobPosting jobPosting = b.getJobPosting(input);
jobPosting.readAllApplications(a);
}
/**
* Access applicant information for the hired applicant of a filled job posting
*/
void accessHiredApplicantInfo(ApplicantManager manager, JobPostingManager jobPostingManager, CompanyManager companyManager) {
VerifyInput verify = new VerifyInput();
Company company = companyManager.getCompanybyID(this.company);
CompanyArchives archives = company.getArchives();
ArrayList<Integer> Jps = new ArrayList<>();
for (JobPosting jobPosting : jobPostingManager.getJobPostings()) {
if (archives.hasJobPosting(jobPosting.getId()) && jobPosting.isFilled()) {
Jps.add(jobPosting.getId());
System.out.println(jobPosting);
}
}
System.out.println("Please enter id for the job posting to access its hired applicant's information or -1 to go back.");
int input = verify.getValidNumber();
if (input == -1) {
return;
}
while (!Jps.contains(input)) {
System.out.println("This job posting is not a valid choice." +
" Please try again.");
input = verify.getValidNumber();
if (input == -1) {
return;
}
}
System.out.println("Selected job posting. Printing hired applicant information.");
JobPosting jobPosting = jobPostingManager.getJobPosting(input);
Application application = jobPosting.getApplicant(jobPosting.getHired_applicant());
application.read(manager);
}
/**
* uses user input to return the selected closed job posting. Return null if there are no open job postings.
*/
private JobPosting selectClosedPosting(JobPostingManager jpm, CompanyManager companyManager) {
VerifyInput verify = new VerifyInput();
Company company = companyManager.getCompanybyID(this.company);
CompanyArchives archives = company.getArchives();
if (!archives.hasOpenPostings(jpm)) {
System.out.println("Your company does not have any open job postings at the moment.");
return null;
}
archives.printOpenPostings(jpm);
System.out.println("Please enter job ID for which you want to assign interviewers to or -1 to go back");
int input = verify.getValidNumber();
if (input == -1) {
return null;
}
while (!archives.hasJobPosting(input)) {
System.out.println("Job posting not found. Please try again or -1 to go back.");
input = verify.getValidNumber();
if (input == -1) {
return null;
}
}
return jpm.getJobPosting(input);
}
}