1
2
3
4 package de.tivsource.page.entity.vacancy;
5
6 import java.util.Date;
7 import java.util.List;
8
9 import javax.persistence.CascadeType;
10 import javax.persistence.Entity;
11 import javax.persistence.FetchType;
12 import javax.persistence.JoinColumn;
13 import javax.persistence.ManyToOne;
14 import javax.persistence.OneToMany;
15 import javax.persistence.Temporal;
16
17 import org.hibernate.envers.Audited;
18
19 import de.tivsource.page.entity.application.Application;
20 import de.tivsource.page.entity.contentitem.ContentItem;
21 import de.tivsource.page.entity.location.Location;
22
23
24
25
26
27 @Audited
28 @Entity
29 public class Vacancy extends ContentItem {
30
31 @Temporal(javax.persistence.TemporalType.TIMESTAMP)
32 private Date beginning;
33
34 private String workingTime;
35
36 @ManyToOne(fetch = FetchType.EAGER)
37 @JoinColumn(name = "location_uuid")
38 private Location location;
39
40 @OneToMany(mappedBy = "vacancy", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval=true)
41 private List<Application> applications;
42
43 public Date getBeginning() {
44 return beginning;
45 }
46
47 public void setBeginning(Date beginning) {
48 this.beginning = beginning;
49 }
50
51 public String getWorkingTime() {
52 return workingTime;
53 }
54
55 public void setWorkingTime(String workingTime) {
56 this.workingTime = workingTime;
57 }
58
59 public Location getLocation() {
60 return location;
61 }
62
63 public void setLocation(Location location) {
64 this.location = location;
65 }
66
67 public List<Application> getApplications() {
68 return applications;
69 }
70
71 public void setApplications(List<Application> applications) {
72 this.applications = applications;
73 }
74
75
76
77
78 @Override
79 public String getUrl() {
80 StringBuffer stringBuffer = new StringBuffer();
81 stringBuffer.append("/");
82 stringBuffer.append("vacancy/");
83 stringBuffer.append(this.getUuid());
84 stringBuffer.append("/");
85 stringBuffer.append("index.html");
86 return stringBuffer.toString();
87 }
88
89 @Override
90 public int compareTo(ContentItem o) {
91 if (o.getCreated().after(this.getCreated())) {
92 return 1;
93 } else if (o.getCreated().before(this.getCreated())) {
94 return -1;
95 } else {
96 return o.getUuid().compareTo(this.getUuid());
97 }
98 }
99
100 }