fix: services and repositories naming a packaging
This commit is contained in:
parent
80fb068af4
commit
2e97e866d5
4 changed files with 18 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
||||||
package com.application.munera;
|
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.component.page.AppShellConfigurator;
|
||||||
import com.vaadin.flow.theme.Theme;
|
import com.vaadin.flow.theme.Theme;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
@ -27,7 +27,7 @@ public class Application implements AppShellConfigurator {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
SqlDataSourceScriptDatabaseInitializer dataSourceScriptDatabaseInitializer(DataSource dataSource,
|
SqlDataSourceScriptDatabaseInitializer dataSourceScriptDatabaseInitializer(DataSource dataSource,
|
||||||
SqlInitializationProperties properties, SamplePersonRepository repository) {
|
SqlInitializationProperties properties, ExpenseRepository repository) {
|
||||||
// This bean ensures the database is only initialized when empty
|
// This bean ensures the database is only initialized when empty
|
||||||
return new SqlDataSourceScriptDatabaseInitializer(dataSource, properties) {
|
return new SqlDataSourceScriptDatabaseInitializer(dataSource, properties) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
public interface SamplePersonRepository
|
public interface ExpenseRepository
|
||||||
extends
|
extends
|
||||||
JpaRepository<Expense, Long>,
|
JpaRepository<Expense, Long>,
|
||||||
JpaSpecificationExecutor<Expense> {
|
JpaSpecificationExecutor<Expense> {
|
|
@ -1,19 +1,20 @@
|
||||||
package com.application.munera.services;
|
package com.application.munera.services;
|
||||||
|
|
||||||
import com.application.munera.data.Expense;
|
import com.application.munera.data.Expense;
|
||||||
import com.application.munera.data.SamplePersonRepository;
|
import com.application.munera.repositories.ExpenseRepository;
|
||||||
import java.util.Optional;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@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;
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.application.munera.views.expenses;
|
package com.application.munera.views.expenses;
|
||||||
|
|
||||||
import com.application.munera.data.Expense;
|
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.application.munera.views.MainLayout;
|
||||||
import com.vaadin.flow.component.UI;
|
import com.vaadin.flow.component.UI;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
@ -52,10 +52,10 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
|
|
||||||
private Expense expense;
|
private Expense expense;
|
||||||
|
|
||||||
private final SamplePersonService samplePersonService;
|
private final ExpenseService expenseService;
|
||||||
|
|
||||||
public ExpensesView(SamplePersonService samplePersonService) {
|
public ExpensesView(ExpenseService expenseService) {
|
||||||
this.samplePersonService = samplePersonService;
|
this.expenseService = expenseService;
|
||||||
addClassNames("expenses-view");
|
addClassNames("expenses-view");
|
||||||
|
|
||||||
// Create UI
|
// Create UI
|
||||||
|
@ -82,7 +82,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
//
|
//
|
||||||
// grid.addColumn(importantRenderer).setHeader("Important").setAutoWidth(true);
|
// 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)))
|
PageRequest.of(query.getPage(), query.getPageSize(), VaadinSpringDataHelpers.toSpringDataSort(query)))
|
||||||
.stream());
|
.stream());
|
||||||
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER);
|
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER);
|
||||||
|
@ -115,7 +115,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
this.expense = new Expense();
|
this.expense = new Expense();
|
||||||
}
|
}
|
||||||
binder.writeBean(this.expense);
|
binder.writeBean(this.expense);
|
||||||
samplePersonService.update(this.expense);
|
expenseService.update(this.expense);
|
||||||
clearForm();
|
clearForm();
|
||||||
refreshGrid();
|
refreshGrid();
|
||||||
Notification.show("Data updated");
|
Notification.show("Data updated");
|
||||||
|
@ -135,7 +135,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
public void beforeEnter(BeforeEnterEvent event) {
|
public void beforeEnter(BeforeEnterEvent event) {
|
||||||
Optional<Long> samplePersonId = event.getRouteParameters().get(SAMPLEPERSON_ID).map(Long::parseLong);
|
Optional<Long> samplePersonId = event.getRouteParameters().get(SAMPLEPERSON_ID).map(Long::parseLong);
|
||||||
if (samplePersonId.isPresent()) {
|
if (samplePersonId.isPresent()) {
|
||||||
Optional<Expense> samplePersonFromBackend = samplePersonService.get(samplePersonId.get());
|
Optional<Expense> samplePersonFromBackend = expenseService.get(samplePersonId.get());
|
||||||
if (samplePersonFromBackend.isPresent()) {
|
if (samplePersonFromBackend.isPresent()) {
|
||||||
populateForm(samplePersonFromBackend.get());
|
populateForm(samplePersonFromBackend.get());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue