private void writeCalendar ( ProjectCalendar mpxj ) { CalendarType xml = m_factory . createCalendarType ( ) ; m_apibo . getCalendar ( ) . add ( xml ) ; String type = mpxj . getResource ( ) == null ? "Global" : "Resource" ; xml . setBaseCalendarObjectId ( getCalendarUniqueID ( mpxj . getParent ( ) ) ) ; xml . setIsPersonal ( mpxj . getResource ( ) == null ? Boolean . FALSE : Boolean . TRUE ) ; xml . setName ( mpxj . getName ( ) ) ; xml . setObjectId ( mpxj . getUniqueID ( ) ) ; xml . setType ( type ) ; StandardWorkWeek xmlStandardWorkWeek = m_factory . createCalendarTypeStandardWorkWeek ( ) ; xml . setStandardWorkWeek ( xmlStandardWorkWeek ) ; for ( Day day : EnumSet . allOf ( Day . class ) ) { StandardWorkHours xmlHours = m_factory . createCalendarTypeStandardWorkWeekStandardWorkHours ( ) ; xmlStandardWorkWeek . getStandardWorkHours ( ) . add ( xmlHours ) ; xmlHours . setDayOfWeek ( getDayName ( day ) ) ; for ( DateRange range : mpxj . getHours ( day ) ) { WorkTimeType xmlWorkTime = m_factory . createWorkTimeType ( ) ; xmlHours . getWorkTime ( ) . add ( xmlWorkTime ) ; xmlWorkTime . setStart ( range . getStart ( ) ) ; xmlWorkTime . setFinish ( getEndTime ( range . getEnd ( ) ) ) ; } } HolidayOrExceptions xmlExceptions = m_factory . createCalendarTypeHolidayOrExceptions ( ) ; xml . setHolidayOrExceptions ( xmlExceptions ) ; if ( ! mpxj . getCalendarExceptions ( ) . isEmpty ( ) ) { Calendar calendar = DateHelper . popCalendar ( ) ; for ( ProjectCalendarException mpxjException : mpxj . getCalendarExceptions ( ) ) { calendar . setTime ( mpxjException . getFromDate ( ) ) ; while ( calendar . getTimeInMillis ( ) < mpxjException . getToDate ( ) . getTime ( ) ) { HolidayOrException xmlException = m_factory . createCalendarTypeHolidayOrExceptionsHolidayOrException ( ) ; xmlExceptions . getHolidayOrException ( ) . add ( xmlException ) ; xmlException . setDate ( calendar . getTime ( ) ) ; for ( DateRange range : mpxjException ) { WorkTimeType xmlHours = m_factory . createWorkTimeType ( ) ; xmlException . getWorkTime ( ) . add ( xmlHours ) ; xmlHours . setStart ( range . getStart ( ) ) ; if ( range . getEnd ( ) != null ) { xmlHours . setFinish ( getEndTime ( range . getEnd ( ) ) ) ; } } calendar . add ( Calendar . DAY_OF_YEAR , 1 ) ; } } DateHelper . pushCalendar ( calendar ) ; } }
This method writes data for an individual calendar to a PM XML file .