private void writeCalendar ( ProjectCalendar mpxjCalendar , net . sf . mpxj . planner . schema . Calendar plannerCalendar ) throws JAXBException { // // Populate basic details // plannerCalendar . setId ( getIntegerString ( mpxjCalendar . getUniqueID ( ) ) ) ; plannerCalendar . setName ( getString ( mpxjCalendar . getName ( ) ) ) ; // // Set working and non working days // DefaultWeek dw = m_factory . createDefaultWeek ( ) ; plannerCalendar . setDefaultWeek ( dw ) ; dw . setMon ( getWorkingDayString ( mpxjCalendar , Day . MONDAY ) ) ; dw . setTue ( getWorkingDayString ( mpxjCalendar , Day . TUESDAY ) ) ; dw . setWed ( getWorkingDayString ( mpxjCalendar , Day . WEDNESDAY ) ) ; dw . setThu ( getWorkingDayString ( mpxjCalendar , Day . THURSDAY ) ) ; dw . setFri ( getWorkingDayString ( mpxjCalendar , Day . FRIDAY ) ) ; dw . setSat ( getWorkingDayString ( mpxjCalendar , Day . SATURDAY ) ) ; dw . setSun ( getWorkingDayString ( mpxjCalendar , Day . SUNDAY ) ) ; // // Set working hours // OverriddenDayTypes odt = m_factory . createOverriddenDayTypes ( ) ; plannerCalendar . setOverriddenDayTypes ( odt ) ; List < OverriddenDayType > typeList = odt . getOverriddenDayType ( ) ; Sequence uniqueID = new Sequence ( 0 ) ; // // This is a bit arbitrary, so not ideal, however... // The idea here is that MS Project allows us to specify working hours // for each day of the week individually. Planner doesn't do this, // but instead allows us to specify working hours for each day type. // What we are doing here is stepping through the days of the week to // find the first working day, then using the hours for that day // as the hours for the working day type in Planner. // for ( int dayLoop = 1 ; dayLoop < 8 ; dayLoop ++ ) { Day day = Day . getInstance ( dayLoop ) ; if ( mpxjCalendar . isWorkingDay ( day ) ) { processWorkingHours ( mpxjCalendar , uniqueID , day , typeList ) ; break ; } } // // Process exception days // Days plannerDays = m_factory . createDays ( ) ; plannerCalendar . setDays ( plannerDays ) ; List < net . sf . mpxj . planner . schema . Day > dayList = plannerDays . getDay ( ) ; processExceptionDays ( mpxjCalendar , dayList ) ; m_eventManager . fireCalendarWrittenEvent ( mpxjCalendar ) ; // // Process any derived calendars // List < net . sf . mpxj . planner . schema . Calendar > calendarList = plannerCalendar . getCalendar ( ) ; for ( ProjectCalendar mpxjDerivedCalendar : mpxjCalendar . getDerivedCalendars ( ) ) { net . sf . mpxj . planner . schema . Calendar plannerDerivedCalendar = m_factory . createCalendar ( ) ; calendarList . add ( plannerDerivedCalendar ) ; writeCalendar ( mpxjDerivedCalendar , plannerDerivedCalendar ) ; } }
This method writes data for a single calendar to a Planner file .