Calendar Year view fixed.

master
Markus Kreth 7 years ago
parent abf14d9f4f
commit 3749163d60
  1. 4
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/YearlyCalendarCreator.java
  2. 18
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/Year.java
  3. 1791
      src/main/resources/jasper/calendar_year.jrxml
  4. 1
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/AbstractDatabaseTest.java
  5. 2
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoTest.java
  6. 7
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/YearTest.java

@ -1,14 +1,12 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
import java.io.InputStream;
import java.util.Collection;
import java.util.Map;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.calendar.Year;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JasperPrint;
public class YearlyCalendarCreator extends CalendarCreator {
@ -33,7 +31,7 @@ public class YearlyCalendarCreator extends CalendarCreator {
return CalendarCreator.class.getResourceAsStream("/jasper/calendar_year.jrxml");
}
private static class EmptySource implements JRDataSource {
public static class EmptySource implements JRDataSource {
@Override
public boolean next() throws JRException {

@ -19,13 +19,13 @@ public class Year {
}
public Year(int year, Locale locale) {
if (year < 1900 || year >2100) {
if (year < 1900 || year > 2100) {
throw new IllegalArgumentException("Year value must be between 1900 and 2100");
}
this.date = LocalDate.of(year, 1, 1);
this.locale = locale;
this.monthWeeks = new HashMap<>();
for (Month m: Month.values()) {
for (Month m : Month.values()) {
monthWeeks.put(m, new WeeksOfMonth(m, year));
}
}
@ -40,20 +40,20 @@ public class Year {
/**
* Day of month, numeric for the specified by parameters.
* @param month month of the day
* @param week 1-6th week of the month
* @param dayOfWeek weekday of the week in the month.
* @return numeric value of the day of the month.
*
* @param month month of the day
* @param week 1-6th week of the month
* @param dayOfWeek weekday of the week in the month.
* @return numeric value of the day of the month.
*/
public String getDay(Month month, short week, DayOfWeek dayOfWeek) {
WeeksOfMonth weeksOfMonth = monthWeeks.get(month);
if (week >= weeksOfMonth.weekCount()) {
if (week > weeksOfMonth.weekCount()) {
return "";
}
Integer res = weeksOfMonth.getWeek(week - 1).get(dayOfWeek);
return res == null ? "" : res.toString();
return res == null ? "" : res.toString();
}

File diff suppressed because it is too large Load Diff

@ -29,7 +29,6 @@ public abstract class AbstractDatabaseTest {
Configuration configuration = createConfig();
sessionFactory = configuration.buildSessionFactory();
session = sessionFactory.openSession();
}

@ -7,8 +7,8 @@ import java.time.ZonedDateTime;
import java.util.List;
import org.hibernate.query.Query;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

@ -1,6 +1,7 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.calendar;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.time.DayOfWeek;
import java.time.Month;
@ -20,13 +21,13 @@ class YearTest {
@Test
void testMondayIsFirst() {
Year y = new Year(2018);
assertEquals(Short.valueOf((short)1), y.getDay(Month.OCTOBER, (short)1, DayOfWeek.MONDAY));
assertEquals("1", y.getDay(Month.OCTOBER, (short) 1, DayOfWeek.MONDAY));
}
@Test
void testThursdayIsFirst() {
Year y = new Year(2018);
assertNull(y.getDay(Month.NOVEMBER, (short)1, DayOfWeek.MONDAY));
assertEquals("", y.getDay(Month.NOVEMBER, (short) 1, DayOfWeek.MONDAY));
}
}

Loading…
Cancel
Save