code: private void processWorkPattern(ProjectCalendarWeek week, Integer workPatternID, Map<Integer, Row> workPatternMap, Map<Integer, List<Row>> timeEntryMap, Map<Integer, DayType> exceptionTypeMap)
     {
        Row workPatternRow = workPatternMap.get(workPatternID);
        if (workPatternRow != null)
        {
           week.setName(workPatternRow.getString("NAMN"));
  
           List<Row> timeEntryRows = timeEntryMap.get(workPatternID);
           if (timeEntryRows != null)
           {
              long lastEndTime = Long.MIN_VALUE;
              Day currentDay = Day.SUNDAY;
              ProjectCalendarHours hours = week.addCalendarHours(currentDay);
              Arrays.fill(week.getDays(), DayType.NON_WORKING);
  
              for (Row row : timeEntryRows)
              {
                 Date startTime = row.getDate("START_TIME");
                 Date endTime = row.getDate("END_TIME");
                 if (startTime == null)
                 {
                    startTime = DateHelper.getDayStartDate(new Date(0));
                 }
  
                 if (endTime == null)
                 {
                    endTime = DateHelper.getDayEndDate(new Date(0));
                 }
  
                 if (startTime.getTime() > endTime.getTime())
                 {
                    endTime = DateHelper.addDays(endTime, 1);
                 }
  
                 if (startTime.getTime() < lastEndTime)
                 {
                    currentDay = currentDay.getNextDay();
                    hours = week.addCalendarHours(currentDay);
                 }
  
                 DayType type = exceptionTypeMap.get(row.getInteger("EXCEPTIOP"));
                 if (type == DayType.WORKING)
                 {
                    hours.addRange(new DateRange(startTime, endTime));
                    week.setWorkingDay(currentDay, DayType.WORKING);
                 }
  
                 lastEndTime = endTime.getTime();
              }
           }
        }
     }
docs: Populates a ProjectCalendarWeek instance from Asta work pattern data.
  
  @param week target ProjectCalendarWeek instance
  @param workPatternID target work pattern ID
  @param workPatternMap work pattern data
  @param timeEntryMap time entry map
  @param exceptionTypeMap exception type map