Logging optimized, Extracted personBusiness from UI

master
Markus Kreth 6 years ago
parent b988036706
commit 5d29a2d3fb
  1. 12
      .classpath
  2. 2
      .settings/com.vaadin.integration.eclipse.prefs
  3. 21
      .settings/org.eclipse.wst.common.component
  4. 21
      src/main/java/Main.java
  5. 1
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java
  6. 60
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/PersonBusiness.java
  7. 1
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDao.java
  8. 1
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java
  9. 12
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/AbstractDataGrid.java
  10. 13
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/ContactGrid.java
  11. 17
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventDetails.java
  12. 60
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDetails.java
  13. 19
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonFilter.java
  14. 45
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java
  15. 7
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/RelationComponent.java
  16. 18
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java
  17. 6
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/LoginUI.java
  18. 12
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainView.java
  19. 6
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainViewDesktop.java
  20. 6
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainViewMobile.java
  21. 39
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/PersonEditView.java
  22. 12
      src/main/resources/log4j2.xml
  23. 4
      src/test/java/de/kreth/vaadin/clubhelper/AbstractHibernateConfiguration.java
  24. 4
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonFilterTest.java
  25. 4
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/LoginUITest.java
  26. 4
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainViewDesktopSmokeTest.java
  27. 4
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainViewMobileSmokeTest.java

@ -14,28 +14,28 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-resources/gwt">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

@ -1,4 +1,4 @@
com.vaadin.integration.eclipse.mavenLatestVersionsUpgrade=["8.6.4","8.8.3"]
com.vaadin.integration.eclipse.mavenLatestVersionsUpgrade=["8.6.4","8.8.6"]
com.vaadin.integration.eclipse.previousCompileAction=both
com.vaadin.integration.eclipse.useLatestNightly=false
com.vaadin.integration.eclipse.widgetsetDirty=true

@ -10,10 +10,10 @@
<wb-module deploy-name="vaadin-clubhelper-1.1.1-SNAPSHOT">
<wb-module deploy-name="vaadin-clubhelper-1.1.1-SNAPSHOT">
@ -22,19 +22,18 @@
<wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -44,9 +43,10 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -60,6 +60,7 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-resources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
@ -74,6 +75,9 @@
<property name="context-root" value="vaadin-clubhelper"/>
@ -86,6 +90,9 @@
<property name="java-output-path" value="/vaadin-clubhelper/target/classes"/>
@ -98,6 +105,9 @@
</wb-module>
@ -110,4 +120,7 @@
</project-modules>

@ -1,21 +0,0 @@
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import com.mysql.cj.jdbc.MysqlDataSource;
public class Main {
public static void main(String[] args) throws SQLException {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setUrl(
"jdbc:mysql://localhost:3306/clubhelper?useSSL=FALSE&useUnicode=yes&characterEncoding=utf8&serverTimezone=UTC");
dataSource.setUser("root");
dataSource.setPassword("07!73");
try (Connection conn = dataSource.getConnection()) {
DatabaseMetaData meta = conn.getMetaData();
System.out.println(meta);
}
}
}

@ -87,6 +87,7 @@ public class EventBusiness {
public void storeAltersgruppe(Altersgruppe edited) {
altersgruppeDao.save(edited);
clubEventDao.save(current);
log.info("Stored {}", edited);
}
public EventMeldung createMeldung() {

@ -0,0 +1,60 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.business;
import java.util.Collection;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relation;
@Component
public class PersonBusiness {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private PersonDao dao;
public void save(Person edited) {
dao.save(edited);
log.info("Saved {}", edited);
}
public void delete(Contact c) {
dao.delete(c);
log.info("Deleted {}", c);
}
public Collection<? extends Relation> findRelationsFor(Person person) {
log.info("Loading relations of {}", person);
return dao.findRelationsFor(person);
}
public void delete(Adress a) {
dao.delete(a);
log.info("Deleted {}", a);
}
public List<Person> listAll() {
log.info("Loading all Persons");
return dao.listAll();
}
public void delete(Person c) {
dao.delete(c);
log.info("Deleted {}", c);
}
public Person findLoginUser(String username, String password) {
log.info("Identifiing Login for user {}", username);
return dao.findLoginUser(username, password);
}
}

@ -28,4 +28,5 @@ public interface PersonDao extends IDao<Person> {
void delete(Person p);
void delete(Adress a);
}

@ -133,4 +133,5 @@ public class PersonDaoImpl extends AbstractDaoImpl<Person> implements PersonDao
Person person = a.getPerson();
person.getAdresses().remove(a);
}
}

