Index: sources/app/src/main/java/parkup/services/AdministratorService.java
===================================================================
--- sources/app/src/main/java/parkup/services/AdministratorService.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/services/AdministratorService.java	(revision 9dd526f0ddf9a23ad37dd4c977f761ff959f5913)
@@ -21,12 +21,10 @@
     private final AdministratorRepository administratorRepository;
     private final BCryptPasswordEncoder bCryptPasswordEncoder;
-    private final ConfirmationTokenService confirmationTokenService;
-    private EmailValidator emailValidator;
+
 
     @Autowired
-    public AdministratorService(AdministratorRepository administratorRepository, BCryptPasswordEncoder bCryptPasswordEncoder, ConfirmationTokenService confirmationTokenService) {
+    public AdministratorService(AdministratorRepository administratorRepository, BCryptPasswordEncoder bCryptPasswordEncoder) {
         this.administratorRepository = administratorRepository;
         this.bCryptPasswordEncoder = bCryptPasswordEncoder;
-        this.confirmationTokenService = confirmationTokenService;
     }
 
@@ -46,5 +44,5 @@
         } else {
             if (administrator.getEmail() != null && administrator.getEmail().length() > 1 && administrator.getEmail().contains("@")) {
-                //System.out.println(regPark);
+                administrator.setPassword(bCryptPasswordEncoder.encode(administrator.getPassword()));
                 this.administratorRepository.save(administrator);
             }
@@ -108,40 +106,4 @@
     }
 
