-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJobsBean.java
More file actions
92 lines (78 loc) · 2.17 KB
/
JobsBean.java
File metadata and controls
92 lines (78 loc) · 2.17 KB
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
package org.javaee7.jsf;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.javaee7.entity.Jobs;
import org.javaee7.jpa.session.JobsSession;
/**
*
* @author Juneau
*/
@ManagedBean(name = "jobsBean")
@RequestScoped
public class JobsBean {
@EJB
JobsSession jobsSession;
private List<Jobs> currJobs;
/**
* Creates a new instance of JobsBean
*/
public JobsBean() {
}
public void printJobListing(){
jobsSession.retrieveJobs();
}
public List<Jobs> obtainJobListing(){
if(currJobs == null){
jobsSession.getJobList();
}
if(jobsSession.obtainJobListing().isDone()){
setCurrJobs(jobsSession.getJobList());
System.out.println("Task Is Complete");
} else {
setCurrJobs((List<Jobs>) new ArrayList());
Jobs inProgress = new Jobs();
inProgress.setTitle("In Progress");
getCurrJobs().add(inProgress);
System.out.println("Not yet complete...");
}
return getCurrJobs();
}
/**
* @return the currJobs
*/
public List<Jobs> getCurrJobs() {
return currJobs;
}
/**
* @param currJobs the currJobs to set
*/
public void setCurrJobs(List<Jobs> currJobs) {
this.currJobs = currJobs;
}
/**
* Create a jobs record
* @param jobId
* @param jobTitle
* @param salary
* @param division
*/
public void createJob(
@NotNull @Size(min = 3, max = 20) Integer jobId,
@NotNull String jobTitle,
@DecimalMin("35000") BigDecimal salary,
@NotNull String division) {
Jobs newJob = new Jobs();
newJob.setDivision(division);
newJob.setJobId(jobId);
newJob.setTitle(jobTitle);
newJob.setSalary(salary);
jobsSession.create(newJob);
}
}