diff --git a/src/main/java/com/primefactorsolutions/model/Assessment.java b/src/main/java/com/primefactorsolutions/model/Assessment.java index c33a415..7ff63ce 100644 --- a/src/main/java/com/primefactorsolutions/model/Assessment.java +++ b/src/main/java/com/primefactorsolutions/model/Assessment.java @@ -25,7 +25,7 @@ public class Assessment extends BaseEntity { private List submissions = new ArrayList<>(); @ManyToOne - private AppUser appUser; + private Candidate candidate; @OneToMany(fetch = FetchType.EAGER, mappedBy = "assessment", cascade = {CascadeType.ALL}) private List assessmentEvents = new ArrayList<>(); diff --git a/src/main/java/com/primefactorsolutions/model/AppUser.java b/src/main/java/com/primefactorsolutions/model/Candidate.java similarity index 78% rename from src/main/java/com/primefactorsolutions/model/AppUser.java rename to src/main/java/com/primefactorsolutions/model/Candidate.java index 83707de..f9f0d73 100644 --- a/src/main/java/com/primefactorsolutions/model/AppUser.java +++ b/src/main/java/com/primefactorsolutions/model/Candidate.java @@ -13,10 +13,10 @@ import java.util.List; @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode(callSuper = true) -public class AppUser extends BaseEntity { +public class Candidate extends BaseEntity { @Column(unique = true) private String email; - @OneToMany(fetch = FetchType.EAGER, mappedBy = "appUser") + @OneToMany(fetch = FetchType.EAGER, mappedBy = "candidate") private List assessments; } diff --git a/src/main/java/com/primefactorsolutions/model/Document.java b/src/main/java/com/primefactorsolutions/model/Document.java new file mode 100644 index 0000000..d162230 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/Document.java @@ -0,0 +1,23 @@ +package com.primefactorsolutions.model; + +import jakarta.annotation.Nullable; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class Document extends BaseEntity { + @Nullable + private String description; + private String location; + private DocumentType documentType; + @ManyToOne + private Employee employee; +} diff --git a/src/main/java/com/primefactorsolutions/model/DocumentType.java b/src/main/java/com/primefactorsolutions/model/DocumentType.java new file mode 100644 index 0000000..645beeb --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/DocumentType.java @@ -0,0 +1,7 @@ +package com.primefactorsolutions.model; + +public enum DocumentType { + ID_CARD, + PAY_STUB, + OTHER +} diff --git a/src/main/java/com/primefactorsolutions/model/Employee.java b/src/main/java/com/primefactorsolutions/model/Employee.java new file mode 100644 index 0000000..dcc7df0 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -0,0 +1,31 @@ +package com.primefactorsolutions.model; + +import io.hypersistence.utils.hibernate.type.json.JsonType; +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.Type; + +import java.time.LocalDate; +import java.util.List; + +@Data +@Entity +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class Employee extends BaseEntity { + private String username; + private String firstName; + private String lastName; + private LocalDate dob; + private String personalEmail; + @Type(JsonType.class) + @Column(columnDefinition = "json") + private List phoneNumbers; + @OneToMany(fetch = FetchType.EAGER, mappedBy = "employee", cascade = {CascadeType.ALL}) + private List documents; + private Role role; +} diff --git a/src/main/java/com/primefactorsolutions/model/PartOfDay.java b/src/main/java/com/primefactorsolutions/model/PartOfDay.java new file mode 100644 index 0000000..d4331a3 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/PartOfDay.java @@ -0,0 +1,6 @@ +package com.primefactorsolutions.model; + +public enum PartOfDay { + MORNING, + AFTERNOON +} diff --git a/src/main/java/com/primefactorsolutions/model/Role.java b/src/main/java/com/primefactorsolutions/model/Role.java new file mode 100644 index 0000000..d37aebd --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/Role.java @@ -0,0 +1,7 @@ +package com.primefactorsolutions.model; + +public enum Role { + ADMIN, + ACCOUNTING, + USER +} diff --git a/src/main/java/com/primefactorsolutions/model/TaskType.java b/src/main/java/com/primefactorsolutions/model/TaskType.java new file mode 100644 index 0000000..90c9224 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/TaskType.java @@ -0,0 +1,17 @@ +package com.primefactorsolutions.model; + +import jakarta.persistence.Entity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class TaskType extends BaseEntity { + private String description; + private int code; +} diff --git a/src/main/java/com/primefactorsolutions/model/TimeOffRequest.java b/src/main/java/com/primefactorsolutions/model/TimeOffRequest.java new file mode 100644 index 0000000..980c612 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/TimeOffRequest.java @@ -0,0 +1,21 @@ +package com.primefactorsolutions.model; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.OneToMany; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Entity +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class TimeOffRequest extends BaseEntity { + @OneToMany(fetch = FetchType.EAGER, mappedBy = "request", cascade = {CascadeType.ALL}) + private List entries; + private TimeOffRequestType type; +} diff --git a/src/main/java/com/primefactorsolutions/model/TimeOffRequestEntry.java b/src/main/java/com/primefactorsolutions/model/TimeOffRequestEntry.java new file mode 100644 index 0000000..a80f4da --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/TimeOffRequestEntry.java @@ -0,0 +1,22 @@ +package com.primefactorsolutions.model; + +import jakarta.annotation.Nullable; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +@Entity +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class TimeOffRequestEntry extends BaseEntity { + private LocalDate date; + @Nullable + private PartOfDay partOfDay; + @ManyToOne + private TimeOffRequest request; +} diff --git a/src/main/java/com/primefactorsolutions/model/TimeOffRequestType.java b/src/main/java/com/primefactorsolutions/model/TimeOffRequestType.java new file mode 100644 index 0000000..1260023 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/TimeOffRequestType.java @@ -0,0 +1,7 @@ +package com.primefactorsolutions.model; + +public enum TimeOffRequestType { + VACATION, + MATERNITY, + OTHER +} diff --git a/src/main/java/com/primefactorsolutions/model/Timesheet.java b/src/main/java/com/primefactorsolutions/model/Timesheet.java new file mode 100644 index 0000000..041cc3c --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/Timesheet.java @@ -0,0 +1,21 @@ +package com.primefactorsolutions.model; + +import io.hypersistence.utils.hibernate.type.json.JsonType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.annotations.Type; + +import java.util.List; + +@Entity +@Data +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class Timesheet extends BaseEntity { + @Type(JsonType.class) + @Column(columnDefinition = "json") + private List entries; +} diff --git a/src/main/java/com/primefactorsolutions/model/TimesheetEntry.java b/src/main/java/com/primefactorsolutions/model/TimesheetEntry.java new file mode 100644 index 0000000..dc09bc4 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/model/TimesheetEntry.java @@ -0,0 +1,13 @@ +package com.primefactorsolutions.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TimesheetEntry { + private TaskType taskType; + private int hours; +} diff --git a/src/main/java/com/primefactorsolutions/repositories/UserRepository.java b/src/main/java/com/primefactorsolutions/repositories/CandidateRepository.java similarity index 51% rename from src/main/java/com/primefactorsolutions/repositories/UserRepository.java rename to src/main/java/com/primefactorsolutions/repositories/CandidateRepository.java index 70f46d0..b4759da 100644 --- a/src/main/java/com/primefactorsolutions/repositories/UserRepository.java +++ b/src/main/java/com/primefactorsolutions/repositories/CandidateRepository.java @@ -1,9 +1,9 @@ package com.primefactorsolutions.repositories; -import com.primefactorsolutions.model.AppUser; +import com.primefactorsolutions.model.Candidate; import org.springframework.data.jpa.repository.JpaRepository; import java.util.UUID; -public interface UserRepository extends JpaRepository { +public interface CandidateRepository extends JpaRepository { } diff --git a/src/main/java/com/primefactorsolutions/service/AssessmentService.java b/src/main/java/com/primefactorsolutions/service/AssessmentService.java index 2c54d00..4b4821d 100644 --- a/src/main/java/com/primefactorsolutions/service/AssessmentService.java +++ b/src/main/java/com/primefactorsolutions/service/AssessmentService.java @@ -38,7 +38,7 @@ public class AssessmentService { final SimpleMailMessage message = new SimpleMailMessage(); message.setFrom("no-reply@primefactorsolutions.com"); message.setBcc("no-reply@primefactorsolutions.com"); - message.setTo(assessment.getAppUser().getEmail()); + message.setTo(assessment.getCandidate().getEmail()); message.setSubject("PFS - Evaluacion Tecnica"); message.setText(String.format("Estimado candidato,\n\nGracias por su candidatura. En esta etapa del proceso de seleccion, usted debe completar " + "una evaluacion tecnica de programacion en JAVA. La prueba tiene una duracion de 30 minutos y puede completarla cuando tenga una buena " @@ -47,9 +47,9 @@ public class AssessmentService { + "Exito!")); emailSender.send(message); - log.info("Sent email to {}", assessment.getAppUser().getEmail()); + log.info("Sent email to {}", assessment.getCandidate().getEmail()); } catch (Exception e) { - log.error("Error sending email to {}", assessment.getAppUser().getEmail(), e); + log.error("Error sending email to {}", assessment.getCandidate().getEmail(), e); throw e; } } @@ -181,11 +181,11 @@ public class AssessmentService { @Transactional public Assessment saveAssessment(final Assessment assessment) { - AppUser merged = entityManager.merge(assessment.getAppUser()); + Candidate merged = entityManager.merge(assessment.getCandidate()); List mergedQuestions = assessment.getQuestions().stream().map(entityManager::merge) .collect(Collectors.toList()); - assessment.setAppUser(merged); + assessment.setCandidate(merged); assessment.setQuestions(mergedQuestions); return assessmentRepository.save(assessment); diff --git a/src/main/java/com/primefactorsolutions/service/CandidateService.java b/src/main/java/com/primefactorsolutions/service/CandidateService.java new file mode 100644 index 0000000..4b0108d --- /dev/null +++ b/src/main/java/com/primefactorsolutions/service/CandidateService.java @@ -0,0 +1,29 @@ +package com.primefactorsolutions.service; + +import com.primefactorsolutions.model.Candidate; +import com.primefactorsolutions.repositories.CandidateRepository; +import lombok.Data; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.UUID; + +@Service +@Data +public class CandidateService { + private final CandidateRepository candidateRepository; + + public Candidate createOrUpdate(final Candidate assessment) { + final Candidate saved = candidateRepository.save(assessment); + + return saved; + } + + public List getCandidates() { + return candidateRepository.findAll(); + } + + public Candidate getCandidate(final UUID id) { + return candidateRepository.findById(id).orElse(null); + } +} diff --git a/src/main/java/com/primefactorsolutions/service/UserService.java b/src/main/java/com/primefactorsolutions/service/UserService.java deleted file mode 100644 index dfb1797..0000000 --- a/src/main/java/com/primefactorsolutions/service/UserService.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.primefactorsolutions.service; - -import com.primefactorsolutions.model.AppUser; -import com.primefactorsolutions.repositories.UserRepository; -import lombok.Data; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.UUID; - -@Service -@Data -public class UserService { - private final UserRepository userRepository; - - public AppUser createOrUpdate(final AppUser assessment) { - final AppUser saved = userRepository.save(assessment); - - return saved; - } - - public List getUsers() { - return userRepository.findAll(); - } - - public AppUser getUser(final UUID id) { - return userRepository.findById(id).orElse(null); - } -} diff --git a/src/main/java/com/primefactorsolutions/views/AssessmentView.java b/src/main/java/com/primefactorsolutions/views/AssessmentView.java index 00800ac..761f069 100644 --- a/src/main/java/com/primefactorsolutions/views/AssessmentView.java +++ b/src/main/java/com/primefactorsolutions/views/AssessmentView.java @@ -1,11 +1,11 @@ package com.primefactorsolutions.views; -import com.primefactorsolutions.model.AppUser; +import com.primefactorsolutions.model.Candidate; import com.primefactorsolutions.model.Assessment; import com.primefactorsolutions.model.Question; import com.primefactorsolutions.service.AssessmentService; import com.primefactorsolutions.service.QuestionService; -import com.primefactorsolutions.service.UserService; +import com.primefactorsolutions.service.CandidateService; import com.vaadin.flow.component.Component; import com.vaadin.flow.component.ItemLabelGenerator; import com.vaadin.flow.component.combobox.ComboBox; @@ -33,17 +33,17 @@ import java.util.UUID; public class AssessmentView extends BeanValidationForm implements HasUrlParameter { private final AssessmentService assessmentService; - private ComboBox appUser = null; + private ComboBox candidate = null; private SubListSelector questions = null; - public AssessmentView(AssessmentService assessmentService, QuestionService questionService, UserService userService) { + public AssessmentView(AssessmentService assessmentService, QuestionService questionService, CandidateService candidateService) { super(Assessment.class); this.assessmentService = assessmentService; - appUser = new ComboBox<>("AppUser", userService.getUsers()); - appUser.setItemLabelGenerator((ItemLabelGenerator) AppUser::getEmail); - appUser.setReadOnly(false); + candidate = new ComboBox<>("Candidate", candidateService.getCandidates()); + candidate.setItemLabelGenerator((ItemLabelGenerator) Candidate::getEmail); + candidate.setReadOnly(false); questions = new SubListSelector<>(Question.class); questions.setItemLabelGenerator((ItemLabelGenerator) Question::getTitle); @@ -69,6 +69,6 @@ public class AssessmentView extends BeanValidationForm implements Ha @Override protected List getFormComponents() { - return List.of(appUser, questions); + return List.of(candidate, questions); } } diff --git a/src/main/java/com/primefactorsolutions/views/AssessmentsListView.java b/src/main/java/com/primefactorsolutions/views/AssessmentsListView.java index 12f0f2f..823898e 100644 --- a/src/main/java/com/primefactorsolutions/views/AssessmentsListView.java +++ b/src/main/java/com/primefactorsolutions/views/AssessmentsListView.java @@ -42,7 +42,7 @@ public class AssessmentsListView extends Main { hl.add(addAssessment); final VGrid grid = new VGrid<>(Assessment.class); - grid.setColumns("id", "appUser.email"); + grid.setColumns("id", "candidate.email"); final Grid.Column statusColumn = grid.addColumn((ValueProvider) assessment -> assessment.getAssessmentEvents().isEmpty() ? "N/A" @@ -61,13 +61,13 @@ public class AssessmentsListView extends Main { grid.addComponentColumn((ValueProvider) assessment -> new Button("Copy Link", event -> ClientsideClipboard.writeToClipboard( String.format("email: %s link: https://careers.primefactorsolutions.com/evaluation/%s", - assessment.getAppUser().getEmail(), + assessment.getCandidate().getEmail(), assessment.getId())) )); grid.addComponentColumn((ValueProvider) assessment -> new Button("Send Email", event -> { ConfirmDialog dialog = new ConfirmDialog(); dialog.setHeader("Send Link Email"); - dialog.setText(String.format("Enviar link por email al candidato %s?", assessment.getAppUser().getEmail())); + dialog.setText(String.format("Enviar link por email al candidato %s?", assessment.getCandidate().getEmail())); dialog.setCancelable(true); dialog.setConfirmText("Enviar"); dialog.setConfirmButtonTheme("primary"); diff --git a/src/main/java/com/primefactorsolutions/views/CalendarView.java b/src/main/java/com/primefactorsolutions/views/CalendarView.java new file mode 100644 index 0000000..c8d02fb --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/CalendarView.java @@ -0,0 +1,4 @@ +package com.primefactorsolutions.views; + +public class CalendarView { +} diff --git a/src/main/java/com/primefactorsolutions/views/UserView.java b/src/main/java/com/primefactorsolutions/views/CandidateView.java similarity index 59% rename from src/main/java/com/primefactorsolutions/views/UserView.java rename to src/main/java/com/primefactorsolutions/views/CandidateView.java index fdd6898..ff2568b 100644 --- a/src/main/java/com/primefactorsolutions/views/UserView.java +++ b/src/main/java/com/primefactorsolutions/views/CandidateView.java @@ -1,7 +1,7 @@ package com.primefactorsolutions.views; -import com.primefactorsolutions.model.AppUser; -import com.primefactorsolutions.service.UserService; +import com.primefactorsolutions.model.Candidate; +import com.primefactorsolutions.service.CandidateService; import com.vaadin.flow.component.Component; import com.vaadin.flow.component.textfield.EmailField; import com.vaadin.flow.router.BeforeEvent; @@ -20,22 +20,22 @@ import java.util.UUID; @SpringComponent @Scope("prototype") @PageTitle("Assessments") -@Route(value = "/users", layout = MainLayout.class) +@Route(value = "/candidates", layout = MainLayout.class) @PermitAll -public class UserView extends BeanValidationForm implements HasUrlParameter { - private final UserService userService; +public class CandidateView extends BeanValidationForm implements HasUrlParameter { + private final CandidateService candidateService; private EmailField email = null; - public UserView(final UserService userService) { - super(AppUser.class); - this.userService = userService; + public CandidateView(final CandidateService candidateService) { + super(Candidate.class); + this.candidateService = candidateService; email = new EmailField(); email.setWidthFull(); email.setLabel("Email"); - setSavedHandler((SavedHandler) appUser -> { - final AppUser saved = userService.createOrUpdate(appUser); + setSavedHandler((SavedHandler) candidate -> { + final Candidate saved = candidateService.createOrUpdate(candidate); setEntityWithEnabledSave(saved); }); } @@ -43,10 +43,10 @@ public class UserView extends BeanValidationForm implements HasUrlParam @Override public void setParameter(final BeforeEvent beforeEvent, final String s) { if (StringUtils.isNotBlank(s) && !"new".equals(s)) { - var user = userService.getUser(UUID.fromString(s)); - setEntityWithEnabledSave(user); + var candidate = candidateService.getCandidate(UUID.fromString(s)); + setEntityWithEnabledSave(candidate); } else { - setEntityWithEnabledSave(new AppUser()); + setEntityWithEnabledSave(new Candidate()); } } diff --git a/src/main/java/com/primefactorsolutions/views/UsersListView.java b/src/main/java/com/primefactorsolutions/views/CandidatesListView.java similarity index 60% rename from src/main/java/com/primefactorsolutions/views/UsersListView.java rename to src/main/java/com/primefactorsolutions/views/CandidatesListView.java index 98f586a..af470b9 100644 --- a/src/main/java/com/primefactorsolutions/views/UsersListView.java +++ b/src/main/java/com/primefactorsolutions/views/CandidatesListView.java @@ -1,7 +1,7 @@ package com.primefactorsolutions.views; -import com.primefactorsolutions.model.AppUser; -import com.primefactorsolutions.service.UserService; +import com.primefactorsolutions.model.Candidate; +import com.primefactorsolutions.service.CandidateService; import com.vaadin.flow.component.ClickEvent; import com.vaadin.flow.component.Component; import com.vaadin.flow.component.ComponentEventListener; @@ -24,29 +24,29 @@ import java.util.stream.Stream; @SpringComponent @Scope("prototype") -@PageTitle("Users") -@Route(value = "/users", layout = MainLayout.class) +@PageTitle("Candidates") +@Route(value = "/candidates", layout = MainLayout.class) @PermitAll -public class UsersListView extends Main { - final UserService userService; +public class CandidatesListView extends Main { + final CandidateService candidateService; - public UsersListView(final UserService userService) { - this.userService = userService; + public CandidatesListView(final CandidateService candidateService) { + this.candidateService = candidateService; final HorizontalLayout hl = new HorizontalLayout(); - final Button addUser = new Button("Add User"); - addUser.addClickListener((ComponentEventListener>) buttonClickEvent -> { - this.getUI().get().navigate(UserView.class, "new"); + final Button addCandidate = new Button("Add Candidate"); + addCandidate.addClickListener((ComponentEventListener>) buttonClickEvent -> { + this.getUI().get().navigate(CandidateView.class, "new"); }); - hl.add(addUser); + hl.add(addCandidate); - final VGrid grid = new VGrid<>(AppUser.class); + final VGrid grid = new VGrid<>(Candidate.class); grid.setColumns("id", "email"); grid.setAllRowsVisible(true); - grid.addComponentColumn((ValueProvider) appUser -> { + grid.addComponentColumn((ValueProvider) candidate -> { final Button edit = new Button("Edit"); edit.addClickListener((ComponentEventListener>) buttonClickEvent -> - this.getUI().get().navigate(UserView.class, appUser.getId().toString())); + this.getUI().get().navigate(CandidateView.class, candidate.getId().toString())); return edit; }); @@ -57,20 +57,20 @@ public class UsersListView extends Main { } @Override - public int size(Query query) { - return userService.getUsers().size(); + public int size(Query query) { + return candidateService.getCandidates().size(); } @Override - public Stream fetch(Query query) { + public Stream fetch(Query query) { int limit = query.getLimit(); int pagerSize = query.getPageSize(); int page = query.getPage(); - return userService.getUsers().stream(); + return candidateService.getCandidates().stream(); } @Override - public void refreshItem(AppUser appUser) { + public void refreshItem(Candidate candidate) { } @@ -80,7 +80,7 @@ public class UsersListView extends Main { } @Override - public Registration addDataProviderListener(DataProviderListener dataProviderListener) { + public Registration addDataProviderListener(DataProviderListener dataProviderListener) { return null; } }); diff --git a/src/main/java/com/primefactorsolutions/views/EvaluationView.java b/src/main/java/com/primefactorsolutions/views/EvaluationView.java index f549cb6..84d6122 100644 --- a/src/main/java/com/primefactorsolutions/views/EvaluationView.java +++ b/src/main/java/com/primefactorsolutions/views/EvaluationView.java @@ -254,7 +254,7 @@ public class EvaluationView extends Main implements HasUrlParameter { log.info(">>> start"); this.assessment = this.assessmentService.startAssessment(this.assessment.getId()); - if (tf.getValue().trim().equalsIgnoreCase(this.assessment.getAppUser().getEmail())) { + if (tf.getValue().trim().equalsIgnoreCase(this.assessment.getCandidate().getEmail())) { this.getUI().get().getPage().reload(); } else { Notification notification = new Notification(); @@ -389,7 +389,7 @@ public class EvaluationView extends Main implements HasUrlParameter { if (dl.getChildren().collect(Collectors.toList()).isEmpty()) { dl.add( - createItem("Candidato:", assessment.getAppUser().getEmail()), + createItem("Candidato:", assessment.getCandidate().getEmail()), createItem("Hora de inicio:", Optional.ofNullable(assessment.getStartingTime()) .map(t -> ZonedDateTime.ofInstant(t, ZoneId.of("GMT-4")).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)) .orElse("N/A")) diff --git a/src/main/java/com/primefactorsolutions/views/MainLayout.java b/src/main/java/com/primefactorsolutions/views/MainLayout.java index b57e8d2..53d28d7 100644 --- a/src/main/java/com/primefactorsolutions/views/MainLayout.java +++ b/src/main/java/com/primefactorsolutions/views/MainLayout.java @@ -54,10 +54,26 @@ public class MainLayout extends AppLayout { SideNav nav = new SideNav(); authContext.getAuthenticatedUser(UserDetails.class).ifPresent(u -> { + SideNavItem recruiting = new SideNavItem("Recruiting", MainView.class, LineAwesomeIcon.BUSINESS_TIME_SOLID.create()); + recruiting.addItem(new SideNavItem("Assessments", AssessmentsListView.class, LineAwesomeIcon.RIBBON_SOLID.create())); + recruiting.addItem(new SideNavItem("Candidates", CandidatesListView.class, LineAwesomeIcon.USER.create())); + recruiting.addItem(new SideNavItem("Questions", QuestionsListView.class, LineAwesomeIcon.QUESTION_SOLID.create())); + + SideNavItem admin = new SideNavItem("Admin", MainView.class, LineAwesomeIcon.SUITCASE_SOLID.create()); + admin.addItem(new SideNavItem("Time-off requests", AssessmentsListView.class, LineAwesomeIcon.THEMEISLE.create())); + admin.addItem(new SideNavItem("Timesheets", CandidatesListView.class, LineAwesomeIcon.HOURGLASS_END_SOLID.create())); + admin.addItem(new SideNavItem("Employees", QuestionsListView.class, LineAwesomeIcon.USER_EDIT_SOLID.create())); + + SideNavItem timeOff = new SideNavItem("My Time-off", MainView.class, LineAwesomeIcon.THEMEISLE.create()); + SideNavItem timesheet = new SideNavItem("My Timesheet", MainView.class, LineAwesomeIcon.HOURGLASS_START_SOLID.create()); + SideNavItem profile = new SideNavItem("My Profile", MainView.class, LineAwesomeIcon.USER_EDIT_SOLID.create()); + nav.addItem(new SideNavItem("Home", MainView.class, LineAwesomeIcon.HOME_SOLID.create())); - nav.addItem(new SideNavItem("Assessments", AssessmentsListView.class, LineAwesomeIcon.RIBBON_SOLID.create())); - nav.addItem(new SideNavItem("Users", UsersListView.class, LineAwesomeIcon.USER.create())); - nav.addItem(new SideNavItem("Questions", QuestionsListView.class, LineAwesomeIcon.QUESTION_SOLID.create())); + nav.addItem(admin); + nav.addItem(recruiting); + nav.addItem(profile); + nav.addItem(timesheet); + nav.addItem(timeOff); }); return nav; diff --git a/src/main/java/com/primefactorsolutions/views/QuestionView.java b/src/main/java/com/primefactorsolutions/views/QuestionView.java index e2a41dd..9050919 100644 --- a/src/main/java/com/primefactorsolutions/views/QuestionView.java +++ b/src/main/java/com/primefactorsolutions/views/QuestionView.java @@ -56,8 +56,8 @@ public class QuestionView extends BeanValidationForm implements HasUrl @Override public void setParameter(final BeforeEvent beforeEvent, final String s) { if (StringUtils.isNotBlank(s) && !"new".equals(s)) { - var user = questionService.getQuestion(UUID.fromString(s)); - setEntityWithEnabledSave(user); + var question = questionService.getQuestion(UUID.fromString(s)); + setEntityWithEnabledSave(question); } else if ("new".equals(s)) { setEntityWithEnabledSave(new Question()); } else { diff --git a/src/main/java/com/primefactorsolutions/views/SubmissionView.java b/src/main/java/com/primefactorsolutions/views/SubmissionView.java index 1a33fa0..9672dd5 100644 --- a/src/main/java/com/primefactorsolutions/views/SubmissionView.java +++ b/src/main/java/com/primefactorsolutions/views/SubmissionView.java @@ -221,7 +221,7 @@ public class SubmissionView extends Main implements HasUrlParameter { if (dl.getChildren().collect(Collectors.toList()).isEmpty()) { dl.add( - createItem("Candidato:", assessment.getAppUser().getEmail()), + createItem("Candidato:", assessment.getCandidate().getEmail()), createItem("Hora de inicio:", Optional.ofNullable(assessment.getStartingTime()) .map(t -> ZonedDateTime.ofInstant(t, ZoneId.of("GMT-4")).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)) .orElse("N/A")) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f468332..71a5dac 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -19,12 +19,13 @@ spring.mail.properties.mail.smtp.starttls.required=true # spring.datasource.url=jdbc:h2:mem:testdb # spring.datasource.url=jdbc:h2:file:./db -spring.datasource.url=jdbc:h2:file:/var/opt/pfs/db +# spring.datasource.url=jdbc:h2:file:/var/opt/pfs/db +spring.datasource.url=${DB_URL:jdbc:h2:mem:testdb} spring.jpa.hibernate.ddl-auto=update spring.sql.init.mode=${SQL_INIT:embedded} spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa -spring.datasource.password=${H2_PASS} +spring.datasource.password=${H2_PASS:sa} spring.h2.console.settings.web-allow-others=true spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.jpa.defer-datasource-initialization = true diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 31fd2f6..cc682ab 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1,9 +1,9 @@ -insert into app_user (id, version, email) values ('23471ab3-f639-4d2b-9541-7227f4ea7ee6', 1, 'foo@bar.com'); +insert into candidate (id, version, email) values ('23471ab3-f639-4d2b-9541-7227f4ea7ee6', 1, 'foo@bar.com'); insert into question (id, version, content, title, description) values ('a7e00ff8-da41-4624-b31c-1b13c3f2e3ae', 1, 'foo bar', 'q1', 'lorem ipsum'); insert into question (id, version, content, title, description) values ('8a4b213c-ca81-4c38-b56d-d7028c2dde88', 1, 'foo buzz', 'q2', 'lorem ipsum'); -insert into assessment(id, version, app_user_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', 1, '23471ab3-f639-4d2b-9541-7227f4ea7ee6'); +insert into assessment(id, version, candidate_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', 1, '23471ab3-f639-4d2b-9541-7227f4ea7ee6'); insert into ASSESSMENT_QUESTIONS (assessment_id, question_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', 'a7e00ff8-da41-4624-b31c-1b13c3f2e3ae');