0

I'm using jollyday for checking the holidays for showing them in a calendar.

With that i'm getting the Holidays as a Set, by calling the Method with the year and the regionCode:

HolidayManager m = HolidayManager.getInstance(HolidayCalendar.GERMANY);
Set<Holiday> holidays =m.getHolidays(year, regionCode)

Perhaps I have to do this multiple times for different regionCodes, but all comes in one Set. After I have all the holidays i want to make a Map with Informations to this Holiday:

Map getCalendarProperties(Holiday holiday) {
    HolidayManager m = HolidayManager.getInstance(HolidayCalendar.GERMANY);

    Map a = [:]
    a.tooltip = "<div class='row'>" +
            "<div class='col-xs-6'><b>${holiday.description}</b></div>" +
            "<div class='col-xs-6'>    </div>" +
            "</div>"  
    a.date = holiday?.date.toString(DateTimeFormat.forPattern("YYYY-MM-dd"));
    return a
}

I would like to write in the tooltip in which regions of Germany this Holiday is available.

I could check the Date for every Region, but this is to much for that.

Any suggestions?

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
YAT
  • 456
  • 1
  • 4
  • 14

1 Answers1

0

Well, since the API of jollyday does not offer the view you want, and it's not using a proper multimap which could do this by itself, you have to just construct it. Do something like this (untested code, my Groovy is rusty):

regionsForHolidays = [:]
regions.each{ region -> 
    holidays = m.getHolidays(year, region)
    holidays.each{ holiday ->
        set = regionsForHolidays[holiday]
        if(set==null){
            set = []
            regionsForHolidays[holiday] = set
        }
        set.add(region)
    }
}

Then you can query regionsForHolidays[holiday] and get a set of regions.

Community
  • 1
  • 1
Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720