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