|
|
|
@ -11,35 +11,17 @@ import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.function.Consumer; |
|
|
|
import java.util.function.Consumer; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import org.hibernate.Session; |
|
|
|
|
|
|
|
import org.hibernate.SessionFactory; |
|
|
|
|
|
|
|
import org.hibernate.cfg.Configuration; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.ClubEventDaoImpl; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Attendance; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.DeletedEntry; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Persongroup; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relative; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpass; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.StartpassStartrechte; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Version; |
|
|
|
|
|
|
|
import net.sf.jasperreports.engine.JRDataSource; |
|
|
|
import net.sf.jasperreports.engine.JRDataSource; |
|
|
|
import net.sf.jasperreports.engine.JRException; |
|
|
|
import net.sf.jasperreports.engine.JRException; |
|
|
|
import net.sf.jasperreports.engine.JasperCompileManager; |
|
|
|
import net.sf.jasperreports.engine.JasperCompileManager; |
|
|
|
import net.sf.jasperreports.engine.JasperFillManager; |
|
|
|
import net.sf.jasperreports.engine.JasperFillManager; |
|
|
|
import net.sf.jasperreports.engine.JasperPrint; |
|
|
|
import net.sf.jasperreports.engine.JasperPrint; |
|
|
|
import net.sf.jasperreports.engine.JasperReport; |
|
|
|
import net.sf.jasperreports.engine.JasperReport; |
|
|
|
import net.sf.jasperreports.view.JasperViewer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public abstract class CalendarCreator { |
|
|
|
public abstract class CalendarCreator { |
|
|
|
|
|
|
|
|
|
|
|
@ -79,24 +61,6 @@ public abstract class CalendarCreator { |
|
|
|
|
|
|
|
|
|
|
|
protected abstract InputStream jrxmlResource(); |
|
|
|
protected abstract InputStream jrxmlResource(); |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws JRException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Locale.setDefault(Locale.GERMANY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int year = 2019; |
|
|
|
|
|
|
|
List<ClubEvent> allevents = loadAllEvents().stream().filter(ev -> { |
|
|
|
|
|
|
|
return ev.getStart().toLocalDate().getYear() <= year && ev.getEnd().toLocalDate().getYear() >= year; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<LocalDate> holidays = filterHolidays(allevents); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<LocalDate, CharSequence> values = map(allevents, year); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JasperViewer v1 = new JasperViewer(createYearCalendar(year, values, holidays)); |
|
|
|
|
|
|
|
v1.setVisible(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<LocalDate> filterHolidays(List<ClubEvent> allevents) { |
|
|
|
public static List<LocalDate> filterHolidays(List<ClubEvent> allevents) { |
|
|
|
List<LocalDate> holidays = new ArrayList<>(); |
|
|
|
List<LocalDate> holidays = new ArrayList<>(); |
|
|
|
Iterator<ClubEvent> iter = allevents.iterator(); |
|
|
|
Iterator<ClubEvent> iter = allevents.iterator(); |
|
|
|
@ -158,44 +122,10 @@ public abstract class CalendarCreator { |
|
|
|
txt.append(ev.getCaption()); |
|
|
|
txt.append(ev.getCaption()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static List<ClubEvent> loadAllEvents() { |
|
|
|
|
|
|
|
Configuration configuration = createConfig(); |
|
|
|
|
|
|
|
SessionFactory sessionFactory = configuration.buildSessionFactory(); |
|
|
|
|
|
|
|
Session session = sessionFactory.openSession(); |
|
|
|
|
|
|
|
ClubEventDaoImpl dao = new ClubEventDaoImpl(); |
|
|
|
|
|
|
|
dao.setEntityManager(session); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dao.listAll(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Calendar toCalendar(long time) { |
|
|
|
public static Calendar toCalendar(long time) { |
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
cal.setTimeInMillis(time); |
|
|
|
cal.setTimeInMillis(time); |
|
|
|
return cal; |
|
|
|
return cal; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Configuration createConfig() { |
|
|
|
|
|
|
|
Configuration configuration = new Configuration(); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(Adress.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(Attendance.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(Contact.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(DeletedEntry.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(GroupDef.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(Person.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(Persongroup.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(Relative.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(Startpass.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(StartpassStartrechte.class); |
|
|
|
|
|
|
|
configuration.addAnnotatedClass(Version.class); |
|
|
|
|
|
|
|
configuration.addInputStream(CalendarCreator.class.getResourceAsStream("/schema/ClubEvent.hbm.xml")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); |
|
|
|
|
|
|
|
configuration.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver"); |
|
|
|
|
|
|
|
configuration.setProperty("hibernate.connection.url", |
|
|
|
|
|
|
|
"jdbc:mysql://localhost:3306/clubhelper?useUnicode=yes&characterEncoding=utf8&serverTimezone=Europe/Berlin"); |
|
|
|
|
|
|
|
configuration.setProperty("hibernate.connection.username", "markus"); |
|
|
|
|
|
|
|
configuration.setProperty("hibernate.connection.password", "0773"); |
|
|
|
|
|
|
|
return configuration; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|