fix: services and repositories naming a packaging

This commit is contained in:
filippo-ferrari 2024-05-18 20:31:57 +02:00
parent 80fb068af4
commit 2e97e866d5
4 changed files with 18 additions and 16 deletions

View file

@ -1,6 +1,6 @@
package com.application.munera;
import com.application.munera.data.SamplePersonRepository;
import com.application.munera.repositories.ExpenseRepository;
import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.theme.Theme;
import javax.sql.DataSource;
@ -27,7 +27,7 @@ public class Application implements AppShellConfigurator {
@Bean
SqlDataSourceScriptDatabaseInitializer dataSourceScriptDatabaseInitializer(DataSource dataSource,
SqlInitializationProperties properties, SamplePersonRepository repository) {
SqlInitializationProperties properties, ExpenseRepository repository) {
// This bean ensures the database is only initialized when empty
return new SqlDataSourceScriptDatabaseInitializer(dataSource, properties) {
@Override

View file

@ -1,10 +1,11 @@
package com.application.munera.data;
package com.application.munera.repositories;
import com.application.munera.data.Expense;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface SamplePersonRepository
public interface ExpenseRepository
extends
JpaRepository<Expense, Long>,
JpaSpecificationExecutor<Expense> {

View file

@ -1,19 +1,20 @@
package com.application.munera.services;
import com.application.munera.data.Expense;
import com.application.munera.data.SamplePersonRepository;
import java.util.Optional;
import com.application.munera.repositories.ExpenseRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class SamplePersonService {
public class ExpenseService {
private final SamplePersonRepository repository;
private final ExpenseRepository repository;
public SamplePersonService(SamplePersonRepository repository) {
public ExpenseService(ExpenseRepository repository) {
this.repository = repository;
}

View file

@ -1,7 +1,7 @@
package com.application.munera.views.expenses;
import com.application.munera.data.Expense;
import com.application.munera.services.SamplePersonService;
import com.application.munera.services.ExpenseService;
import com.application.munera.views.MainLayout;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
@ -52,10 +52,10 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
private Expense expense;
private final SamplePersonService samplePersonService;
private final ExpenseService expenseService;
public ExpensesView(SamplePersonService samplePersonService) {
this.samplePersonService = samplePersonService;
public ExpensesView(ExpenseService expenseService) {
this.expenseService = expenseService;
addClassNames("expenses-view");
// Create UI
@ -82,7 +82,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
//
// grid.addColumn(importantRenderer).setHeader("Important").setAutoWidth(true);
grid.setItems(query -> samplePersonService.list(
grid.setItems(query -> expenseService.list(
PageRequest.of(query.getPage(), query.getPageSize(), VaadinSpringDataHelpers.toSpringDataSort(query)))
.stream());
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER);
@ -115,7 +115,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
this.expense = new Expense();
}
binder.writeBean(this.expense);
samplePersonService.update(this.expense);
expenseService.update(this.expense);
clearForm();
refreshGrid();
Notification.show("Data updated");
@ -135,7 +135,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
public void beforeEnter(BeforeEnterEvent event) {
Optional<Long> samplePersonId = event.getRouteParameters().get(SAMPLEPERSON_ID).map(Long::parseLong);
if (samplePersonId.isPresent()) {
Optional<Expense> samplePersonFromBackend = samplePersonService.get(samplePersonId.get());
Optional<Expense> samplePersonFromBackend = expenseService.get(samplePersonId.get());
if (samplePersonFromBackend.isPresent()) {
populateForm(samplePersonFromBackend.get());
} else {