Java Code Examples for net.sf.mpxj.ProjectFile#getCalendars()
The following examples show how to use
net.sf.mpxj.ProjectFile#getCalendars() .
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: CalendarCalendarsTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test an individual project. * * @param file project file */ private void testCalendars(File file) throws MPXJException { ProjectReader reader = ProjectReaderUtility.getProjectReader(file.getName()); if (reader instanceof MPDDatabaseReader) { assumeJvm(); } ProjectFile project = reader.read(file); ProjectCalendarContainer calendars = project.getCalendars(); int id = 1; assertEquals("Standard", calendars.getByUniqueID(Integer.valueOf(id++)).getName()); if (!file.getName().endsWith(".mpx")) { id++; } assertEquals("Calendar1", calendars.getByUniqueID(Integer.valueOf(id++)).getName()); assertEquals("Calendar2", calendars.getByUniqueID(Integer.valueOf(id++)).getName()); assertEquals("Resource One", calendars.getByUniqueID(Integer.valueOf(id++)).getName()); assertEquals("Resource Two", calendars.getByUniqueID(Integer.valueOf(id++)).getName()); }
Example 2
Source File: ProjectTreeController.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Add calendars to the tree. * * @param parentNode parent tree node * @param file calendar container */ private void addCalendars(MpxjTreeNode parentNode, ProjectFile file) { for (ProjectCalendar calendar : file.getCalendars()) { addCalendar(parentNode, calendar); } }
Example 3
Source File: MpxjQuery.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * List details of all calendars in the file. * * @param file ProjectFile instance */ private static void listCalendars(ProjectFile file) { for (ProjectCalendar cal : file.getCalendars()) { System.out.println(cal.toString()); } }
Example 4
Source File: MppCalendarTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test calendar data. * * @param mpp ProjectFile instance */ private void testCalendars(ProjectFile mpp) { DateFormat tf = new SimpleDateFormat("HH:mm"); List<ProjectCalendar> baseCalendars = mpp.getCalendars(); assertEquals(8, baseCalendars.size()); ProjectCalendar cal = mpp.getCalendarByUniqueID(Integer.valueOf(1)); assertNotNull(cal); assertEquals("Standard", cal.getName()); assertNull(cal.getParent()); assertFalse(cal.isDerived()); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.MONDAY)); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.TUESDAY)); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.WEDNESDAY)); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.THURSDAY)); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.FRIDAY)); assertEquals(DayType.NON_WORKING, cal.getWorkingDay(Day.SATURDAY)); assertEquals(DayType.NON_WORKING, cal.getWorkingDay(Day.SUNDAY)); assertEquals(0, cal.getCalendarExceptions().size()); ProjectCalendarHours hours = cal.getCalendarHours(Day.MONDAY); assertEquals(2, hours.getRangeCount()); DateRange range = hours.getRange(0); assertEquals("08:00", tf.format(range.getStart())); assertEquals("12:00", tf.format(range.getEnd())); range = cal.getCalendarHours(Day.MONDAY).getRange(1); assertEquals("13:00", tf.format(range.getStart())); assertEquals("17:00", tf.format(range.getEnd())); }
Example 5
Source File: MppCalendarTest.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Test calendar exceptions. * * @param mpp ProjectFile instance */ private void testExceptions(ProjectFile mpp) { DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm"); DateFormat tf = new SimpleDateFormat("HH:mm"); List<ProjectCalendar> baseCalendars = mpp.getCalendars(); assertEquals(2, baseCalendars.size()); ProjectCalendar cal = mpp.getCalendarByUniqueID(Integer.valueOf(1)); assertNotNull(cal); assertEquals("Standard", cal.getName()); assertNull(cal.getParent()); assertFalse(cal.isDerived()); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.MONDAY)); assertEquals(DayType.NON_WORKING, cal.getWorkingDay(Day.TUESDAY)); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.WEDNESDAY)); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.THURSDAY)); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.FRIDAY)); assertEquals(DayType.WORKING, cal.getWorkingDay(Day.SATURDAY)); assertEquals(DayType.NON_WORKING, cal.getWorkingDay(Day.SUNDAY)); List<net.sf.mpxj.ProjectCalendarException> exceptions = cal.getCalendarExceptions(); assertEquals(3, exceptions.size()); ProjectCalendarException exception = exceptions.get(0); assertFalse(exception.getWorking()); assertEquals("05/03/2008 00:00", df.format(exception.getFromDate())); assertEquals("05/03/2008 23:59", df.format(exception.getToDate())); assertNull(exception.getRange(0).getStart()); assertNull(exception.getRange(0).getEnd()); assertNull(exception.getRange(1).getStart()); assertNull(exception.getRange(1).getEnd()); assertNull(exception.getRange(2).getStart()); assertNull(exception.getRange(2).getEnd()); assertNull(exception.getRange(3).getStart()); assertNull(exception.getRange(3).getEnd()); assertNull(exception.getRange(4).getStart()); assertNull(exception.getRange(4).getEnd()); exception = exceptions.get(1); assertTrue(exception.getWorking()); assertEquals("09/03/2008 00:00", df.format(exception.getFromDate())); assertEquals("09/03/2008 23:59", df.format(exception.getToDate())); assertEquals("08:00", tf.format(exception.getRange(0).getStart())); assertEquals("12:00", tf.format(exception.getRange(0).getEnd())); assertEquals("13:00", tf.format(exception.getRange(1).getStart())); assertEquals("17:00", tf.format(exception.getRange(1).getEnd())); assertNull(exception.getRange(2).getStart()); assertNull(exception.getRange(2).getEnd()); assertNull(exception.getRange(3).getStart()); assertNull(exception.getRange(3).getEnd()); assertNull(exception.getRange(4).getStart()); assertNull(exception.getRange(4).getEnd()); exception = exceptions.get(2); assertTrue(exception.getWorking()); assertEquals("16/03/2008 00:00", df.format(exception.getFromDate())); assertEquals("16/03/2008 23:59", df.format(exception.getToDate())); assertEquals("08:00", tf.format(exception.getRange(0).getStart())); assertEquals("09:00", tf.format(exception.getRange(0).getEnd())); assertEquals("11:00", tf.format(exception.getRange(1).getStart())); assertEquals("12:00", tf.format(exception.getRange(1).getEnd())); assertEquals("14:00", tf.format(exception.getRange(2).getStart())); assertEquals("15:00", tf.format(exception.getRange(2).getEnd())); assertEquals("16:00", tf.format(exception.getRange(3).getStart())); assertEquals("17:00", tf.format(exception.getRange(3).getEnd())); assertEquals("18:00", tf.format(exception.getRange(4).getStart())); assertEquals("19:00", tf.format(exception.getRange(4).getEnd())); }