-   //public String register(RegistrationRequest request) {
-   //    boolean isValidEmail = emailValidator.test(request.getEmail());
-   //    if (!isValidEmail){
-   //        throw new IllegalStateException("Email not valid");
-   //    }
-   //    return "it works";
-   //}
-
-    public String signUpAdministrator(Administrator administrator){
-        boolean administratorExists = administratorRepository
-                .findAdministratorByEmail(administrator.getEmail())
-                .isPresent();
-        if(administratorExists){
-            // TODO check if attributes are the same and
-            // TODO if email not confirmed send confirmation email
-
-            throw new IllegalStateException("Email already taken");
-        }
-
-        String encodedPassword = bCryptPasswordEncoder
-                .encode(administrator.getPassword());
-
-        administrator.setPassword(encodedPassword);
-
-        administratorRepository.save(administrator);
-
-        // TODO: Send confirmation token
-
-        String token = UUID.randomUUID().toString();
-
-
-        // TODO: SEND EMAIL
-
-        return token;
-    }
-
     public int enableAdministrator(String email) {
         return administratorRepository.enableAdministrator(email);
Index: sources/app/src/main/java/parkup/services/ParkingSessionService.java
===================================================================
--- sources/app/src/main/java/parkup/services/ParkingSessionService.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/services/ParkingSessionService.java	(revision 9dd526f0ddf9a23ad37dd4c977f761ff959f5913)
@@ -3,5 +3,5 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import parkup.data.Tablicka;
+import parkup.data.Plate;
 import parkup.data.enumarations.SessionStatus;
 import parkup.entities.ParkingSession;
@@ -11,5 +11,5 @@
 import parkup.repositories.ParkingSpaceRepository;
 import parkup.repositories.ParkingZoneRepository;
-import parkup.repositories.TablickaRepository;
+import parkup.repositories.PlateRepository;
 
 import javax.transaction.Transactional;
@@ -25,12 +25,12 @@
     private final ParkingZoneRepository parkingZoneRepository;
     private final ParkingSpaceRepository parkingSpaceRepository;
-    private final TablickaRepository tablickaRepository;
+    private final PlateRepository plateRepository;
 
     @Autowired
-    public ParkingSessionService(ParkingSessionRepository parkingSessionRepository, ParkingZoneRepository parkingZoneRepository, ParkingSpaceRepository parkingSpaceRepository, TablickaRepository tablickaRepository) {
+    public ParkingSessionService(ParkingSessionRepository parkingSessionRepository, ParkingZoneRepository parkingZoneRepository, ParkingSpaceRepository parkingSpaceRepository, PlateRepository plateRepository) {
         this.parkingSessionRepository = parkingSessionRepository;
         this.parkingZoneRepository = parkingZoneRepository;
         this.parkingSpaceRepository = parkingSpaceRepository;
-        this.tablickaRepository = tablickaRepository;
+        this.plateRepository = plateRepository;
     }
 
@@ -83,10 +83,10 @@
     public Optional<ParkingSession> startParkingSession(String tablica, int parkingZoneId) {
         ParkingZone parkingZone = parkingZoneRepository.findByPzId(parkingZoneId);
-        Tablicka tablicka = tablickaRepository.findByTablica(tablica);
-        if(tablicka==null) {
-            tablickaRepository.save(new Tablicka(tablica));
+        Plate plate = plateRepository.findByPlate(tablica);
+        if(plate ==null) {
+            plateRepository.save(new Plate(tablica));
         }
-        tablicka=tablickaRepository.findByTablica(tablica);
-        ParkingSession sessionToAdd = new ParkingSession(tablicka);
+        plate = plateRepository.findByPlate(tablica);
+        ParkingSession sessionToAdd = new ParkingSession(plate);
         sessionToAdd.setParkingZone(parkingZone);
         parkingSessionRepository.save(sessionToAdd);
Index: sources/app/src/main/java/parkup/services/ParkingSpaceService.java
===================================================================
--- sources/app/src/main/java/parkup/services/ParkingSpaceService.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/services/ParkingSpaceService.java	(revision 9dd526f0ddf9a23ad37dd4c977f761ff959f5913)
@@ -4,4 +4,5 @@
 import org.springframework.stereotype.Service;
 import parkup.entities.ParkingSpace;
+import parkup.entities.ParkingZone;
 import parkup.repositories.ParkingSpaceRepository;
 import parkup.repositories.ParkingZoneRepository;
@@ -48,6 +49,6 @@
         Optional<ParkingSpace> ParkingSpaceOpt = Optional.ofNullable(parkingSpaceRepository.findByPsId(parkingSpaceId));
         if (ParkingSpaceOpt.isPresent()) {
-            ParkingSpace ParkingSpaceNov = parkingSpaceRepository.findByPsId(parkingSpaceId);
-            if (psName != null && psName.length() > 1 && !Objects.equals(ParkingSpaceNov.getPsName(), psName)) {
+            ParkingSpace parkingSpaceNew = parkingSpaceRepository.findByPsId(parkingSpaceId);
+            if (psName != null && psName.length() > 1 && !Objects.equals(parkingSpaceNew.getPsName(), psName)) {
                 Optional<ParkingSpace> parkingSpaceOpt1 = Optional.ofNullable(parkingSpaceRepository.findByPsName(psName));
                 if (parkingSpaceOpt1.isPresent()) {
@@ -55,20 +56,20 @@
                 }
 
-                ParkingSpaceNov.setPsName(psName);
+                parkingSpaceNew.setPsName(psName);
             }
 
-            if (!Objects.equals(ParkingSpaceNov.isTaken(), taken)) {
-                ParkingSpaceNov.setTaken(taken);
+            if (!Objects.equals(parkingSpaceNew.isTaken(), taken)) {
+                parkingSpaceNew.setTaken(taken);
             }
 
 
-            if(lat!=0 && !Objects.equals(ParkingSpaceNov.getLat(), lat)){
-                ParkingSpaceNov.setLat(lat);
+            if(lat!=0 && !Objects.equals(parkingSpaceNew.getLat(), lat)){
+                parkingSpaceNew.setLat(lat);
             }
 
-            if(lng!=0 && !Objects.equals(ParkingSpaceNov.getLng(), lng)){
-                ParkingSpaceNov.setLng(lng);
+            if(lng!=0 && !Objects.equals(parkingSpaceNew.getLng(), lng)){
+                parkingSpaceNew.setLng(lng);
             }
-            return ParkingSpaceNov;
+            return parkingSpaceNew;
         }else{
             throw new IllegalStateException("ParkingSpace does not exist");
@@ -80,4 +81,8 @@
         Optional<ParkingSpace> parkingSpaceOpt = Optional.ofNullable(parkingSpaceRepository.findByPsId(parkingSpaceId));
         if (parkingSpaceOpt.isPresent()) {
+            for(ParkingZone pz: parkingZoneRepository.findAll()){
+                pz.getParkingSpaces().remove(parkingSpaceOpt.get());
+                parkingZoneRepository.save(pz);
+            }
             parkingSpaceRepository.deleteByPsId(parkingSpaceId);
         } else {
Index: sources/app/src/main/java/parkup/services/ParkingZoneService.java
===================================================================
--- sources/app/src/main/java/parkup/services/ParkingZoneService.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/services/ParkingZoneService.java	(revision 9dd526f0ddf9a23ad37dd4c977f761ff959f5913)
@@ -4,12 +4,11 @@
 import org.springframework.stereotype.Service;
 import parkup.data.ParkingZoneLocation;
-import parkup.entities.ParkingSession;
 import parkup.entities.ParkingSpace;
 import parkup.entities.ParkingZone;
-import parkup.entities.Vraboten;
+import parkup.entities.Worker;
 import parkup.repositories.ParkingSessionRepository;
 import parkup.repositories.ParkingSpaceRepository;
 import parkup.repositories.ParkingZoneRepository;
-import parkup.repositories.VrabotenRepository;
+import parkup.repositories.WorkerRepository;
 
 import javax.transaction.Transactional;
@@ -23,22 +22,30 @@
     private final ParkingZoneRepository parkingZoneRepository;
     private final ParkingSpaceRepository parkingSpaceRepository;
-    private final VrabotenRepository vrabotenRepository;
+    private final WorkerRepository workerRepository;
     private final ParkingSessionRepository parkingSessionRepository;
 
     @Autowired
-    public ParkingZoneService(ParkingZoneRepository parkingZoneRepository, ParkingSpaceRepository parkingSpaceRepository, VrabotenRepository vrabotenRepository, ParkingSessionRepository parkingSessionRepository) {
+    public ParkingZoneService(ParkingZoneRepository parkingZoneRepository, ParkingSpaceRepository parkingSpaceRepository, WorkerRepository workerRepository, ParkingSessionRepository parkingSessionRepository) {
         this.parkingZoneRepository = parkingZoneRepository;
         this.parkingSpaceRepository = parkingSpaceRepository;
         this.parkingSessionRepository = parkingSessionRepository;
-        this.vrabotenRepository = vrabotenRepository;
+        this.workerRepository = workerRepository;
     }
 
     public List<ParkingZone> getAllParkingZones() {
-        return parkingZoneRepository.findAll();
+        List<ParkingZone> parkingZones= parkingZoneRepository.findAll();
+        for(ParkingZone pz:parkingZones){
+            setTransientVariables(pz.getId());
+        }
+        return parkingZones;
     }
 
     public ParkingZone findById(int parkingZoneId) {
         Optional<ParkingZone> parkingZone = Optional.ofNullable(this.parkingZoneRepository.findByPzId(parkingZoneId));
-        return parkingZone.orElse(null);
+        if (!parkingZone.isPresent()) {
+            throw new IllegalStateException("ParkingZone does not exist");
+        }
+        setTransientVariables(parkingZone.get().getId());
+        return parkingZone.get();
     }
 
@@ -134,7 +141,7 @@
                     ParkingZone parkingZone = parkingZoneRepository.findByPzId(parkingZoneId);
                     for (Integer vrabotenId : odgovorniLica) {
-                        Vraboten vrabotenToAdd = vrabotenRepository.findByVrabotenId(vrabotenId);
-                        if(vrabotenToAdd!=null)
-                        vrabotenToAdd.getParkingZones().add(parkingZone);
+                        Worker workerToAdd = workerRepository.findByWorkerId(vrabotenId);
+                        if(workerToAdd !=null)
+                        workerToAdd.getParkingZones().add(parkingZone);
                     }
                 }
@@ -158,4 +165,17 @@
             return parkingZoneOpt;
         }
+
+        public int calculateTakenSpaces(int pzId){
+            ParkingZone parkingZone=parkingZoneRepository.findByPzId(pzId);
+            return (int)parkingZone.getParkingSpaces().stream().filter(ParkingSpace::isTaken).count();
+        }
+        public int calculateCapacity(int pzId){
+            ParkingZone parkingZone=parkingZoneRepository.findByPzId(pzId);
+            return parkingZone.getParkingSpaces().size();
+        }
+        public void setTransientVariables(int pzId){
+            calculateCapacity(pzId);
+            calculateTakenSpaces(pzId);
+        }
     }
 
Index: sources/app/src/main/java/parkup/services/RegisteredUserService.java
===================================================================
--- sources/app/src/main/java/parkup/services/RegisteredUserService.java	(revision 9dd526f0ddf9a23ad37dd4c977f761ff959f5913)
+++ sources/app/src/main/java/parkup/services/RegisteredUserService.java	(revision 9dd526f0ddf9a23ad37dd4c977f761ff959f5913)
@@ -0,0 +1,151 @@
+package parkup.services;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
+import javax.transaction.Transactional;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.stereotype.Service;
+import parkup.configs.email.EmailValidator;
+import parkup.configs.token.ConfirmationTokenRP;
+import parkup.configs.token.ConfirmationTokenService;
+import parkup.data.Plate;
+import parkup.entities.RegisteredUser;
+import parkup.repositories.RegisteredUserRepository;
+
+@Service
+public class RegisteredUserService implements UserDetailsService {
+    private final RegisteredUserRepository registeredUserRepository;
+    private final BCryptPasswordEncoder bCryptPasswordEncoder;
+    private final ConfirmationTokenService confirmationTokenService;
+    private final EmailValidator emailValidator;
+    @Autowired
+    public RegisteredUserService(RegisteredUserRepository registeredUserRepository, BCryptPasswordEncoder bCryptPasswordEncoder, ConfirmationTokenService confirmationTokenService, EmailValidator emailValidator) {
+        this.registeredUserRepository = registeredUserRepository;
+        this.bCryptPasswordEncoder = bCryptPasswordEncoder;
+        this.confirmationTokenService = confirmationTokenService;
+        this.emailValidator = emailValidator;
+    }
+
+    public List<RegisteredUser> getRegPark() {
+        return this.registeredUserRepository.findAll();
+    }
+
+    public Optional<RegisteredUser> addRegPark(RegisteredUser regPark) {
+        Optional<RegisteredUser> regParkOpt = this.registeredUserRepository.findRegisteredUserByEmail(regPark.getEmail());
+        if (regParkOpt.isPresent()) {
+            throw new IllegalStateException("Email already taken, try adding a registriranParkirac with a different valid email address");
+        } else {
+            if (regPark.getEmail() != null && regPark.getEmail().length() > 1 && regPark.getEmail().contains("@")) {
+                this.registeredUserRepository.save(regPark);
+            }
+            else {
+                throw new IllegalStateException("email not valid");
+            }
+        }
+        return regParkOpt;
+    }
+
+    @Transactional
+    public RegisteredUser updateRegPark(int regParkId, String name, String surname, String mobile, String email, List<Plate> regTablicki) {
+        Optional<RegisteredUser> regParkOpt = Optional.ofNullable(this.registeredUserRepository.findByRegParkId(regParkId));
+        if (regParkOpt.isPresent()) {
+            RegisteredUser regParkNov = this.registeredUserRepository.findByRegParkId(regParkId);
+            if (email != null && email.length() > 1 && email.contains("@") && !Objects.equals(regParkNov.getEmail(), email)) {
+                Optional<RegisteredUser> userOpt1 = this.registeredUserRepository.findRegisteredUserByEmail(email);
+                if (userOpt1.isPresent()) {
+                    throw new IllegalStateException("email taken");
+                }
+
+                regParkNov.setEmail(email);
+            }
+
+            if (name != null && name.length() > 1 && !Objects.equals(regParkNov.getName(), name)) {
+                regParkNov.setName(name);
+            }
+
+            if (surname != null && surname.length() > 1 && !Objects.equals(regParkNov.getSurname(), surname)) {
+                regParkNov.setSurname(surname);
+            }
+
+            if (mobile != null && mobile.length() > 0 && !Objects.equals(regParkNov.getMobile(), mobile)) {
+                regParkNov.setMobile(mobile);
+            }
+            regParkNov.setPlates(regTablicki);
+            return regParkNov;
+        }else{
+            throw new IllegalStateException("RegistriranParkirac doesn't exist, therefore can't be updated");
+        }
+    }
+
+    @Transactional
+    @Modifying
+    public Optional<RegisteredUser> deleteRegPark(int regParkId) {
+        Optional<RegisteredUser> regPark = Optional.ofNullable(this.registeredUserRepository.findByRegParkId(regParkId));
+        if (regPark.isPresent()) {
+            //TODO da povikamo metod od ConfirmationTokenService za brisenje na ConfirmationTokenRP *DONE
+            //TODO da se izbrisat tablicki i da ne se dupliraat istite tablicki pri update ili add na nov registriranParkirac
+            this.confirmationTokenService.deleteByRegisteredUser_RegParkId(regParkId);
+            this.registeredUserRepository.deleteByRegParkId(regParkId);
+        } else {
+            throw new IllegalStateException("RegistriranParkirac doesn't exist, therefore can't be deleted");
+        }
+        return regPark;
+    }
+
+    public RegisteredUser findById(int regParkId) {
+        Optional<RegisteredUser> regPark = Optional.ofNullable(this.registeredUserRepository.findByRegParkId(regParkId));
+        return regPark.orElse(null);
+    }
+
+    @Override
+    public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
+        return registeredUserRepository.findRegisteredUserByEmail(email)
+                .orElseThrow(() ->
+                        new UsernameNotFoundException("Email not found"));
+
+    }
+
+    public String signUpRegistriranParkirac(RegisteredUser registeredUser){
+        if (registeredUser.getEmail() == null || registeredUser.getEmail().isEmpty())
+            throw new IllegalArgumentException("Empty email");
+        if (!emailValidator.test(registeredUser.getEmail()))
+            throw new IllegalArgumentException("Invalid email");
+        boolean registriranParkiracExists = registeredUserRepository
+                .findRegisteredUserByEmail(registeredUser.getEmail())
+                .isPresent();
+        if(registriranParkiracExists){
+            throw new IllegalStateException("Email already taken");
+        }
+
+        String encodedPassword = bCryptPasswordEncoder
+                .encode(registeredUser.getPassword());
+
+        registeredUser.setPassword(encodedPassword);
+
+        registeredUserRepository.save(registeredUser);
+
+        String token = UUID.randomUUID().toString();
+        ConfirmationTokenRP confirmationTokenRP = new ConfirmationTokenRP(
+                token,
+                LocalDateTime.now(),
+                LocalDateTime.now().plusMinutes(15),
+                registeredUser
+        );
+
+        confirmationTokenService.saveConfirmationTokenRP(confirmationTokenRP);
+
+        return token;
+    }
+
+    public int enableRegistriranParkirac(String email) {
+        return registeredUserRepository.enableRegisteredUser(email);
+    }
+}
Index: sources/app/src/main/java/parkup/services/RegistriranParkiracService.java
===================================================================
--- sources/app/src/main/java/parkup/services/RegistriranParkiracService.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ 	(revision )
@@ -1,155 +1,0 @@
-package parkup.services;
-
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.UUID;
-import javax.transaction.Transactional;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.jpa.repository.Modifying;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.stereotype.Service;
-import parkup.configs.email.EmailValidator;
-import parkup.configs.token.ConfirmationTokenRP;
-import parkup.configs.token.ConfirmationTokenService;
-import parkup.data.Tablicka;
-import parkup.entities.RegistriranParkirac;
-import parkup.repositories.RegistriranParkiracRepository;
-
-@Service
-public class RegistriranParkiracService implements UserDetailsService {
-    private final RegistriranParkiracRepository registriranParkiracRepository;
-    private final BCryptPasswordEncoder bCryptPasswordEncoder;
-    private final ConfirmationTokenService confirmationTokenService;
-    private EmailValidator emailValidator;
-
-    @Autowired
-    public RegistriranParkiracService(RegistriranParkiracRepository registriranParkiracRepository, BCryptPasswordEncoder bCryptPasswordEncoder, ConfirmationTokenService confirmationTokenService) {
-        this.registriranParkiracRepository = registriranParkiracRepository;
-        this.bCryptPasswordEncoder = bCryptPasswordEncoder;
-        this.confirmationTokenService = confirmationTokenService;
-    }
-
-    public List<RegistriranParkirac> getRegPark() {
-        return this.registriranParkiracRepository.findAll();
-    }
-
-    public Optional<RegistriranParkirac> addRegPark(RegistriranParkirac regPark) {
-        Optional<RegistriranParkirac> regParkOpt = this.registriranParkiracRepository.findRegistriranParkiracByEmail(regPark.getEmail());
-        if (regParkOpt.isPresent()) {
-            throw new IllegalStateException("Email already taken, try adding a registriranParkirac with a different valid email address");
-        } else {
-            if (regPark.getEmail() != null && regPark.getEmail().length() > 1 && regPark.getEmail().contains("@")) {
-                //System.out.println(regPark);
-                this.registriranParkiracRepository.save(regPark);
-            }
-            else {
-                throw new IllegalStateException("email not valid");
-            }
-        }
-        return regParkOpt;
-    }
-
-    @Transactional
-    public RegistriranParkirac updateRegPark(int regParkId, String name, String surname, String mobile, String email,List<Tablicka> regTablicki) {
-        Optional<RegistriranParkirac> regParkOpt = Optional.ofNullable(this.registriranParkiracRepository.findByRegParkId(regParkId));
-        if (regParkOpt.isPresent()) {
-            RegistriranParkirac regParkNov = this.registriranParkiracRepository.findByRegParkId(regParkId);
-            if (email != null && email.length() > 1 && email.contains("@") && !Objects.equals(regParkNov.getEmail(), email)) {
-                Optional<RegistriranParkirac> userOpt1 = this.registriranParkiracRepository.findRegistriranParkiracByEmail(email);
-                if (userOpt1.isPresent()) {
-                    throw new IllegalStateException("email taken");
-                }
-
-                regParkNov.setEmail(email);
-            }
-
-            if (name != null && name.length() > 1 && !Objects.equals(regParkNov.getName(), name)) {
-                regParkNov.setName(name);
-            }
-
-            if (surname != null && surname.length() > 1 && !Objects.equals(regParkNov.getSurname(), surname)) {
-                regParkNov.setSurname(surname);
-            }
-
-            if (mobile != null && mobile.length() > 0 && !Objects.equals(regParkNov.getMobile(), mobile)) {
-                regParkNov.setMobile(mobile);
-            }
-            regParkNov.setRegTablicki(regTablicki);
-            return regParkNov;
-        }else{
-            throw new IllegalStateException("RegistriranParkirac doesn't exist, therefore can't be updated");
-        }
-    }
-
-    @Transactional
-    @Modifying
-    public Optional<RegistriranParkirac> deleteRegPark(int regParkId) {
-        Optional<RegistriranParkirac> regPark = Optional.ofNullable(this.registriranParkiracRepository.findByRegParkId(regParkId));
-        if (regPark.isPresent()) {
-            //TODO da povikamo metod od ConfirmationTokenService za brisenje na ConfirmationTokenRP *DONE
-            //TODO da se izbrisat tablicki i da ne se dupliraat istite tablicki pri update ili add na nov registriranParkirac
-            this.confirmationTokenService.deleteByRegistriranParkirac_RegParkId(regParkId);
-            this.registriranParkiracRepository.deleteByRegParkId(regParkId);
-        } else {
-            throw new IllegalStateException("RegistriranParkirac doesn't exist, therefore can't be deleted");
-        }
-        return regPark;
-    }
-
-    public RegistriranParkirac findById(int regParkId) {
-        Optional<RegistriranParkirac> regPark = Optional.ofNullable(this.registriranParkiracRepository.findByRegParkId(regParkId));
-        return regPark.orElse(null);
-    }
-
-    @Override
-    public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
-        return registriranParkiracRepository.findRegistriranParkiracByEmail(email)
-                .orElseThrow(() ->
-                        new UsernameNotFoundException("Email not found"));
-
-    }
-
-    public String signUpRegistriranParkirac(RegistriranParkirac registriranParkirac){
-        boolean registriranParkiracExists = registriranParkiracRepository
-                .findRegistriranParkiracByEmail(registriranParkirac.getEmail())
-                .isPresent();
-        if(registriranParkiracExists){
-            // TODO check if attributes are the same and
-            // TODO if email not confirmed send confirmation email
-
-            throw new IllegalStateException("Email already taken");
-        }
-
-        String encodedPassword = bCryptPasswordEncoder
-                .encode(registriranParkirac.getPassword());
-
-        registriranParkirac.setPassword(encodedPassword);
-
-        registriranParkiracRepository.save(registriranParkirac);
-
-        // TODO: Send confirmation token
-
-        String token = UUID.randomUUID().toString();
-        ConfirmationTokenRP confirmationTokenRP = new ConfirmationTokenRP(
-                token,
-                LocalDateTime.now(),
-                LocalDateTime.now().plusMinutes(15),
-                registriranParkirac
-        );
-
-        confirmationTokenService.saveConfirmationTokenRP(confirmationTokenRP);
-
-        // TODO: SEND EMAIL
-
-        return token;
-    }
-
-    public int enableRegistriranParkirac(String email) {
-        return registriranParkiracRepository.enableRegistriranParkirac(email);
-    }
-}
Index: sources/app/src/main/java/parkup/services/VrabotenService.java
===================================================================
--- sources/app/src/main/java/parkup/services/VrabotenService.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ 	(revision )
@@ -1,263 +1,0 @@
-package parkup.services;
-
-import java.time.LocalDateTime;
-import java.util.*;
-import java.util.stream.Collectors;
-import javax.transaction.Transactional;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.stereotype.Service;
-import parkup.configs.token.ConfirmationTokenW;
-import parkup.configs.token.ConfirmationTokenService;
-import parkup.data.enumarations.EmployeeStatus;
-import parkup.entities.ParkingZone;
-import parkup.entities.Vraboten;
-import parkup.repositories.ParkingZoneRepository;
-import parkup.repositories.VrabotenRepository;
-import parkup.data.VrabotenDemo;
-
-@Service
-public class VrabotenService implements UserDetailsService {
-    private final VrabotenRepository vrabotenRepository;
-    private final ParkingZoneRepository parkingZoneRepository;
-    private final BCryptPasswordEncoder bCryptPasswordEncoder;
-    private final ConfirmationTokenService confirmationTokenService;
-
-    @Autowired
-    public VrabotenService(VrabotenRepository vrabotenRepository, ParkingZoneRepository parkingZoneRepository, BCryptPasswordEncoder bCryptPasswordEncoder, ConfirmationTokenService confirmationTokenService) {
-        this.vrabotenRepository = vrabotenRepository;
-        this.parkingZoneRepository = parkingZoneRepository;
-        this.bCryptPasswordEncoder = bCryptPasswordEncoder;
-        this.confirmationTokenService = confirmationTokenService;
-    }
-
-    public List<Vraboten> getVraboteni() {
-        return this.vrabotenRepository.findAll();
-    }
-
-    public Vraboten findById(int vrabotenId) {
-        Optional<Vraboten> vraboten = Optional.ofNullable(this.vrabotenRepository.findByVrabotenId(vrabotenId));
-        return vraboten.orElse(null);
-    }
-
-    public List<VrabotenDemo> getAllVraboteniDemos() {
-        List<Vraboten> vraboteni = this.vrabotenRepository.findAll();
-        List<VrabotenDemo> vrabotenDemos = new ArrayList<>();
-        for (Vraboten v : vraboteni){
-            VrabotenDemo vd = new VrabotenDemo(v.getVrabotenId(),v.getFirstName(), v.getLastName(), v.getEmail());
-            vrabotenDemos.add(vd);
-        }
-        return vrabotenDemos;
-    }
-
-    public Optional<Vraboten> addVraboten(String password,String confirmPass,boolean locked, String firstName, String lastName, String mobile, String email, EmployeeStatus status,List<String> parkingZones) {
-        Optional<Vraboten> vrabotenOpt = this.vrabotenRepository.findVrabotenByEmail(email);
-        if (vrabotenOpt.isPresent()){
-            throw new IllegalArgumentException("User with that mail already exists");
-        }
-        Vraboten vrabotenToAdd=new Vraboten();
-        if (email != null && email.length() > 1 && email.contains("@") ) {
-            vrabotenToAdd.setEmail(email);
-        } else {
-            throw new IllegalStateException("email not valid");
-        }
-        if(password.equals(confirmPass)){
-            vrabotenToAdd.setPassword(bCryptPasswordEncoder.encode(password));
-        }
-        vrabotenToAdd.setLocked(locked);
-
-        if (firstName != null && firstName.length() > 1) {
-            vrabotenToAdd.setFirstName(firstName);
-        }
-
-        if (lastName != null && lastName.length() > 1 ) {
-            vrabotenToAdd.setLastName(lastName);
-        }
-
-        if (mobile != null && mobile.length() > 0 ) {
-            vrabotenToAdd.setMobile(mobile);
-        }
-
-        vrabotenToAdd.setStatus(status);
-
-        if(parkingZones!=null){
-            List<ParkingZone> parkingZonesAvailable =parkingZoneRepository.findAll();
-            List<ParkingZone> zonesToAdd= new ArrayList<>();
-            vrabotenToAdd.setParkingZones(null);
-            for(String pzName:parkingZones){
-                for(ParkingZone pz :parkingZonesAvailable){
-                    if(pzName.equals(pz.getPzName())) {
-                        zonesToAdd.add(pz);
-//                            pz.getOdgovorniLica().add(vrabotenRepository.findByVrabotenId(vrabotenId));
-                    }
-                }
-            }
-            vrabotenToAdd.setParkingZones(zonesToAdd);
-        }
-        String token = UUID.randomUUID().toString();
-        ConfirmationTokenW confirmationTokenW = new ConfirmationTokenW(
-                token,
-                LocalDateTime.now(),
-                LocalDateTime.now().plusMinutes(15),
-                vrabotenToAdd
-        );
-
-        confirmationTokenService.saveConfirmationTokenW(confirmationTokenW);
-
-        return Optional.of(vrabotenToAdd);
-//        Optional<Vraboten> vrabotenOpt = this.vrabotenRepository.findVrabotenByEmail(vraboten.getEmail());
-//        if (vrabotenOpt.isPresent()) {
-//            throw new IllegalStateException("Email already taken, try adding a vraboten with a different valid email address");
-//        } else {
-//            if (vraboten.getEmail() != null && vraboten.getEmail().length() > 1 && vraboten.getEmail().contains("@")) {
-//                //System.out.println(vraboten);
-//                this.vrabotenRepository.save(vraboten);
-//            }
-//            else{
-//                throw new IllegalStateException("email not valid");
-//            }
-//        }
-//        return vrabotenOpt;
-    }
-
-    @Transactional
-    public Vraboten updateVraboten(int vrabotenId,String password,String confirmPass,boolean locked, String firstName, String lastName, String mobile, String email, EmployeeStatus status,List<String> parkingZones) {
-        Optional<Vraboten> vrabotenOpt = Optional.ofNullable(this.vrabotenRepository.findByVrabotenId(vrabotenId));
-        if (vrabotenOpt.isPresent()) {
-
-            if (email != null && email.length() > 1 && email.contains("@") ) {
-                List<String> emails = vrabotenRepository.findAll().stream().map(Vraboten::getEmail).collect(Collectors.toList());
-                for(String mailToCheck :emails)
-                if (email.equals(mailToCheck)&&vrabotenOpt.get().getVrabotenId()!=vrabotenId) {
-                    throw new IllegalStateException("email taken");
-                }
-                vrabotenOpt.get().setEmail(email);
-            } else {
-                throw new IllegalStateException("email not valid");
-            }
-            if(password.equals(confirmPass)){
-                vrabotenOpt.get().setPassword(bCryptPasswordEncoder.encode(password));
-            }
-            vrabotenOpt.get().setLocked(locked);
-
-            if (firstName != null && firstName.length() > 1 && !Objects.equals(vrabotenOpt.get().getFirstName(), firstName)) {
-                vrabotenOpt.get().setFirstName(firstName);
-            }
-
-            if (lastName != null && lastName.length() > 1 && !Objects.equals(vrabotenOpt.get().getLastName(), lastName)) {
-                vrabotenOpt.get().setLastName(lastName);
-            }
-
-            if (mobile != null && mobile.length() > 0 && !Objects.equals(vrabotenOpt.get().getMobile(), mobile)) {
-                vrabotenOpt.get().setMobile(mobile);
-            }
-
-//            if (status != null && status.toString().length() > 0) {
-//                if(Arrays.stream(EmployeeStatus.values()).toList().contains(EmployeeStatus.valueOf(status))){
-            vrabotenOpt.get().setStatus(status);
-//                }else{
-//                    throw new IllegalStateException("Please enter one of the following statuses: 'raboti', 'ne raboti', 'na odmor', 'na boleduvanje'");
-//                }
-//            }
-            if(parkingZones!=null){
-                List<ParkingZone> parkingZonesAvailable =parkingZoneRepository.findAll();
-                List<ParkingZone> zonesToAdd= new ArrayList<>();
-                vrabotenOpt.get().setParkingZones(null);
-                for(String pzName:parkingZones){
-                    for(ParkingZone pz :parkingZonesAvailable){
-                        if(pzName.equals(pz.getPzName())) {
-                            zonesToAdd.add(pz);
-//                            pz.getOdgovorniLica().add(vrabotenRepository.findByVrabotenId(vrabotenId));
-                        }
-                    }
-                }
-                vrabotenOpt.get().setParkingZones(zonesToAdd);
-            }
-            return vrabotenOpt.get();
-        }
-        else{
-            throw new IllegalStateException("Vraboten doesn't exist, therefore can't be updated");
-        }
-    }//za menjanje password da se implementira
-
-    @Transactional
-    public Optional<Vraboten> deleteVraboten(int vrabotenId) {
-        Optional<Vraboten> vrabotenOpt = Optional.ofNullable(this.vrabotenRepository.findByVrabotenId(vrabotenId));
-        if (vrabotenOpt.isPresent()) {
-            this.confirmationTokenService.deleteByVraboten_VrabotenId(vrabotenId);
-            this.vrabotenRepository.deleteByVrabotenId(vrabotenId);
-        } else {
-            throw new IllegalStateException("Vraboten doesn't exist, therefore can't be deleted");
-        }
-        return vrabotenOpt;
-    }
-
-    @Transactional
-    public void lockVrabotenAcc(int vrabotenId) {
-        Vraboten vrabotenOpt = this.vrabotenRepository.findByVrabotenId(vrabotenId);
-        if (vrabotenOpt!=null) {
-            vrabotenOpt.lockVraboten();
-        } else {
-            throw new IllegalStateException("Vraboten doesn't exist, therefore his account can't be locked/unlocked");
-        }
-    }
-
-    @Override
-    public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
-        return vrabotenRepository.findVrabotenByEmail(email)
-                .orElseThrow(() ->
-                        new UsernameNotFoundException("Email not found"));
-    }
-    public String signUpVraboten(Vraboten vraboten){
-        boolean vrabotenExists = vrabotenRepository
-                .findVrabotenByEmail(vraboten.getEmail())
-                .isPresent();
-        if(vrabotenExists){
-            // TODO check if attributes are the same and
-            // TODO if email not confirmed send confirmation email
-
-            throw new IllegalStateException("Email already taken");
-        }
-
-        String encodedPassword = bCryptPasswordEncoder
-                .encode(vraboten.getPassword());
-
-        vraboten.setPassword(encodedPassword);
-
-        vrabotenRepository.save(vraboten);
-
-        // TODO: Send confirmation token
-
-        String token = UUID.randomUUID().toString();
-        ConfirmationTokenW confirmationTokenW = new ConfirmationTokenW(
-                token,
-                LocalDateTime.now(),
-                LocalDateTime.now().plusMinutes(15),
-                vraboten
-        );
-
-        confirmationTokenService.saveConfirmationTokenW(confirmationTokenW);
-
-        // TODO: SEND EMAIL
-
-        return token;
-    }
-
-    public int enableVraboten(String email) {
-        return vrabotenRepository.enableVraboten(email);
-    }
-
-//    @Transactional
-//    public void setVrabotenStatus(int vrabotenId,String vrabotenStatus) {
-//        Vraboten vraboten = vrabotenRepository.findByVrabotenId(vrabotenId);
-//        if(vraboten!=null && value){
-//            vraboten.setStatus(valuee);
-//        }
-//        else {
-//            throw new IllegalStateException(String.format("Vraboten with id %d does not exist.",vrabotenId));
-//        }
-//    }
-}
Index: sources/app/src/main/java/parkup/services/WorkerService.java
===================================================================
--- sources/app/src/main/java/parkup/services/WorkerService.java	(revision 9dd526f0ddf9a23ad37dd4c977f761ff959f5913)
+++ sources/app/src/main/java/parkup/services/WorkerService.java	(revision 9dd526f0ddf9a23ad37dd4c977f761ff959f5913)
@@ -0,0 +1,200 @@
+package parkup.services;
+
+import java.util.*;
+import java.util.stream.Collectors;
+import javax.transaction.Transactional;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.stereotype.Service;
+import parkup.data.WorkerDemoParkingZones;
+import parkup.data.enumarations.EmployeeStatus;
+import parkup.entities.ParkingZone;
+import parkup.entities.Worker;
+import parkup.repositories.ParkingZoneRepository;
+import parkup.repositories.WorkerRepository;
+import parkup.data.WorkerDemo;
+
+@Service
+public class WorkerService implements UserDetailsService {
+    private final WorkerRepository workerRepository;
+    private final ParkingZoneRepository parkingZoneRepository;
+    private final BCryptPasswordEncoder bCryptPasswordEncoder;
+
+    @Autowired
+    public WorkerService(WorkerRepository workerRepository, ParkingZoneRepository parkingZoneRepository, BCryptPasswordEncoder bCryptPasswordEncoder) {
+        this.workerRepository = workerRepository;
+        this.parkingZoneRepository = parkingZoneRepository;
+        this.bCryptPasswordEncoder = bCryptPasswordEncoder;
+    }
+
+    public List<Worker> getWorkers() {
+        return this.workerRepository.findAll();
+    }
+
+    public WorkerDemoParkingZones findById(int workerId) {
+        Worker worker = this.workerRepository.findByWorkerId(workerId);
+        WorkerDemoParkingZones workerToReturn = new WorkerDemoParkingZones(worker);
+        return workerToReturn;
+    }
+
+    public List<WorkerDemo> getAllVraboteniDemos() {
+        List<Worker> workers = this.workerRepository.findAll();
+        List<WorkerDemo> workerDemos = new ArrayList<>();
+        for (Worker v : workers){
+            WorkerDemo vd = new WorkerDemo(v.getWorkerId(),v.getFirstName(), v.getLastName(), v.getEmail());
+            workerDemos.add(vd);
+        }
+        return workerDemos;
+    }
+
+    public Optional<Worker> addWorker(String password, String confirmPass, boolean locked, String firstName, String lastName, String mobile, String email, EmployeeStatus status, List<String> parkingZones) {
+        Optional<Worker> workerOpt = this.workerRepository.findWorkerByEmail(email);
+        if (workerOpt.isPresent()){
+            throw new IllegalArgumentException("User with that mail already exists");
+        }
+        Worker workerToAdd =new Worker();
+        if (email != null && email.length() > 1 && email.contains("@") ) {
+            workerToAdd.setEmail(email);
+        } else {
+            throw new IllegalStateException("email not valid");
+        }
+        if(!password.isEmpty()&&password.equals(confirmPass)){
+            workerToAdd.setPassword(bCryptPasswordEncoder.encode(password));
+        }
+        workerToAdd.setLocked(locked);
+
+        if (firstName != null && firstName.length() > 1) {
+            workerToAdd.setFirstName(firstName);
+        }
+
+        if (lastName != null && lastName.length() > 1 ) {
+            workerToAdd.setLastName(lastName);
+        }
+
+        if (mobile != null && mobile.length() > 0 ) {
+            workerToAdd.setMobile(mobile);
+        }
+
+        workerToAdd.setStatus(status);
+
+        if(parkingZones!=null){
+            List<ParkingZone> parkingZonesAvailable =parkingZoneRepository.findAll();
+            List<ParkingZone> zonesToAdd= new ArrayList<>();
+            workerToAdd.setParkingZones(null);
+            for(String pzName:parkingZones){
+                for(ParkingZone pz :parkingZonesAvailable){
+                    if(pzName.equals(pz.getPzName())) {
+                        zonesToAdd.add(pz);
+//                            pz.getOdgovorniLica().add(vrabotenRepository.findByVrabotenId(vrabotenId));
+                    }
+                }
+            }
+            workerToAdd.setParkingZones(zonesToAdd);
+        }
+        workerRepository.save(workerToAdd);
+        return Optional.of(workerToAdd);
+    }
+
+    @Transactional
+    public WorkerDemoParkingZones updateWorker(int workerId, String password, String confirmPass, boolean locked, String firstName, String lastName, String mobile, String email, EmployeeStatus status, List<String> parkingZones) {
+        Optional<Worker> workerOpt = Optional.ofNullable(this.workerRepository.findByWorkerId(workerId));
+        if (workerOpt.isPresent()) {
+
+            if (email != null && email.length() > 1 && email.contains("@") ) {
+                List<String> emails = workerRepository.findAll().stream().map(Worker::getEmail).collect(Collectors.toList());
+                for(String mailToCheck :emails)
+                if (email.equals(mailToCheck)&&workerOpt.get().getWorkerId()!=workerId) {
+                    throw new IllegalStateException("email taken");
+                }
+                workerOpt.get().setEmail(email);
+            } else {
+                throw new IllegalStateException("email not valid");
+            }
+            if(!password.isEmpty()&&password.equals(confirmPass)){
+                workerOpt.get().setPassword(bCryptPasswordEncoder.encode(password));
+            }
+            workerOpt.get().setLocked(locked);
+
+            if (firstName != null && firstName.length() > 1 && !Objects.equals(workerOpt.get().getFirstName(), firstName)) {
+                workerOpt.get().setFirstName(firstName);
+            }
+
+            if (lastName != null && lastName.length() > 1 && !Objects.equals(workerOpt.get().getLastName(), lastName)) {
+                workerOpt.get().setLastName(lastName);
+            }
+
+            if (mobile != null && mobile.length() > 0 && !Objects.equals(workerOpt.get().getMobile(), mobile)) {
+                workerOpt.get().setMobile(mobile);
+            }
+
+//            if (status != null && status.toString().length() > 0) {
+//                if(Arrays.stream(EmployeeStatus.values()).toList().contains(EmployeeStatus.valueOf(status))){
+            workerOpt.get().setStatus(status);
+//                }else{
+//                    throw new IllegalStateException("Please enter one of the following statuses: 'raboti', 'ne raboti', 'na odmor', 'na boleduvanje'");
+//                }
+//            }
+            if(parkingZones!=null){
+                List<ParkingZone> parkingZonesAvailable =parkingZoneRepository.findAll();
+                List<ParkingZone> zonesToAdd= new ArrayList<>();
+                workerOpt.get().setParkingZones(null);
+                for(String pzName:parkingZones){
+                    for(ParkingZone pz :parkingZonesAvailable){
+                        if(pzName.equals(pz.getPzName())) {
+                            zonesToAdd.add(pz);
+//                            pz.getOdgovorniLica().add(vrabotenRepository.findByVrabotenId(workerId));
+                        }
+                    }
+                }
+                workerOpt.get().setParkingZones(zonesToAdd);
+            }
+//            VrabotenDemoParkingZones zoneToReturn = new VrabotenDemoParkingZones(workerOpt.get());
+            return new WorkerDemoParkingZones(workerOpt.get());
+        }
+        else{
+            throw new IllegalStateException("Worker doesn't exist, therefore can't be updated");
+        }
+    }//za menjanje password da se implementira
+
+    @Transactional
+    public Optional<Worker> deleteWorker(int workerId) {
+        Optional<Worker> workerOpt = Optional.ofNullable(this.workerRepository.findByWorkerId(workerId));
+        if (workerOpt.isPresent()) {
+            this.workerRepository.deleteByWorkerId(workerId);
+        } else {
+            throw new IllegalStateException("Worker doesn't exist, therefore can't be deleted");
+        }
+        return workerOpt;
+    }
+
+    @Transactional
+    public void lockWorkerAcc(int workerId) {
+        Worker workerOpt = this.workerRepository.findByWorkerId(workerId);
+        if (workerOpt !=null) {
+            workerOpt.lockVraboten();
+        } else {
+            throw new IllegalStateException("Worker doesn't exist, therefore his account can't be locked/unlocked");
+        }
+    }
+
+    @Override
+    public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
+        return workerRepository.findWorkerByEmail(email)
+                .orElseThrow(() ->
+                        new UsernameNotFoundException("Email not found"));
+    }
+
+//    @Transactional
+//    public void setVrabotenStatus(int vrabotenId,String vrabotenStatus) {
+//        Vraboten vraboten = vrabotenRepository.findByVrabotenId(vrabotenId);
+//        if(vraboten!=null && value){
+//            vraboten.setStatus(valuee);
+//        }
+//        else {
+//            throw new IllegalStateException(String.format("Vraboten with id %d does not exist.",vrabotenId));
+//        }
+//    }
+}