@ -30,17 +30,24 @@ public abstract class AbstractDataGrid<T> extends VerticalLayout {
private static final long serialVersionUID = -3404971410481135696L;
private final Grid<T> grid;
private final List<T> source;
private final ListDataProvider<T> dataProvider;
private boolean hasChanges;
private Column<T, Component> deleteButtonColumn;
private Consumer<T> deleteConsumer;
private final List<Consumer<T>> successConsumers;
private final HorizontalLayout buttonLayout;
private final Button addButton;
public AbstractDataGrid() {
protected AbstractDataGrid() {
this.grid = new Grid<>();
this.source = new ArrayList<>();
successConsumers = new ArrayList<>();
@ -110,7 +117,8 @@ public abstract class AbstractDataGrid<T> extends VerticalLayout {
this.deleteConsumer = deleteConsumer;
if (deleteConsumer != null) {
deleteButtonColumn.setHidden(false);
} else {
}
else {
deleteButtonColumn.setHidden(true);
}
}

@ -24,6 +24,7 @@ public class ContactGrid extends AbstractDataGrid<Contact> {
*
*/
private static final long serialVersionUID = -2573761302198992085L;
private static final PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
@Override
@ -40,17 +41,21 @@ public class ContactGrid extends AbstractDataGrid<Contact> {
protected ValidationResult validate(Contact obj, ValueContext context) {
if (obj.getType().equalsIgnoreCase("email")) {
return new EmailValidator("Emailformat nicht gültig!").apply(obj.getValue(), context);
} else if (obj.getType().equalsIgnoreCase("Telefon") || obj.getType().equalsIgnoreCase("Mobile")) {
}
else if (obj.getType().equalsIgnoreCase("Telefon") || obj.getType().equalsIgnoreCase("Mobile")) {
try {
PhoneNumber phone = phoneUtil.parse(obj.getValue(), "DE");
if (phoneUtil.isValidNumber(phone)) {
obj.setValue(phoneUtil.format(phone,
com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL));
return ValidationResult.ok();
} else {
return ValidationResult.error("Fehler beim Validieren von Telefonnummer: " + obj.getValue());
}
} catch (NumberParseException e) {
else {
return ValidationResult.error("Ungültige Telefonnummer: " + obj.getValue());
}
}
catch (NumberParseException e) {
return ValidationResult.error("Fehler beim Validieren von Telefonnummer: " + obj.getValue());
}
}

@ -13,9 +13,9 @@ import com.vaadin.ui.Window;
import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.meldung.EventMeldung;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator;
@ -25,17 +25,25 @@ public class EventDetails extends GridLayout implements View {
private static final long serialVersionUID = 8290150079638390995L;
private final EventBusiness eventBusiness;
private final PersonDao personDao;
private final PersonBusiness personDao;
private final GroupDao groupDao;
private final PflichtenDao pflichtenDao;
private ClubEvent currentEvent;
private SingleEventView eventView;
private PersonGrid personGrid;
private EventAltersgruppen eventAltersgruppen;
private CalendarAdapter calendarAdapter;
public EventDetails(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness, PflichtenDao pflichtenDao,
public EventDetails(PersonBusiness personDao, GroupDao groupDao, EventBusiness eventBusiness,
PflichtenDao pflichtenDao,
CalendarAdapter calendarAdapter) {
super(3, 5);
this.eventBusiness = eventBusiness;
@ -81,7 +89,8 @@ public class EventDetails extends GridLayout implements View {
addComponent(personGrid, 2, 0);
addComponent(buttonLayout, 0, 4, 2, 4);
setSizeFull();
} else {
}
else {
eventAltersgruppen.updateData();
}
eventView.setEvent(currentEvent);

@ -1,12 +1,18 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.teemu.switchui.Switch;
import com.vaadin.data.Binder;
import com.vaadin.data.Binder.BindingBuilder;
import com.vaadin.data.BinderValidationStatus;
import com.vaadin.data.HasValue.ValueChangeEvent;
import com.vaadin.data.HasValue.ValueChangeListener;
import com.vaadin.data.ValidationResult;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
@ -18,7 +24,7 @@ import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Gender;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
@ -34,10 +40,12 @@ public class PersonEditDetails extends HorizontalLayout {
private final DateField birthday;
private final PersonDao dao;
private final PersonBusiness dao;
private final Binder<Person> binder;
private final Binder<Set<GroupDef>> binderGroups;
private Consumer<Person> personChangeHandler;
private Button okButton;
@ -48,11 +56,11 @@ public class PersonEditDetails extends HorizontalLayout {
private AdressComponent adressLayout;
public PersonEditDetails(List<GroupDef> groups, PersonDao dao) {
public PersonEditDetails(List<GroupDef> groups, PersonBusiness dao) {
this(groups, dao, true);
}
public PersonEditDetails(List<GroupDef> groups, PersonDao dao, boolean showCloseButton) {
public PersonEditDetails(List<GroupDef> groups, PersonBusiness dao, boolean showCloseButton) {
this.dao = dao;
@ -122,6 +130,7 @@ public class PersonEditDetails extends HorizontalLayout {
VerticalLayout layout = new VerticalLayout(textPrename, textSureName, birthday, genderBox, textStartPass, close,
okButton);
binderGroups = new Binder<Set<GroupDef>>();
Component groupLayout = createGroupPanel(groups);
contactLayout = new ContactGrid();
contactLayout.setDeleteConsumer(c -> {
@ -175,18 +184,46 @@ public class PersonEditDetails extends HorizontalLayout {
for (GroupDef g : groups) {
Switch sw = new Switch(g.getName());
sw.setId("Group_" + g.getName());
sw.setData(g);
layout.addComponent(sw);
binder.forField(sw).bind(p -> p.getGroups().contains(g), (bean, fieldvalue) -> {
BindingBuilder<Set<GroupDef>, Boolean> forField = binderGroups.forField(sw);
forField.bind(p -> p.contains(g), (bean, fieldvalue) -> {
if (fieldvalue) {
bean.getGroups().add(g);
bean.add(g);
}
else {
bean.getGroups().remove(g);
bean.remove(g);
}
});
}
binder.addValueChangeListener(new ValueChangeListener<Object>() {
transient Logger log = LoggerFactory.getLogger(PersonEditDetails.this.getClass());
@Override
public void valueChange(ValueChangeEvent<Object> event) {
Component comp = event.getComponent();
Object oldGroups = event.getOldValue();
Object newGroups = event.getValue();
log.warn("Changed value in {}, old size={}, new size={}, hasChanges={}", comp.getId(), oldGroups,
newGroups, binder.hasChanges());
}
});
binderGroups.addValueChangeListener(new ValueChangeListener<Object>() {
transient Logger log = LoggerFactory.getLogger(PersonEditDetails.this.getClass());
@Override
public void valueChange(ValueChangeEvent<Object> event) {
Component comp = event.getComponent();
Object oldGroups = event.getOldValue();
Object newGroups = event.getValue();
log.warn("Changed value in {}, old size={}, new size={}, hasChanges={}", comp.getId(), oldGroups,
newGroups, binderGroups.hasChanges());
}
});
return layout;
}
@ -197,6 +234,12 @@ public class PersonEditDetails extends HorizontalLayout {
public void setBean(Person person) {
closeWithoutSave();
binder.setBean(person);
if (person != null) {
binderGroups.setBean(person.getGroups());
}
else {
binderGroups.setBean(null);
}
contactLayout.setPerson(person);
relationshipLayout.setPerson(person);
adressLayout.setPerson(person);
@ -212,7 +255,7 @@ public class PersonEditDetails extends HorizontalLayout {
}
}
void closeWithoutSave() {
public void closeWithoutSave() {
if (hasChanges()) {
final Person current = binder.getBean();
@ -234,6 +277,7 @@ public class PersonEditDetails extends HorizontalLayout {
public boolean hasChanges() {
return binder.getBean() != null
&& (binder.hasChanges()
|| binderGroups.hasChanges()
|| contactLayout.hasChanges()
|| relationshipLayout.hasChanges()
|| adressLayout.hasChanges());

@ -11,7 +11,7 @@ import com.vaadin.data.provider.DataChangeEvent;
import com.vaadin.data.provider.DataProviderListener;
import com.vaadin.server.SerializablePredicate;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.events.DataUpdatedEvent;
@ -20,16 +20,22 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.events.DefaultDataUpdateHa
public class PersonFilter implements SerializablePredicate<Person>, DataProviderListener<Person> {
private static final long serialVersionUID = -8481035921020651601L;
private Set<Integer> selectedPersons = null;
private Set<GroupDef> selectedGroups = null;
private final List<Person> publishedList;
private final PersonDao personDao;
private final PersonBusiness personDao;
private final DefaultDataUpdateHandler updateHandler;
private String nameFilter;
public PersonFilter(PersonDao personDao) {
this.personDao = personDao;
publishedList = new ArrayList<>(personDao.listAll());
public PersonFilter(PersonBusiness personDao2) {
this.personDao = personDao2;
publishedList = new ArrayList<>(personDao2.listAll());
this.updateHandler = new DefaultDataUpdateHandler();
}
@ -102,7 +108,8 @@ public class PersonFilter implements SerializablePredicate<Person>, DataProvider
public void setNameFilter(String value) {
if (value != null) {
this.nameFilter = value.toLowerCase();
} else {
}
else {
this.nameFilter = value;
}
}

@ -31,8 +31,8 @@ import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.components.grid.GridMultiSelect;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Gender;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
@ -42,29 +42,40 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpass;
public class PersonGrid extends VerticalLayout {
private static final long serialVersionUID = -8148097982839343673L;
private final transient Logger log = LoggerFactory.getLogger(getClass());
private final transient DateTimeFormatter birthFormat = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
private final ListDataProvider<Person> dataProvider;
private final Grid<Person> grid;
private final CheckBox checkIncluded;
private final ComboBox<GroupDef> comboGroups;
private final TextField textFilter;
private final PersonDao personDao;
private final PersonBusiness personDao;
private List<GroupDef> allGroups;
private PersonFilter filter;
private ClubEvent currentEvent;
private Column<Person, String> startpassColumn;
private Layout filters;
private SelectionMode currentSelectionMode;
private Column<Person, ?> genderColumn;
private Column<Person, ? extends Component> deleteButtonColumn;
public PersonGrid(GroupDao groupDao, PersonDao personDao) {
public PersonGrid(GroupDao groupDao, PersonBusiness personDao) {
setId("main.person");
setCaption("Teilnehmer");
@ -101,6 +112,7 @@ public class PersonGrid extends VerticalLayout {
grid.setDataProvider(dataProvider);
grid.setId("person.grid");
grid.setSizeFull();
grid.setSelectionMode(SelectionMode.SINGLE);
grid.addColumn(Person::getPrename).setCaption("Vorname");
grid.addColumn(Person::getSurname).setCaption("Nachname");
@ -111,7 +123,8 @@ public class PersonGrid extends VerticalLayout {
Startpass startpass = p.getStartpass();
if (startpass != null) {
return startpass.getStartpassNr();
} else {
}
else {
return null;
}
}).setCaption("Startpass Nr.");
@ -124,7 +137,8 @@ public class PersonGrid extends VerticalLayout {
if (gender == null) {
icon = VaadinIcons.QUESTION;
} else {
}
else {
switch (gender) {
case FEMALE:
icon = VaadinIcons.FEMALE;
@ -161,7 +175,8 @@ public class PersonGrid extends VerticalLayout {
if (gender == null) {
icon = VaadinIcons.QUESTION;
} else {
}
else {
switch (gender) {
case FEMALE:
icon = VaadinIcons.FEMALE;
@ -228,7 +243,8 @@ public class PersonGrid extends VerticalLayout {
if (value != null && value.length() >= 2) {
filter.setNameFilter(value);
dataProvider.refreshAll();
} else {
}
else {
filter.setNameFilter(null);
dataProvider.refreshAll();
}
@ -249,7 +265,8 @@ public class PersonGrid extends VerticalLayout {
private void updateSelectedOnlyFilter(Boolean selectedOnly) {
if (selectedOnly != null && selectedOnly.equals(Boolean.TRUE)) {
filter.setSelectedPersons(grid.getSelectedItems());
} else {
}
else {
filter.setSelectedPersons(null);
}
dataProvider.refreshAll();
@ -269,7 +286,8 @@ public class PersonGrid extends VerticalLayout {
asMultiSelect.deselectAll();
if (items == null || items.length == 0) {
log.debug("No Persons selected.");
} else {
}
else {
log.debug("Selecting Persons: {}", Arrays.asList(items));
asMultiSelect.selectItems(items);
}
@ -312,10 +330,12 @@ public class PersonGrid extends VerticalLayout {
if (currentSelectionMode == SelectionMode.MULTI) {
if (ev != null) {
updateSelection(ev);
} else {
}
else {
selectItems(new Person[0]);
}
} else if (ev != null) {
}
else if (ev != null) {
Collection<Person> items = dataProvider.getItems();
items.clear();
items.addAll(ev.getPersons());
@ -327,7 +347,8 @@ public class PersonGrid extends VerticalLayout {
Set<Person> persons = ev.getPersons();
if (persons != null) {
selectItems(persons.toArray(new Person[0]));
} else {
}
else {
selectItems(new Person[0]);
}
}

@ -6,16 +6,17 @@ import com.vaadin.data.Binder;
import com.vaadin.data.ValidationResult;
import com.vaadin.data.ValueContext;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relation;
public class RelationComponent extends AbstractDataGrid<Relation> {
private static final long serialVersionUID = 7813969695936351799L;
private PersonDao dao;
public RelationComponent(PersonDao dao) {
private PersonBusiness dao;
public RelationComponent(PersonBusiness dao) {
this.dao = dao;
setEditorEnabled(false);
}

@ -17,8 +17,8 @@ import com.vaadin.ui.UI;
import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.EventDetails;
@ -30,9 +30,6 @@ public class ClubhelperNavigation implements ApplicationContextAware {
private ApplicationContext context;
@Autowired
PersonDao personDao;
@Autowired
GroupDao groupDao;
@ -50,6 +47,9 @@ public class ClubhelperNavigation implements ApplicationContextAware {
private ClubNavigator navi;
@Autowired
PersonBusiness personBusiness;
public void configure(UI mainUI) {
navi = new ClubNavigator().init(mainUI);
@ -63,10 +63,10 @@ public class ClubhelperNavigation implements ApplicationContextAware {
navi.addView("", mainView);
navi.addView(ClubhelperViews.MainView.name(), mainView);
navi.addView(ClubhelperViews.LoginUI.name(), new LoginUI(personDao, securityGroupVerifier));
navi.addView(ClubhelperViews.LoginUI.name(), new LoginUI(personBusiness, securityGroupVerifier));
navi.addView(ClubhelperViews.PersonEditView.name(), factory.createPersonEdit());
navi.addView(ClubhelperViews.EventDetails.name(),
new EventDetails(personDao, groupDao, eventBusiness, pflichtenDao, calendarAdapter));
new EventDetails(personBusiness, groupDao, eventBusiness, pflichtenDao, calendarAdapter));
page.addBrowserWindowResizeListener(ev -> {
int width = ev.getWidth();
@ -90,15 +90,15 @@ public class ClubhelperNavigation implements ApplicationContextAware {
public MainView createMain() {
if (page.getBrowserWindowWidth() < 1000) {
return new MainViewMobile(context, personDao, groupDao, eventBusiness, securityGroupVerifier);
return new MainViewMobile(context, personBusiness, groupDao, eventBusiness, securityGroupVerifier);
}
else {
return new MainViewDesktop(context, personDao, groupDao, eventBusiness, securityGroupVerifier);
return new MainViewDesktop(context, personBusiness, groupDao, eventBusiness, securityGroupVerifier);
}
}
public PersonEditView createPersonEdit() {
return new PersonEditView(groupDao, personDao, (page.getBrowserWindowWidth() >= 1000));
return new PersonEditView(groupDao, personBusiness, (page.getBrowserWindowWidth() >= 1000));
}
}

@ -11,7 +11,7 @@ import com.vaadin.ui.LoginForm;
import com.vaadin.ui.Notification;
import com.vaadin.ui.VerticalLayout;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
@ -25,7 +25,7 @@ public class LoginUI extends VerticalLayout implements View {
private String parameters;
public LoginUI(PersonDao personDao, SecurityVerifier securityGroupVerifier) {
public LoginUI(PersonBusiness personBusiness, SecurityVerifier securityGroupVerifier) {
LoginForm lf = new LoginForm();
lf.addLoginListener(e -> {
@ -34,7 +34,7 @@ public class LoginUI extends VerticalLayout implements View {
String password = e.getLoginParameter("password");
try {
Person loggedin = personDao.findLoginUser(username, password);
Person loggedin = personBusiness.findLoginUser(username, password);
securityGroupVerifier.setLoggedinPerson(loggedin);
navigator.navigateTo(ClubhelperViews.MainView.name() + '/' + parameters);
}

@ -13,8 +13,8 @@ import com.vaadin.ui.VerticalLayout;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ClubhelperException;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
@ -29,8 +29,6 @@ public abstract class MainView extends VerticalLayout implements View {
protected final Logger LOGGER = LoggerFactory.getLogger(getClass());
private final PersonDao personDao;
private final GroupDao groupDao;
protected final EventBusiness eventBusiness;
@ -43,9 +41,11 @@ public abstract class MainView extends VerticalLayout implements View {
protected ClubNavigator navigator;
public MainView(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness,
private final PersonBusiness personBusiness;
public MainView(GroupDao groupDao, EventBusiness eventBusiness, PersonBusiness personBusiness,
SecurityVerifier securityGroupVerifier) {
this.personDao = personDao;
this.personBusiness = personBusiness;
this.groupDao = groupDao;
this.eventBusiness = eventBusiness;
this.securityVerifier = securityGroupVerifier;
@ -79,7 +79,7 @@ public abstract class MainView extends VerticalLayout implements View {
eventView.setId(eventView.getClass().getName());
eventView.setVisible(false);
personGrid = new PersonGrid(groupDao, personDao);
personGrid = new PersonGrid(groupDao, personBusiness);
personGrid.setCaption("Personen");
personGrid.setSelectionMode(SelectionMode.MULTI);
personGrid.onPersonSelect(ev -> personSelectionChange(ev));

@ -14,8 +14,8 @@ import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent;
@ -40,10 +40,10 @@ public class MainViewDesktop extends MainView {
private ApplicationContext context;
public MainViewDesktop(ApplicationContext context, PersonDao personDao, GroupDao groupDao,
public MainViewDesktop(ApplicationContext context, PersonBusiness personDao, GroupDao groupDao,
EventBusiness eventBusiness,
SecurityVerifier securityGroupVerifier) {
super(personDao, groupDao, eventBusiness, securityGroupVerifier);
super(groupDao, eventBusiness, personDao, securityGroupVerifier);
this.context = context;
}

@ -24,8 +24,8 @@ import com.vaadin.ui.Label;
import com.vaadin.ui.Window;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent.ClubEventProvider;
@ -42,10 +42,10 @@ public class MainViewMobile extends MainView {
private ApplicationContext context;
public MainViewMobile(ApplicationContext context, PersonDao personDao, GroupDao groupDao,
public MainViewMobile(ApplicationContext context, PersonBusiness personDao, GroupDao groupDao,
EventBusiness eventBusiness,
SecurityVerifier securityGroupVerifier) {
super(personDao, groupDao, eventBusiness, securityGroupVerifier);
super(groupDao, eventBusiness, personDao, securityGroupVerifier);
this.context = context;
}

@ -8,12 +8,15 @@ import com.vaadin.event.selection.SelectionEvent;
import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonEditDetails;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid;
@ -23,11 +26,12 @@ public class PersonEditView extends VerticalLayout implements View {
private static final long serialVersionUID = 1770993670570422036L;
private PersonGrid personGrid;
private PersonEditDetails personDetails;
private Navigator navigator;
public PersonEditView(GroupDao groupDao, PersonDao personDao, boolean horizontalLayout) {
public PersonEditView(GroupDao groupDao, PersonBusiness personDao, boolean horizontalLayout) {
setMargin(true);
personGrid = new PersonGrid(groupDao, personDao);
@ -42,7 +46,8 @@ public class PersonEditView extends VerticalLayout implements View {
if (horizontalLayout) {
addComponent(createHorizontalLayout());
} else {
}
else {
addComponent(createVerticalLayout());
}
Button addPerson = new Button("Hinzufügen");
@ -81,9 +86,37 @@ public class PersonEditView extends VerticalLayout implements View {
}
void selectedPerson(SelectionEvent<Person> p) {
if (personDetails.hasChanges()) {
VerticalLayout content = new VerticalLayout();
Window dlg = new Window("Änderungen verwerfen?", content);
dlg.setClosable(false);
dlg.setModal(true);
Label message = new Label(
"Die Personendaten wurden geändert.<br />Sollen diese Änderungen verworfen werden?",
ContentMode.HTML);
content.addComponent(message);
HorizontalLayout buttons = new HorizontalLayout();
Button ok = new Button("Ja", ev -> {
dlg.setVisible(false);
PersonEditView.this.getUI().removeWindow(dlg);
Optional<Person> firstSelectedItem = p.getFirstSelectedItem();
personDetails.setBean(firstSelectedItem.orElse(null));
});
Button cancel = new Button("Nein", ev -> {
dlg.setVisible(false);
PersonEditView.this.getUI().removeWindow(dlg);
});
buttons.addComponents(ok, cancel);
content.addComponent(buttons);
getUI().addWindow(dlg);
}
else {
Optional<Person> firstSelectedItem = p.getFirstSelectedItem();
personDetails.setBean(firstSelectedItem.orElse(null));
}
}
@Override
public void enter(ViewChangeEvent event) {

@ -4,9 +4,15 @@
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
<File name="MyFile" fileName="all.log" immediateFlush="false" append="false">
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</File>
<RollingFile name="MyFile" fileName="${catalina.base}/logs/vaadin_clubhelper.log" immediateFlush="false" append="true">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %logger %m%n </Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
</Policies>
<DefaultRolloverStrategy max="5" />
</RollingFile>
</Appenders>
<Loggers>
<Root level="error">

@ -1,5 +1,6 @@
package de.kreth.vaadin.clubhelper;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
@ -28,7 +29,8 @@ public abstract class AbstractHibernateConfiguration implements HibernateConfigu
configuration.addAnnotatedClass(entityClass);
}
configuration.addInputStream(getClass().getResourceAsStream("/schema/ClubEvent.hbm.xml"));
InputStream resourceAsStream = getClass().getResourceAsStream("/schema/ClubEvent.hbm.xml");
configuration.addInputStream(resourceAsStream);
configuration.setProperty("hibernate.hbm2ddl.auto", "update");
configuration.setProperty("spring.jpa.hibernate.ddl-auto", "update");

@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.TestDatabaseHelper;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
@ -43,7 +43,7 @@ class PersonFilterTest {
TestDatabaseHelper testDatabaseHelper;
@Mock
private PersonDao dao;
private PersonBusiness dao;
static List<GroupDef> setupData() {

@ -18,7 +18,7 @@ import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Component;
import com.vaadin.ui.LoginForm;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
@RunWith(SpringRunner.class)
@ -26,7 +26,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
public class LoginUITest {
@Autowired
PersonDao personDao;
PersonBusiness personDao;
@Autowired
SecurityVerifier securityGroupVerifier;

@ -24,8 +24,8 @@ import com.vaadin.ui.HasComponents;
import com.vaadin.ui.TextField;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
@ -41,7 +41,7 @@ public class MainViewDesktopSmokeTest {
ApplicationContext context;
@Autowired
PersonDao personDao;
PersonBusiness personDao;
@Autowired
SecurityVerifier securityGroupVerifier;

@ -27,8 +27,8 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.HasComponents;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
@ -50,7 +50,7 @@ public class MainViewMobileSmokeTest {
ApplicationContext context;
@Autowired
PersonDao personDao;
PersonBusiness personDao;
SecurityVerifier securityGroupVerifier;

Loading…
Cancel
Save