private ProjectCalendar getResourceCalendar ( Integer calendarID ) { ProjectCalendar result = null ; if ( calendarID != null ) { ProjectCalendar calendar = m_calMap . get ( calendarID ) ; if ( calendar != null ) { // // If the resource is linked to a base calendar, derive // a default calendar from the base calendar. // if ( ! calendar . isDerived ( ) ) { ProjectCalendar resourceCalendar = m_project . addCalendar ( ) ; resourceCalendar . setParent ( calendar ) ; resourceCalendar . setWorkingDay ( Day . MONDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . TUESDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . WEDNESDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . THURSDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . FRIDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . SATURDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . SUNDAY , DayType . DEFAULT ) ; result = resourceCalendar ; } else { // // Primavera seems to allow a calendar to be shared between resources // whereas in the MS Project model there is a one-to-one // relationship. If we find a shared calendar, take a copy of it // if ( calendar . getResource ( ) == null ) { result = calendar ; } else { ProjectCalendar copy = m_project . addCalendar ( ) ; copy . copy ( calendar ) ; result = copy ; } } } } return result ; }
Retrieve the correct calendar for a resource .