diff --git a/src/main/java/com/application/munera/Application.java b/src/main/java/com/application/munera/Application.java index 44f6a3b..ea681e3 100644 --- a/src/main/java/com/application/munera/Application.java +++ b/src/main/java/com/application/munera/Application.java @@ -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 diff --git a/src/main/java/com/application/munera/data/SamplePersonRepository.java b/src/main/java/com/application/munera/repositories/ExpenseRepository.java similarity index 66% rename from src/main/java/com/application/munera/data/SamplePersonRepository.java rename to src/main/java/com/application/munera/repositories/ExpenseRepository.java index be33666..12391c1 100644 --- a/src/main/java/com/application/munera/data/SamplePersonRepository.java +++ b/src/main/java/com/application/munera/repositories/ExpenseRepository.java @@ -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, JpaSpecificationExecutor { diff --git a/src/main/java/com/application/munera/services/SamplePersonService.java b/src/main/java/com/application/munera/services/ExpenseService.java similarity index 81% rename from src/main/java/com/application/munera/services/SamplePersonService.java rename to src/main/java/com/application/munera/services/ExpenseService.java index 7fb62c3..b6660f0 100644 --- a/src/main/java/com/application/munera/services/SamplePersonService.java +++ b/src/main/java/com/application/munera/services/ExpenseService.java @@ -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; } diff --git a/src/main/java/com/application/munera/views/expenses/ExpensesView.java b/src/main/java/com/application/munera/views/expenses/ExpensesView.java index 4e346fc..eb127b5 100644 --- a/src/main/java/com/application/munera/views/expenses/ExpensesView.java +++ b/src/main/java/com/application/munera/views/expenses/ExpensesView.java @@ -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 samplePersonId = event.getRouteParameters().get(SAMPLEPERSON_ID).map(Long::parseLong); if (samplePersonId.isPresent()) { - Optional samplePersonFromBackend = samplePersonService.get(samplePersonId.get()); + Optional samplePersonFromBackend = expenseService.get(samplePersonId.get()); if (samplePersonFromBackend.isPresent()) { populateForm(samplePersonFromBackend.get()); } else {