Java Code Examples for net.sf.mpxj.ProjectCalendar#setUniqueID()
The following examples show how to use
net.sf.mpxj.ProjectCalendar#setUniqueID() .
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: MPD9AbstractReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read a calendar. * * @param row calendar data */ protected void processCalendar(Row row) { Integer uniqueID = row.getInteger("CAL_UID"); if (NumberHelper.getInt(uniqueID) > 0) { boolean baseCalendar = row.getBoolean("CAL_IS_BASE_CAL"); ProjectCalendar cal; if (baseCalendar == true) { cal = m_project.addCalendar(); cal.setName(row.getString("CAL_NAME")); } else { Integer resourceID = row.getInteger("RES_UID"); cal = m_project.addCalendar(); m_baseCalendarReferences.add(new Pair<>(cal, row.getInteger("CAL_BASE_UID"))); m_resourceMap.put(resourceID, cal); } cal.setUniqueID(uniqueID); m_calendarMap.put(uniqueID, cal); m_eventManager.fireCalendarReadEvent(cal); } }
Example 2
Source File: MSPDIReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method extracts data for a single calendar from an MSPDI file. * * @param calendar Calendar data * @param map Map of calendar UIDs to names * @param baseCalendars list of base calendars */ private void readCalendar(Project.Calendars.Calendar calendar, HashMap<BigInteger, ProjectCalendar> map, List<Pair<ProjectCalendar, BigInteger>> baseCalendars) { ProjectCalendar bc = m_projectFile.addCalendar(); bc.setUniqueID(NumberHelper.getInteger(calendar.getUID())); bc.setName(calendar.getName()); BigInteger baseCalendarID = calendar.getBaseCalendarUID(); if (baseCalendarID != null) { baseCalendars.add(new Pair<>(bc, baseCalendarID)); } readExceptions(calendar, bc); boolean readExceptionsFromDays = bc.getCalendarExceptions().isEmpty(); Project.Calendars.Calendar.WeekDays days = calendar.getWeekDays(); if (days != null) { for (Project.Calendars.Calendar.WeekDays.WeekDay weekDay : days.getWeekDay()) { readDay(bc, weekDay, readExceptionsFromDays); } } else { bc.setWorkingDay(Day.SUNDAY, DayType.DEFAULT); bc.setWorkingDay(Day.MONDAY, DayType.DEFAULT); bc.setWorkingDay(Day.TUESDAY, DayType.DEFAULT); bc.setWorkingDay(Day.WEDNESDAY, DayType.DEFAULT); bc.setWorkingDay(Day.THURSDAY, DayType.DEFAULT); bc.setWorkingDay(Day.FRIDAY, DayType.DEFAULT); bc.setWorkingDay(Day.SATURDAY, DayType.DEFAULT); } readWorkWeeks(calendar, bc); map.put(calendar.getUID(), bc); m_eventManager.fireCalendarReadEvent(bc); }
Example 3
Source File: AstaReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Derive a calendar for a resource. * * @param parentCalendarID calendar from which resource calendar is derived * @return new calendar for a resource */ private ProjectCalendar deriveResourceCalendar(Integer parentCalendarID) { ProjectCalendar calendar = m_project.addDefaultDerivedCalendar(); calendar.setUniqueID(Integer.valueOf(m_project.getProjectConfig().getNextCalendarUniqueID())); calendar.setParent(m_project.getCalendarByUniqueID(parentCalendarID)); return calendar; }
Example 4
Source File: MerlinReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read calendar data. */ private void processCalendars() throws Exception { List<Row> rows = getRows("select * from zcalendar where zproject=?", m_projectID); for (Row row : rows) { ProjectCalendar calendar = m_project.addCalendar(); calendar.setUniqueID(row.getInteger("Z_PK")); calendar.setName(row.getString("ZTITLE")); processDays(calendar); processExceptions(calendar); m_eventManager.fireCalendarReadEvent(calendar); } }
Example 5
Source File: PlannerReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * This method extracts data for a single calendar from a Planner file. * * @param plannerCalendar Calendar data * @param parentMpxjCalendar parent of derived calendar */ private void readCalendar(net.sf.mpxj.planner.schema.Calendar plannerCalendar, ProjectCalendar parentMpxjCalendar) throws MPXJException { // // Create a calendar instance // ProjectCalendar mpxjCalendar = m_projectFile.addCalendar(); // // Populate basic details // mpxjCalendar.setUniqueID(getInteger(plannerCalendar.getId())); mpxjCalendar.setName(plannerCalendar.getName()); mpxjCalendar.setParent(parentMpxjCalendar); // // Set working and non working days // DefaultWeek dw = plannerCalendar.getDefaultWeek(); setWorkingDay(mpxjCalendar, Day.MONDAY, dw.getMon()); setWorkingDay(mpxjCalendar, Day.TUESDAY, dw.getTue()); setWorkingDay(mpxjCalendar, Day.WEDNESDAY, dw.getWed()); setWorkingDay(mpxjCalendar, Day.THURSDAY, dw.getThu()); setWorkingDay(mpxjCalendar, Day.FRIDAY, dw.getFri()); setWorkingDay(mpxjCalendar, Day.SATURDAY, dw.getSat()); setWorkingDay(mpxjCalendar, Day.SUNDAY, dw.getSun()); // // Set working hours // processWorkingHours(mpxjCalendar, plannerCalendar); // // Process exception days // processExceptionDays(mpxjCalendar, plannerCalendar); m_eventManager.fireCalendarReadEvent(mpxjCalendar); // // Process any derived calendars // List<net.sf.mpxj.planner.schema.Calendar> calendarList = plannerCalendar.getCalendar(); for (net.sf.mpxj.planner.schema.Calendar cal : calendarList) { readCalendar(cal, mpxjCalendar); } }
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; }