[ce6ad22] | 1 | package parkup.entities;
|
---|
| 2 |
|
---|
[97fbc67] | 3 | import org.springframework.security.core.GrantedAuthority;
|
---|
| 4 | import org.springframework.security.core.userdetails.UserDetails;
|
---|
| 5 | import parkup.data.VrabotenDemo;
|
---|
[9ff45d6] | 6 | import parkup.data.enumarations.EmployeeStatus;
|
---|
[ce6ad22] | 7 |
|
---|
| 8 | import javax.persistence.*;
|
---|
| 9 | import java.util.ArrayList;
|
---|
[97fbc67] | 10 | import java.util.Collection;
|
---|
[ce6ad22] | 11 | import java.util.List;
|
---|
| 12 |
|
---|
| 13 | @Entity
|
---|
| 14 | @Table(name = "vraboten")
|
---|
[97fbc67] | 15 | public class Vraboten implements UserDetails {
|
---|
[ce6ad22] | 16 | @Id
|
---|
| 17 | @SequenceGenerator(
|
---|
| 18 | name="vraboten_sequence_generator",
|
---|
| 19 | sequenceName = "vraboten_sequence",
|
---|
| 20 | allocationSize = 1,
|
---|
| 21 | initialValue = 200
|
---|
| 22 | )
|
---|
| 23 | @GeneratedValue( //za postgres treba sequence da se namesti i ime na generator mi ga davamo kako od gore sto e
|
---|
| 24 | strategy = GenerationType.SEQUENCE,
|
---|
| 25 | generator = "vraboten_sequence_generator"
|
---|
| 26 | )
|
---|
| 27 | @Column(name = "vrabotenId")
|
---|
| 28 | private int vrabotenId;
|
---|
| 29 |
|
---|
[97fbc67] | 30 | @Override
|
---|
| 31 | public String toString() {
|
---|
| 32 | return "Vraboten{" +
|
---|
| 33 | "firstName='" + firstName + '\'' +
|
---|
| 34 | ", lastName='" + lastName + '\'' +
|
---|
| 35 | ", parkingZones=" + parkingZones +
|
---|
| 36 | ", locked=" + locked +
|
---|
| 37 | ", enabled=" + enabled +
|
---|
| 38 | '}';
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[ce6ad22] | 41 | @Column(name = "firstName")
|
---|
| 42 | private String firstName;
|
---|
| 43 |
|
---|
| 44 | @Column(name = "lastName")
|
---|
| 45 | private String lastName;
|
---|
| 46 |
|
---|
| 47 | @Column(name = "email")
|
---|
| 48 | private String email;
|
---|
| 49 |
|
---|
| 50 | @Column(name = "password")
|
---|
| 51 | private String password;
|
---|
| 52 |
|
---|
| 53 | @Column(name = "mobile")
|
---|
| 54 | private String mobile;
|
---|
| 55 |
|
---|
| 56 | @Column(name = "role")
|
---|
| 57 | private String role;
|
---|
| 58 |
|
---|
| 59 | @ManyToMany(cascade = {CascadeType.ALL})
|
---|
| 60 | private List<ParkingZone> parkingZones;
|
---|
| 61 |
|
---|
| 62 | @Column(name = "status")
|
---|
[9ff45d6] | 63 | private EmployeeStatus status;
|
---|
| 64 |
|
---|
| 65 | public void setLocked(boolean locked) {
|
---|
| 66 | this.locked = locked;
|
---|
| 67 | }
|
---|
[ce6ad22] | 68 |
|
---|
[97fbc67] | 69 | @Column(name="locked")
|
---|
| 70 | private boolean locked;
|
---|
| 71 |
|
---|
| 72 | @Column(name = "enabled")
|
---|
| 73 | private boolean enabled;
|
---|
| 74 |
|
---|
[ce6ad22] | 75 |
|
---|
| 76 | public Vraboten() {
|
---|
| 77 | this.role = "ROLE_VRABOTEN";
|
---|
| 78 | this.parkingZones = new ArrayList<ParkingZone>();
|
---|
[9ff45d6] | 79 | this.enabled = true;
|
---|
| 80 | this.status = EmployeeStatus.NOT_WORKING;
|
---|
[ce6ad22] | 81 | }
|
---|
| 82 |
|
---|
| 83 | public Vraboten(int vrabotenId, String firstName, String lastName, String email, String password, String mobile, List<ParkingZone> parkingZones) {
|
---|
| 84 | this.vrabotenId = vrabotenId;
|
---|
| 85 | this.firstName = firstName;
|
---|
| 86 | this.lastName = lastName;
|
---|
| 87 | this.email = email;
|
---|
| 88 | this.password = password;
|
---|
| 89 | this.mobile = mobile;
|
---|
| 90 | this.parkingZones = parkingZones;
|
---|
| 91 | this.role = "ROLE_VRABOTEN";
|
---|
[9ff45d6] | 92 | this.enabled = true;
|
---|
| 93 | this.status = EmployeeStatus.NOT_WORKING;
|
---|
[ce6ad22] | 94 | }
|
---|
| 95 |
|
---|
| 96 | public Vraboten(String firstName, String lastName, String email, String password, String mobile, List<ParkingZone> parkingZones) {
|
---|
| 97 | this.firstName = firstName;
|
---|
| 98 | this.lastName = lastName;
|
---|
| 99 | this.email = email;
|
---|
| 100 | this.password = password;
|
---|
| 101 | this.mobile = mobile;
|
---|
| 102 | this.parkingZones = parkingZones;
|
---|
| 103 | this.role = "ROLE_VRABOTEN";
|
---|
[9ff45d6] | 104 | this.enabled = true;
|
---|
| 105 | this.status = EmployeeStatus.NOT_WORKING;
|
---|
[ce6ad22] | 106 | }
|
---|
| 107 |
|
---|
[97fbc67] | 108 | public Vraboten(String firstName, String lastName, String email, String password, String mobile) {
|
---|
| 109 | this.firstName=firstName;
|
---|
| 110 | this.lastName=lastName;
|
---|
| 111 | this.email=email;
|
---|
| 112 | this.password=password;
|
---|
| 113 | this.mobile=mobile;
|
---|
| 114 | this.parkingZones=new ArrayList<>();
|
---|
| 115 | this.role="ROLE_VRABOTEN";
|
---|
[9ff45d6] | 116 | this.enabled=true;
|
---|
| 117 | this.status = EmployeeStatus.NOT_WORKING;
|
---|
[97fbc67] | 118 | }
|
---|
| 119 |
|
---|
[ce6ad22] | 120 | public int getVrabotenId() {
|
---|
| 121 | return vrabotenId;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | public void setVrabotenId(int vrabotenId) {
|
---|
| 125 | this.vrabotenId = vrabotenId;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | public String getFirstName() {
|
---|
| 129 | return firstName;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | public void setFirstName(String firstName) {
|
---|
| 133 | this.firstName = firstName;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | public String getLastName() {
|
---|
| 137 | return lastName;
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | public void setLastName(String lastName) {
|
---|
| 141 | this.lastName = lastName;
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | public String getEmail() {
|
---|
| 145 | return email;
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | public void setEmail(String email) {
|
---|
| 149 | this.email = email;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
[97fbc67] | 152 | @Override
|
---|
| 153 | public Collection<? extends GrantedAuthority> getAuthorities() {
|
---|
| 154 | return null;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[ce6ad22] | 157 | public String getPassword() {
|
---|
| 158 | return password;
|
---|
| 159 | }
|
---|
| 160 |
|
---|
[97fbc67] | 161 | @Override
|
---|
| 162 | public String getUsername() {
|
---|
| 163 | return email;
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | @Override
|
---|
| 167 | public boolean isAccountNonExpired() {
|
---|
| 168 | return true;
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | @Override
|
---|
| 172 | public boolean isAccountNonLocked() {
|
---|
| 173 | return !locked;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | public void lockVraboten(){
|
---|
| 177 | this.locked = !locked;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | @Override
|
---|
| 181 | public boolean isCredentialsNonExpired() {
|
---|
| 182 | return true;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | @Override
|
---|
| 186 | public boolean isEnabled() {
|
---|
| 187 | return enabled;
|
---|
| 188 | }
|
---|
| 189 |
|
---|
[ce6ad22] | 190 | public void setPassword(String password) {
|
---|
| 191 | this.password = password;
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | public String getMobile() {
|
---|
| 195 | return mobile;
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | public void setMobile(String mobile) {
|
---|
| 199 | this.mobile = mobile;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | public String getRole() {return role;}
|
---|
| 203 |
|
---|
| 204 | public void setRole(String role) {this.role = role;}
|
---|
| 205 |
|
---|
| 206 | public List<ParkingZone> getParkingZones() {return parkingZones;}
|
---|
| 207 |
|
---|
| 208 | public void setParkingZones(List<ParkingZone> parkingZones) {this.parkingZones = parkingZones;}
|
---|
| 209 |
|
---|
[9ff45d6] | 210 | public EmployeeStatus getStatus() {return status;}
|
---|
[ce6ad22] | 211 |
|
---|
[9ff45d6] | 212 | public void setStatus(EmployeeStatus status) {this.status = status;}
|
---|
[ce6ad22] | 213 |
|
---|
[97fbc67] | 214 | public boolean isAccount() {return enabled;}
|
---|
[ce6ad22] | 215 |
|
---|
[97fbc67] | 216 | public void setAccount(boolean account) {this.enabled = account;}
|
---|
[ce6ad22] | 217 | } |
---|