public void processCalendar ( Row row ) { ProjectCalendar calendar = m_project . addCalendar ( ) ; Integer id = row . getInteger ( "clndr_id" ) ; m_calMap . put ( id , calendar ) ; calendar . setName ( row . getString ( "clndr_name" ) ) ; try { calendar . setMinutesPerDay ( Integer . valueOf ( ( int ) NumberHelper . getDouble ( row . getDouble ( "day_hr_cnt" ) ) * 60 ) ) ; calendar . setMinutesPerWeek ( Integer . valueOf ( ( int ) ( NumberHelper . getDouble ( row . getDouble ( "week_hr_cnt" ) ) * 60 ) ) ) ; calendar . setMinutesPerMonth ( Integer . valueOf ( ( int ) ( NumberHelper . getDouble ( row . getDouble ( "month_hr_cnt" ) ) * 60 ) ) ) ; calendar . setMinutesPerYear ( Integer . valueOf ( ( int ) ( NumberHelper . getDouble ( row . getDouble ( "year_hr_cnt" ) ) * 60 ) ) ) ; } catch ( ClassCastException ex ) { // We have seen examples of malformed calendar data where fields have been missing // from the record. We'll typically get a class cast exception here as we're trying // to process something which isn't a double. // We'll just return at this point as it's not clear that we can salvage anything // sensible from this record. return ; } // Process data String calendarData = row . getString ( "clndr_data" ) ; if ( calendarData != null && ! calendarData . isEmpty ( ) ) { Record root = Record . getRecord ( calendarData ) ; if ( root != null ) { processCalendarDays ( calendar , root ) ; processCalendarExceptions ( calendar , root ) ; } } else { // if there is not DaysOfWeek data, Primavera seems to default to Mon-Fri, 8:00-16:00 DateRange defaultHourRange = new DateRange ( DateHelper . getTime ( 8 , 0 ) , DateHelper . getTime ( 16 , 0 ) ) ; for ( Day day : Day . values ( ) ) { if ( day != Day . SATURDAY && day != Day . SUNDAY ) { calendar . setWorkingDay ( day , true ) ; ProjectCalendarHours hours = calendar . addCalendarHours ( day ) ; hours . addRange ( defaultHourRange ) ; } else { calendar . setWorkingDay ( day , false ) ; } } } m_eventManager . fireCalendarReadEvent ( calendar ) ; }
Process data for an individual calendar .