Java Code Examples for net.sf.mpxj.ProjectCalendar#setMinutesPerMonth()
The following examples show how to use
net.sf.mpxj.ProjectCalendar#setMinutesPerMonth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrimaveraReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Process data for an individual calendar. * * @param row calendar data * @return ProjectCalendar instance */ public ProjectCalendar processCalendar(Row row) { ProjectCalendar calendar = m_project.addCalendar(); Integer id = row.getInteger("clndr_id"); calendar.setUniqueID(id); 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 calendar; } // 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); return calendar; }
Example 2
Source File: SureTrakDatabaseReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Read project calendars. */ private void readCalendars() { Table cal = m_tables.get("CAL"); for (MapRow row : cal) { ProjectCalendar calendar = m_projectFile.addCalendar(); m_calendarMap.put(row.getInteger("CALENDAR_ID"), calendar); Integer[] days = { row.getInteger("SUNDAY_HOURS"), row.getInteger("MONDAY_HOURS"), row.getInteger("TUESDAY_HOURS"), row.getInteger("WEDNESDAY_HOURS"), row.getInteger("THURSDAY_HOURS"), row.getInteger("FRIDAY_HOURS"), row.getInteger("SATURDAY_HOURS") }; calendar.setName(row.getString("NAME")); readHours(calendar, Day.SUNDAY, days[0]); readHours(calendar, Day.MONDAY, days[1]); readHours(calendar, Day.TUESDAY, days[2]); readHours(calendar, Day.WEDNESDAY, days[3]); readHours(calendar, Day.THURSDAY, days[4]); readHours(calendar, Day.FRIDAY, days[5]); readHours(calendar, Day.SATURDAY, days[6]); int workingDaysPerWeek = 0; for (Day day : Day.values()) { if (calendar.isWorkingDay(day)) { ++workingDaysPerWeek; } } Integer workingHours = null; for (int index = 0; index < 7; index++) { if (days[index].intValue() != 0) { workingHours = days[index]; break; } } if (workingHours != null) { int workingHoursPerDay = countHours(workingHours); int minutesPerDay = workingHoursPerDay * 60; int minutesPerWeek = minutesPerDay * workingDaysPerWeek; int minutesPerMonth = 4 * minutesPerWeek; int minutesPerYear = 52 * minutesPerWeek; calendar.setMinutesPerDay(Integer.valueOf(minutesPerDay)); calendar.setMinutesPerWeek(Integer.valueOf(minutesPerWeek)); calendar.setMinutesPerMonth(Integer.valueOf(minutesPerMonth)); calendar.setMinutesPerYear(Integer.valueOf(minutesPerYear)); } } }