parent
5395430640
commit
75d6ed4f09
@ -1,46 +1,46 @@ |
|||||||
package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; |
package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; |
||||||
|
|
||||||
import java.util.List; |
import java.util.List; |
||||||
|
|
||||||
import javax.persistence.EntityManager; |
import javax.persistence.EntityManager; |
||||||
import javax.persistence.TypedQuery; |
import javax.persistence.TypedQuery; |
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired; |
import org.springframework.beans.factory.annotation.Autowired; |
||||||
import org.springframework.transaction.annotation.Transactional; |
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
public abstract class AbstractDaoImpl<T> implements IDao<T> { |
public abstract class AbstractDaoImpl<T> implements IDao<T> { |
||||||
|
|
||||||
@Autowired |
@Autowired |
||||||
protected EntityManager em; |
protected EntityManager em; |
||||||
|
|
||||||
private final Class<T> entityClass; |
private final Class<T> entityClass; |
||||||
|
|
||||||
public AbstractDaoImpl(Class<T> entityClass) { |
public AbstractDaoImpl(Class<T> entityClass) { |
||||||
super(); |
super(); |
||||||
this.entityClass = entityClass; |
this.entityClass = entityClass; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
@Transactional |
@Transactional |
||||||
public void save(T obj) { |
public void save(T obj) { |
||||||
em.persist(obj); |
em.persist(obj); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
@Transactional |
@Transactional |
||||||
public T update(T obj) { |
public T update(T obj) { |
||||||
return em.merge(obj); |
return em.merge(obj); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public T get(Object primaryKey) { |
public T get(Object primaryKey) { |
||||||
return em.find(entityClass, primaryKey); |
return em.find(entityClass, primaryKey); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public List<T> listAll() { |
public List<T> listAll() { |
||||||
TypedQuery<T> query = em.createNamedQuery(entityClass.getSimpleName() + ".findAll", entityClass); |
TypedQuery<T> query = em.createNamedQuery(entityClass.getSimpleName() + ".findAll", entityClass); |
||||||
return query.getResultList(); |
return query.getResultList(); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|||||||
@ -1,4 +1,4 @@ |
|||||||
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; |
package de.kreth.vaadin.clubhelper.vaadinclubhelper.jasper; |
||||||
|
|
||||||
import java.time.YearMonth; |
import java.time.YearMonth; |
||||||
import java.util.Calendar; |
import java.util.Calendar; |
||||||
@ -1,4 +1,4 @@ |
|||||||
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; |
package de.kreth.vaadin.clubhelper.vaadinclubhelper.jasper; |
||||||
|
|
||||||
import java.io.InputStream; |
import java.io.InputStream; |
||||||
import java.sql.Timestamp; |
import java.sql.Timestamp; |
||||||
@ -1,4 +1,4 @@ |
|||||||
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; |
package de.kreth.vaadin.clubhelper.vaadinclubhelper.jasper; |
||||||
|
|
||||||
import java.time.LocalDate; |
import java.time.LocalDate; |
||||||
import java.time.YearMonth; |
import java.time.YearMonth; |
||||||
@ -1,4 +1,4 @@ |
|||||||
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; |
package de.kreth.vaadin.clubhelper.vaadinclubhelper.jasper; |
||||||
|
|
||||||
import java.io.InputStream; |
import java.io.InputStream; |
||||||
import java.time.LocalDate; |
import java.time.LocalDate; |
||||||
@ -1,52 +1,52 @@ |
|||||||
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; |
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; |
||||||
|
|
||||||
import com.vaadin.navigator.Navigator; |
import com.vaadin.navigator.Navigator; |
||||||
import com.vaadin.navigator.View; |
import com.vaadin.navigator.View; |
||||||
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
||||||
import com.vaadin.ui.Alignment; |
import com.vaadin.ui.Alignment; |
||||||
import com.vaadin.ui.LoginForm; |
import com.vaadin.ui.LoginForm; |
||||||
import com.vaadin.ui.Notification; |
import com.vaadin.ui.Notification; |
||||||
import com.vaadin.ui.VerticalLayout; |
import com.vaadin.ui.VerticalLayout; |
||||||
|
|
||||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; |
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; |
||||||
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
||||||
|
|
||||||
public class LoginUI extends VerticalLayout implements View { |
public class LoginUI extends VerticalLayout implements View { |
||||||
|
|
||||||
private static final long serialVersionUID = 4339018452507960084L; |
private static final long serialVersionUID = 4339018452507960084L; |
||||||
public static final String VIEW_NAME = "LoginUI"; |
public static final String VIEW_NAME = "LoginUI"; |
||||||
|
|
||||||
private Navigator navigator; |
private Navigator navigator; |
||||||
private String parameters; |
private String parameters; |
||||||
|
|
||||||
public LoginUI(PersonDao personDao) { |
public LoginUI(PersonDao personDao) { |
||||||
|
|
||||||
LoginForm lf = new LoginForm(); |
LoginForm lf = new LoginForm(); |
||||||
lf.addLoginListener(e -> { |
lf.addLoginListener(e -> { |
||||||
|
|
||||||
String username = e.getLoginParameter("username"); |
String username = e.getLoginParameter("username"); |
||||||
String password = e.getLoginParameter("password"); |
String password = e.getLoginParameter("password"); |
||||||
|
|
||||||
try { |
try { |
||||||
Person loggedin = personDao.findLoginUser(username, password); |
Person loggedin = personDao.findLoginUser(username, password); |
||||||
this.getSession().setAttribute(Person.SESSION_LOGIN, loggedin); |
this.getSession().setAttribute(Person.SESSION_LOGIN, loggedin); |
||||||
navigator.navigateTo(MainView.VIEW_NAME + '/' + parameters); |
navigator.navigateTo(MainView.VIEW_NAME + '/' + parameters); |
||||||
} catch (final Exception ex) { |
} catch (final Exception ex) { |
||||||
String message = "Incorrect user or password:" + ex.getMessage() + e.getLoginParameter("username") + ":" |
String message = "Incorrect user or password:" + ex.getMessage() + e.getLoginParameter("username") + ":" |
||||||
+ e.getLoginParameter("password"); |
+ e.getLoginParameter("password"); |
||||||
Notification.show(message, Notification.Type.ERROR_MESSAGE); |
Notification.show(message, Notification.Type.ERROR_MESSAGE); |
||||||
} |
} |
||||||
}); |
}); |
||||||
addComponent(lf); |
addComponent(lf); |
||||||
setComponentAlignment(lf, Alignment.MIDDLE_CENTER); |
setComponentAlignment(lf, Alignment.MIDDLE_CENTER); |
||||||
setSizeFull(); |
setSizeFull(); |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void enter(ViewChangeEvent event) { |
public void enter(ViewChangeEvent event) { |
||||||
View.super.enter(event); |
View.super.enter(event); |
||||||
navigator = event.getNavigator(); |
navigator = event.getNavigator(); |
||||||
parameters = event.getParameters(); |
parameters = event.getParameters(); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|||||||
@ -1,12 +1,12 @@ |
|||||||
/* This file is automatically managed and will be overwritten from time to time. */ |
/* This file is automatically managed and will be overwritten from time to time. */ |
||||||
/* Do not manually edit this file. */ |
/* Do not manually edit this file. */ |
||||||
|
|
||||||
/* Provided by calendar-component-2.0-BETA4.jar */ |
/* Provided by calendar-component-2.0-BETA4.jar */ |
||||||
@import "../../../VAADIN/addons/calendar/calendar-addon.scss"; |
@import "../../../VAADIN/addons/calendar/calendar-addon.scss"; |
||||||
|
|
||||||
|
|
||||||
/* Import and include this mixin into your project theme to include the addon themes */ |
/* Import and include this mixin into your project theme to include the addon themes */ |
||||||
@mixin addons { |
@mixin addons { |
||||||
@include calendar-addon; |
@include calendar-addon; |
||||||
} |
} |
||||||
|
|
||||||
|
|||||||
Loading…
Reference in new issue