Java Code Examples for net.sf.mpxj.Day#values()
The following examples show how to use
net.sf.mpxj.Day#values() .
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: MSPDIWriter.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Converts days of the week into a bit field. * * @param data recurring data * @return bit field */ private BigInteger getDaysOfTheWeek(RecurringData data) { int value = 0; for (Day day : Day.values()) { if (data.getWeeklyDay(day)) { value = value | DAY_MASKS[day.getValue()]; } } return BigInteger.valueOf(value); }
Example 2
Source File: ProjectTreeController.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Add a calendar node. * * @param parentNode parent node * @param calendar calendar */ private void addCalendar(MpxjTreeNode parentNode, final ProjectCalendar calendar) { MpxjTreeNode calendarNode = new MpxjTreeNode(calendar, CALENDAR_EXCLUDED_METHODS) { @Override public String toString() { return calendar.getName(); } }; parentNode.add(calendarNode); MpxjTreeNode daysFolder = new MpxjTreeNode("Days"); calendarNode.add(daysFolder); for (Day day : Day.values()) { addCalendarDay(daysFolder, calendar, day); } MpxjTreeNode exceptionsFolder = new MpxjTreeNode("Exceptions"); calendarNode.add(exceptionsFolder); for (ProjectCalendarException exception : calendar.getCalendarExceptions()) { addCalendarException(exceptionsFolder, exception); } }
Example 3
Source File: RecurrenceUtility.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Convert weekly recurrence days into a bit field. * * @param task recurring task * @return bit field as a string */ public static String getDays(RecurringTask task) { StringBuilder sb = new StringBuilder(); for (Day day : Day.values()) { sb.append(task.getWeeklyDay(day) ? "1" : "0"); } return sb.toString(); }
Example 4
Source File: GanttProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Add working days and working time to a calendar. * * @param mpxjCalendar MPXJ calendar * @param gpCalendar GanttProject calendar */ private void setWorkingDays(ProjectCalendar mpxjCalendar, Calendars gpCalendar) { DayTypes dayTypes = gpCalendar.getDayTypes(); DefaultWeek defaultWeek = dayTypes.getDefaultWeek(); if (defaultWeek == null) { mpxjCalendar.setWorkingDay(Day.SUNDAY, false); mpxjCalendar.setWorkingDay(Day.MONDAY, true); mpxjCalendar.setWorkingDay(Day.TUESDAY, true); mpxjCalendar.setWorkingDay(Day.WEDNESDAY, true); mpxjCalendar.setWorkingDay(Day.THURSDAY, true); mpxjCalendar.setWorkingDay(Day.FRIDAY, true); mpxjCalendar.setWorkingDay(Day.SATURDAY, false); } else { mpxjCalendar.setWorkingDay(Day.MONDAY, isWorkingDay(defaultWeek.getMon())); mpxjCalendar.setWorkingDay(Day.TUESDAY, isWorkingDay(defaultWeek.getTue())); mpxjCalendar.setWorkingDay(Day.WEDNESDAY, isWorkingDay(defaultWeek.getWed())); mpxjCalendar.setWorkingDay(Day.THURSDAY, isWorkingDay(defaultWeek.getThu())); mpxjCalendar.setWorkingDay(Day.FRIDAY, isWorkingDay(defaultWeek.getFri())); mpxjCalendar.setWorkingDay(Day.SATURDAY, isWorkingDay(defaultWeek.getSat())); mpxjCalendar.setWorkingDay(Day.SUNDAY, isWorkingDay(defaultWeek.getSun())); } for (Day day : Day.values()) { if (mpxjCalendar.isWorkingDay(day)) { ProjectCalendarHours hours = mpxjCalendar.addCalendarHours(day); hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING); hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON); } } }
Example 5
Source File: CalendarRecord.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void process(Context context) { ProjectCalendar calendar = context.addCalendar(getString(0)); calendar.setName(getString(2)); String flags = getString(1); for (Day day : Day.values()) { calendar.setWorkingDay(day, flags.charAt(day.getValue() - 1) == 'Y'); } context.getEventManager().fireCalendarReadEvent(calendar); }
Example 6
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 7
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)); } } }
Example 8
Source File: AbstractCalendarAndExceptionFactory.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Read the work weeks. * * @param data calendar data * @param offset current offset into data * @param cal parent calendar */ private void processWorkWeeks(byte[] data, int offset, ProjectCalendar cal) { // System.out.println("Calendar=" + cal.getName()); // System.out.println("Work week block start offset=" + offset); // System.out.println(ByteArrayHelper.hexdump(data, true, 16, "")); // skip 4 byte header offset += 4; while (data.length >= offset + ((7 * 60) + 2 + 2 + 8 + 4)) { //System.out.println("Week start offset=" + offset); ProjectCalendarWeek week = cal.addWorkWeek(); for (Day day : Day.values()) { // 60 byte block per day processWorkWeekDay(data, offset, week, day); offset += 60; } Date startDate = DateHelper.getDayStartDate(MPPUtility.getDate(data, offset)); offset += 2; Date finishDate = DateHelper.getDayEndDate(MPPUtility.getDate(data, offset)); offset += 2; // skip unknown 8 bytes //System.out.println(ByteArrayHelper.hexdump(data, offset, 8, false)); offset += 8; // // Extract the name length - ensure that it is aligned to a 4 byte boundary // int nameLength = MPPUtility.getInt(data, offset); if (nameLength % 4 != 0) { nameLength = ((nameLength / 4) + 1) * 4; } offset += 4; if (nameLength != 0) { String name = MPPUtility.getUnicodeString(data, offset, nameLength); offset += nameLength; week.setName(name); } week.setDateRange(new DateRange(startDate, finishDate)); // System.out.println(week); } }