diff --git a/pom.xml b/pom.xml index 326e89d..1a98816 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 de.kreth.vaadin.clubhelper @@ -96,6 +98,10 @@ org.hibernate hibernate-core + + org.hibernate + hibernate-java8 + mysql mysql-connector-java diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java index 276aaa8..13c3a3c 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java @@ -24,6 +24,11 @@ public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao super(Person.class); } + @Override + public void save(Person obj) { + super.save(obj); + } + @Override public Person findLoginUser(String username, String password) { TypedQuery query = entityManager.createNamedQuery(Person.QUERY_FINDLOGIN, Person.class); diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java index f35aa72..cd2df3d 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java @@ -9,6 +9,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -42,6 +43,7 @@ public class Person extends BaseEntity implements Serializable { private static final long serialVersionUID = -8361264400619997123L; + @Basic private LocalDate birth; private String prename; diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/ClubhelperMenuBar.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/ClubhelperMenuBar.java index 3d4104a..b8cfc3f 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/ClubhelperMenuBar.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/ClubhelperMenuBar.java @@ -21,7 +21,10 @@ public class ClubhelperMenuBar extends MenuBar { editMenuItem = addItem("Bearbeiten"); viewMenuItem = addItem("Ansicht"); settingsItem = addItem("Einstellungen"); - applyState(initialState); + + if (initialState != null) { + applyState(initialState); + } } public void applyState(MenuItemState state) { diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java index 970eaba..37ab86e 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java @@ -188,6 +188,10 @@ class LoggedinMenuitemState extends LoggedOffState { eventDetailItem.setChecked(true); eventDetailItem.setEnabled(false); } + else if (ClubhelperViews.Systeminfo.equals(view)) { + systeminfoItem.setChecked(true); + systeminfoItem.setEnabled(false); + } } private void show(String preformattedText) { diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java index 9bf60f6..5f8228a 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java @@ -74,10 +74,10 @@ public class ClubhelperNavigation implements ApplicationContextAware { ViewFactory factory = new ViewFactory(page); mainView = factory.createMain(); personEdit = factory.createPersonEdit(); - systemInfo = factory.createSystemInfo(); MenuItemStateFactory menuItemFactory = context.getBean(MenuItemStateFactory.class); setupMenuItemStateFactory(menuItemFactory); + systemInfo = factory.createSystemInfo(menuItemFactory); navi = new ClubNavigator().init(mainUI); ClubhelperMenuBar menuBar = new ClubhelperMenuBar(menuItemFactory.currentState()); @@ -125,8 +125,8 @@ public class ClubhelperNavigation implements ApplicationContextAware { this.page = page; } - public SysteminfoView createSystemInfo() { - return new SysteminfoView(isMobileSize()); + public SysteminfoView createSystemInfo(MenuItemStateFactory menuItemFactory) { + return new SysteminfoView(isMobileSize(), menuItemFactory); } public MainView createMain() { diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/SysteminfoView.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/SysteminfoView.java index 89c8221..68261a7 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/SysteminfoView.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/SysteminfoView.java @@ -19,13 +19,23 @@ import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu.ClubhelperMenuBar; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu.MenuItemState; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu.MenuItemStateFactory; + public class SysteminfoView extends VerticalLayout implements View { private final Grid> valueGrid; private ListDataProvider> entryDataProvider; - public SysteminfoView(boolean mobile) { + private ClubhelperMenuBar menuBar; + + private MenuItemStateFactory menuStateFactory; + + public SysteminfoView(boolean mobile, MenuItemStateFactory menuStateFactory) { + this.menuStateFactory = menuStateFactory; + valueGrid = new Grid<>(); valueGrid.addColumn(Entry::getKey) .setCaption("Schlüssel") @@ -41,6 +51,10 @@ public class SysteminfoView extends VerticalLayout implements View { entryDataProvider = DataProvider.ofCollection(new ArrayList>()); valueGrid.setDataProvider(entryDataProvider); + + menuBar = new ClubhelperMenuBar(null); + addComponent(menuBar); + Label title = new Label("

Systeminformationen

", ContentMode.HTML); addComponent(title); addComponent(valueGrid); @@ -49,6 +63,9 @@ public class SysteminfoView extends VerticalLayout implements View { @Override public void enter(ViewChangeEvent event) { + MenuItemState state = menuStateFactory.currentState(); + menuBar.applyState(state); + Collection> items = entryDataProvider.getItems(); items.clear(); Locale locale = Locale.getDefault(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 895f0e4..db451d9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -7,5 +7,6 @@ spring.datasource.jndi-name=jdbc/clubhelperbackend spring.jpa.open-in-view=false spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect +spring.jpa.properties.hibernate.jdbc.time_zone=UTC spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java index 10f174c..64b8e7e 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java @@ -69,14 +69,16 @@ public class PersonDaoTest { person.setSurname("surname2"); person.setPrename("prename2"); - + person.setBirth(LocalDate.of(2018, 8, 8)); personDao.save(person); }); afterCommit(() -> { - List stored = entityManager.createNamedQuery(Person.QUERY_FINDALL, Person.class).getResultList(); + List stored = entityManager.createNamedQuery(Person.QUERY_FINDALL, Person.class) + .getResultList(); assertEquals(1, stored.size()); - assertEquals(person, stored.get(0)); + Person actual = stored.get(0); + assertEquals(person, actual); }); }