From 49dc6421f52a43c451f1977577fc79673e201b99 Mon Sep 17 00:00:00 2001 From: ricardo051199 Date: Wed, 4 Sep 2024 12:44:47 -0400 Subject: [PATCH] Correccion de estilo de codigo --- .../primefactorsolutions/model/Employee.java | 10 +++------- .../service/EmployeeService.java | 7 ++++--- .../views/EmployeeView.java | 4 ++-- .../views/EmployeesListView.java | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/model/Employee.java b/src/main/java/com/primefactorsolutions/model/Employee.java index 94fce40..c6d918b 100644 --- a/src/main/java/com/primefactorsolutions/model/Employee.java +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -1,16 +1,12 @@ 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 @@ -45,7 +41,7 @@ public Status getStatus() { return status; } - public void setStatus(Status status) { + public void setStatus(final Status status) { this.status = status; } } diff --git a/src/main/java/com/primefactorsolutions/service/EmployeeService.java b/src/main/java/com/primefactorsolutions/service/EmployeeService.java index da815d9..993eecd 100644 --- a/src/main/java/com/primefactorsolutions/service/EmployeeService.java +++ b/src/main/java/com/primefactorsolutions/service/EmployeeService.java @@ -16,11 +16,12 @@ import java.util.Collections; public class EmployeeService { private final EmployeeRepository employeeRepository; - public EmployeeService(EmployeeRepository employeeRepository) { + public EmployeeService(final EmployeeRepository employeeRepository) { this.employeeRepository = employeeRepository; } - public List findEmployees(int start, int pageSize, String sortProperty, boolean asc) { + public List findEmployees( + final int start, final int pageSize, final String sortProperty, final boolean asc) { List employees = employeeRepository.findAll(); int end = Math.min(start + pageSize, employees.size()); @@ -33,7 +34,7 @@ public class EmployeeService { return employees.subList(start, end); } - public List findEmployees(int start, int pageSize) { + public List findEmployees(final int start, final int pageSize) { List employees = employeeRepository.findAll(); int end = Math.min(start + pageSize, employees.size()); diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index d2a570e..9e49fe4 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -145,11 +145,11 @@ public class EmployeeView extends BeanValidationForm implements HasUrl setSavedHandler((SavedHandler) employee -> { if (validateForm()) { final Employee saved = employeeService.createOrUpdate(employee); - Notification.show("Empleado guardado exitosamente."); + Notification.show("Employee saved successfully."); getUI().ifPresent(ui -> ui.navigate(EmployeesListView.class)); setEntityWithEnabledSave(saved); } else { - Notification.show("Acción inválida. Por favor, complete todos los campos requeridos correctamente.", 3000, Notification.Position.MIDDLE); + Notification.show("Please complete the required fields correctly.", 3000, Notification.Position.MIDDLE); } }); diff --git a/src/main/java/com/primefactorsolutions/views/EmployeesListView.java b/src/main/java/com/primefactorsolutions/views/EmployeesListView.java index b91c03c..489ded8 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeesListView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeesListView.java @@ -27,7 +27,7 @@ public class EmployeesListView extends Main { private final EmployeeService employeeService; private final PagingGrid table = new PagingGrid<>(Employee.class); - public EmployeesListView(EmployeeService employeeService) { + public EmployeesListView(final EmployeeService employeeService) { this.employeeService = employeeService; setupView(); refreshGrid(); @@ -46,17 +46,17 @@ public class EmployeesListView extends Main { setupPagingGrid(); } - private void updateEmployeeStatus(Employee employee, boolean isActive) { + private void updateEmployeeStatus(final Employee employee, final boolean isActive) { employee.setStatus(isActive ? Employee.Status.ACTIVE : Employee.Status.INACTIVE); employeeService.createOrUpdate(employee); refreshGrid(); } - private void addEditButtonColumn(String label, ButtonClickHandler handler) { + private void addEditButtonColumn(final String label, final ButtonClickHandler handler) { table.addComponentColumn(employee -> createButton(label, () -> handler.handle(employee))); } - private Button createButton(String label, Runnable onClickAction) { + private Button createButton(final String label, final Runnable onClickAction) { Button button = new Button(label); button.addClickListener(event -> onClickAction.run()); return button; @@ -66,7 +66,7 @@ public class EmployeesListView extends Main { return createButton("Add Employee", this::navigateToAddEmployeeView); } - private void navigateToEditView(Employee employee) { + private void navigateToEditView(final Employee employee) { getUI().ifPresent(ui -> ui.navigate(EmployeeView.class, employee.getId().toString())); } @@ -83,7 +83,7 @@ public class EmployeesListView extends Main { table.setPagingDataProvider((page, pageSize) -> fetchEmployees((int) page, pageSize)); } - private List fetchEmployees(int page, int pageSize) { + private List fetchEmployees(final int page, final int pageSize) { int start = page * pageSize; if (hasSortOrder()) { return fetchSortedEmployees(start, pageSize); @@ -95,9 +95,11 @@ public class EmployeesListView extends Main { return !table.getSortOrder().isEmpty(); } - private List fetchSortedEmployees(int start, int pageSize) { + private List fetchSortedEmployees(final int start, final int pageSize) { GridSortOrder sortOrder = table.getSortOrder().getFirst(); - return employeeService.findEmployees(start, pageSize, sortOrder.getSorted().getKey(), sortOrder.getDirection() == SortDirection.ASCENDING); + return employeeService.findEmployees(start, pageSize, + sortOrder.getSorted().getKey(), + sortOrder.getDirection() == SortDirection.ASCENDING); } @FunctionalInterface