net.sf.mpxj.Day Java Examples
The following examples show how to use
net.sf.mpxj.Day.
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: MPXReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Populates a calendar instance. * * @param record MPX record * @param calendar calendar instance * @param isBaseCalendar true if this is a base calendar */ private void populateCalendar(Record record, ProjectCalendar calendar, boolean isBaseCalendar) { if (isBaseCalendar == true) { calendar.setName(record.getString(0)); } else { calendar.setParent(m_projectFile.getCalendarByName(record.getString(0))); } calendar.setWorkingDay(Day.SUNDAY, record.getDayType(1)); calendar.setWorkingDay(Day.MONDAY, record.getDayType(2)); calendar.setWorkingDay(Day.TUESDAY, record.getDayType(3)); calendar.setWorkingDay(Day.WEDNESDAY, record.getDayType(4)); calendar.setWorkingDay(Day.THURSDAY, record.getDayType(5)); calendar.setWorkingDay(Day.FRIDAY, record.getDayType(6)); calendar.setWorkingDay(Day.SATURDAY, record.getDayType(7)); m_eventManager.fireCalendarReadEvent(calendar); }
Example #2
Source File: ProjectFileExporter.java From ganttproject with GNU General Public License v3.0 | 6 votes |
private void exportWeekends(ProjectCalendar calendar) { ProjectCalendarHours workingDayHours = calendar.getCalendarHours(Day.MONDAY); calendar.setWorkingDay(Day.MONDAY, isWorkingDay(Calendar.MONDAY)); calendar.setWorkingDay(Day.TUESDAY, isWorkingDay(Calendar.TUESDAY)); calendar.setWorkingDay(Day.WEDNESDAY, isWorkingDay(Calendar.WEDNESDAY)); calendar.setWorkingDay(Day.THURSDAY, isWorkingDay(Calendar.THURSDAY)); calendar.setWorkingDay(Day.FRIDAY, isWorkingDay(Calendar.FRIDAY)); calendar.setWorkingDay(Day.SATURDAY, isWorkingDay(Calendar.SATURDAY)); if (calendar.isWorkingDay(Day.SATURDAY)) { copyHours(workingDayHours, calendar.addCalendarHours(Day.SATURDAY)); } calendar.setWorkingDay(Day.SUNDAY, isWorkingDay(Calendar.SUNDAY)); if (calendar.isWorkingDay(Day.SUNDAY)) { copyHours(workingDayHours, calendar.addCalendarHours(Day.SUNDAY)); } }
Example #3
Source File: PlannerReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Set the working/non-working status of a weekday. * * @param mpxjCalendar MPXJ calendar * @param mpxjDay day of the week * @param plannerDay planner day type */ private void setWorkingDay(ProjectCalendar mpxjCalendar, Day mpxjDay, String plannerDay) { DayType dayType = DayType.DEFAULT; if (plannerDay != null) { switch (getInt(plannerDay)) { case 0: { dayType = DayType.WORKING; break; } case 1: { dayType = DayType.NON_WORKING; break; } } } mpxjCalendar.setWorkingDay(mpxjDay, dayType); }
Example #4
Source File: PrimaveraReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Process hours in a working day. * * @param calendar project calendar * @param dayRecord working day data */ private void processCalendarHours(ProjectCalendar calendar, Record dayRecord) { // ... for each day of the week Day day = Day.getInstance(Integer.parseInt(dayRecord.getField())); // Get hours List<Record> recHours = dayRecord.getChildren(); if (recHours.size() == 0) { // No data -> not working calendar.setWorkingDay(day, false); } else { calendar.setWorkingDay(day, true); // Read hours ProjectCalendarHours hours = calendar.addCalendarHours(day); for (Record recWorkingHours : recHours) { addHours(hours, recWorkingHours); } } }
Example #5
Source File: PlannerReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Process exception days. * * @param mpxjCalendar MPXJ calendar * @param plannerCalendar Planner calendar */ private void processExceptionDays(ProjectCalendar mpxjCalendar, net.sf.mpxj.planner.schema.Calendar plannerCalendar) throws MPXJException { Days days = plannerCalendar.getDays(); if (days != null) { List<net.sf.mpxj.planner.schema.Day> dayList = days.getDay(); for (net.sf.mpxj.planner.schema.Day day : dayList) { if (day.getType().equals("day-type")) { Date exceptionDate = getDate(day.getDate()); ProjectCalendarException exception = mpxjCalendar.addCalendarException(exceptionDate, exceptionDate); if (getInt(day.getId()) == 0) { for (int hoursIndex = 0; hoursIndex < m_defaultWorkingHours.size(); hoursIndex++) { DateRange range = m_defaultWorkingHours.get(hoursIndex); exception.addRange(range); } } } } } }
Example #6
Source File: SynchroReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Extract data for a single calendar. * * @param row calendar data */ private void processCalendar(MapRow row) { ProjectCalendar calendar = m_project.addCalendar(); Map<UUID, List<DateRange>> dayTypeMap = processDayTypes(row.getRows("DAY_TYPES")); calendar.setName(row.getString("NAME")); processRanges(dayTypeMap.get(row.getUUID("SUNDAY_DAY_TYPE")), calendar.addCalendarHours(Day.SUNDAY)); processRanges(dayTypeMap.get(row.getUUID("MONDAY_DAY_TYPE")), calendar.addCalendarHours(Day.MONDAY)); processRanges(dayTypeMap.get(row.getUUID("TUESDAY_DAY_TYPE")), calendar.addCalendarHours(Day.TUESDAY)); processRanges(dayTypeMap.get(row.getUUID("WEDNESDAY_DAY_TYPE")), calendar.addCalendarHours(Day.WEDNESDAY)); processRanges(dayTypeMap.get(row.getUUID("THURSDAY_DAY_TYPE")), calendar.addCalendarHours(Day.THURSDAY)); processRanges(dayTypeMap.get(row.getUUID("FRIDAY_DAY_TYPE")), calendar.addCalendarHours(Day.FRIDAY)); processRanges(dayTypeMap.get(row.getUUID("SATURDAY_DAY_TYPE")), calendar.addCalendarHours(Day.SATURDAY)); for (MapRow assignment : row.getRows("DAY_TYPE_ASSIGNMENTS")) { Date date = assignment.getDate("DATE"); processRanges(dayTypeMap.get(assignment.getUUID("DAY_TYPE_UUID")), calendar.addCalendarException(date, date)); } m_calendarMap.put(row.getUUID("UUID"), calendar); }
Example #7
Source File: ProjectCommanderReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read a calendar exception. * * @param calendar parent calendar * @param ranges default day of week working times * @param data byte array */ private void readCalendarException(ProjectCalendar calendar, Map<Day, List<DateRange>> ranges, byte[] data) { long timestampInDays = DatatypeConverter.getShort(data, 2, 0); // Heuristic to filter out odd exception dates if (timestampInDays > 0xFF) { long timestampInMilliseconds = timestampInDays * 24 * 60 * 60 * 1000; Date exceptionDate = DateHelper.getTimestampFromLong(timestampInMilliseconds); Calendar cal = DateHelper.popCalendar(); cal.setTime(exceptionDate); Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK)); DateHelper.pushCalendar(cal); ProjectCalendarException ex = calendar.addCalendarException(exceptionDate, exceptionDate); if (!calendar.isWorkingDay(day)) { ranges.get(day).stream().forEach(range -> ex.addRange(range)); } } }
Example #8
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 #9
Source File: RecurrenceUtility.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Convert Day instance to MPX day index. * * @param day Day instance * @return day index */ public static Integer getDay(Day day) { Integer result = null; if (day != null) { result = DAY_MAP.get(day); } return (result); }
Example #10
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 #11
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 #12
Source File: MSPDIReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method extracts data for a normal working day from an MSPDI file. * * @param calendar Calendar data * @param weekDay Day data */ private void readNormalDay(ProjectCalendar calendar, Project.Calendars.Calendar.WeekDays.WeekDay weekDay) { int dayNumber = weekDay.getDayType().intValue(); Day day = Day.getInstance(dayNumber); calendar.setWorkingDay(day, BooleanHelper.getBoolean(weekDay.isDayWorking())); ProjectCalendarHours hours = calendar.addCalendarHours(day); Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes times = weekDay.getWorkingTimes(); if (times != null) { for (Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes.WorkingTime period : times.getWorkingTime()) { Date startTime = period.getFromTime(); Date endTime = period.getToTime(); if (startTime != null && endTime != null) { if (startTime.getTime() >= endTime.getTime()) { endTime = DateHelper.addDays(endTime, 1); } hours.addRange(new DateRange(startTime, endTime)); } } } }
Example #13
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 #14
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 #15
Source File: ProjectTreeController.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Add a calendar day node. * * @param parentNode parent node * @param calendar ProjectCalendar instance * @param day calendar day */ private void addCalendarDay(MpxjTreeNode parentNode, ProjectCalendar calendar, final Day day) { MpxjTreeNode dayNode = new MpxjTreeNode(day) { @Override public String toString() { return day.name(); } }; parentNode.add(dayNode); addHours(dayNode, calendar.getHours(day)); }
Example #16
Source File: RecurrenceUtility.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Convert MPX day index to Day instance. * * @param day day index * @return Day instance */ public static Day getDay(Integer day) { Day result = null; if (day != null) { result = DAY_ARRAY[day.intValue()]; } return (result); }
Example #17
Source File: MPXReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Populates a calendar hours instance. * * @param record MPX record * @param hours calendar hours instance * @throws MPXJException */ private void populateCalendarHours(Record record, ProjectCalendarHours hours) throws MPXJException { hours.setDay(Day.getInstance(NumberHelper.getInt(record.getInteger(0)))); addDateRange(hours, record.getTime(1), record.getTime(2)); addDateRange(hours, record.getTime(3), record.getTime(4)); addDateRange(hours, record.getTime(5), record.getTime(6)); }
Example #18
Source File: ProjectFileImporter.java From ganttproject with GNU General Public License v3.0 | 5 votes |
private void importWeekends(ProjectCalendar calendar) { importDayType(calendar, Day.MONDAY, Calendar.MONDAY); importDayType(calendar, Day.TUESDAY, Calendar.TUESDAY); importDayType(calendar, Day.WEDNESDAY, Calendar.WEDNESDAY); importDayType(calendar, Day.THURSDAY, Calendar.THURSDAY); importDayType(calendar, Day.FRIDAY, Calendar.FRIDAY); importDayType(calendar, Day.SATURDAY, Calendar.SATURDAY); importDayType(calendar, Day.SUNDAY, Calendar.SUNDAY); }
Example #19
Source File: AbstractCalendarAndExceptionFactory.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Process an individual work week day. * * @param data calendar data * @param offset current offset into data * @param week parent week * @param day current day */ private void processWorkWeekDay(byte[] data, int offset, ProjectCalendarWeek week, Day day) { //System.out.println(ByteArrayHelper.hexdump(data, offset, 60, false)); int dayType = MPPUtility.getShort(data, offset + 0); if (dayType == 1) { week.setWorkingDay(day, DayType.DEFAULT); } else { ProjectCalendarHours hours = week.addCalendarHours(day); int rangeCount = MPPUtility.getShort(data, offset + 2); if (rangeCount == 0) { week.setWorkingDay(day, DayType.NON_WORKING); } else { week.setWorkingDay(day, DayType.WORKING); Calendar cal = DateHelper.popCalendar(); for (int index = 0; index < rangeCount; index++) { Date startTime = DateHelper.getCanonicalTime(MPPUtility.getTime(data, offset + 8 + (index * 2))); int durationInSeconds = MPPUtility.getInt(data, offset + 20 + (index * 4)) * 6; cal.setTime(startTime); cal.add(Calendar.SECOND, durationInSeconds); Date finishTime = DateHelper.getCanonicalTime(cal.getTime()); hours.addRange(new DateRange(startTime, finishTime)); } DateHelper.pushCalendar(cal); } } }
Example #20
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 #21
Source File: PrimaveraPMFileReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Process project properties. * * @param apibo top level object * @param project xml container */ private void processProjectProperties(APIBusinessObjects apibo, ProjectType project) { ProjectProperties properties = m_projectFile.getProjectProperties(); properties.setCreationDate(project.getCreateDate()); properties.setFinishDate(project.getFinishDate()); properties.setName(project.getName()); properties.setStartDate(project.getPlannedStartDate()); properties.setStatusDate(project.getDataDate()); properties.setProjectTitle(project.getId()); properties.setUniqueID(project.getObjectId() == null ? null : project.getObjectId().toString()); List<GlobalPreferencesType> list = apibo.getGlobalPreferences(); if (!list.isEmpty()) { GlobalPreferencesType prefs = list.get(0); properties.setCreationDate(prefs.getCreateDate()); properties.setLastSaved(prefs.getLastUpdateDate()); properties.setMinutesPerDay(Integer.valueOf((int) (NumberHelper.getDouble(prefs.getHoursPerDay()) * 60))); properties.setMinutesPerWeek(Integer.valueOf((int) (NumberHelper.getDouble(prefs.getHoursPerWeek()) * 60))); properties.setWeekStartDay(Day.getInstance(NumberHelper.getInt(prefs.getStartDayOfWeek()))); List<CurrencyType> currencyList = apibo.getCurrency(); for (CurrencyType currency : currencyList) { if (currency.getObjectId().equals(prefs.getBaseCurrencyObjectId())) { properties.setCurrencySymbol(currency.getSymbol()); break; } } } }
Example #22
Source File: PlannerReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method extracts data for a single resource from a Planner file. * * @param plannerResource Resource data */ private void readResource(net.sf.mpxj.planner.schema.Resource plannerResource) throws MPXJException { Resource mpxjResource = m_projectFile.addResource(); //mpxjResource.setResourceCalendar(m_projectFile.getBaseCalendarByUniqueID(getInteger(plannerResource.getCalendar()))); mpxjResource.setEmailAddress(plannerResource.getEmail()); mpxjResource.setUniqueID(getInteger(plannerResource.getId())); mpxjResource.setName(plannerResource.getName()); mpxjResource.setNotes(plannerResource.getNote()); mpxjResource.setInitials(plannerResource.getShortName()); mpxjResource.setType(getInt(plannerResource.getType()) == 2 ? ResourceType.MATERIAL : ResourceType.WORK); //plannerResource.getStdRate(); //plannerResource.getOvtRate(); //plannerResource.getUnits(); //plannerResource.getProperties(); ProjectCalendar calendar = mpxjResource.addResourceCalendar(); calendar.setWorkingDay(Day.SUNDAY, DayType.DEFAULT); calendar.setWorkingDay(Day.MONDAY, DayType.DEFAULT); calendar.setWorkingDay(Day.TUESDAY, DayType.DEFAULT); calendar.setWorkingDay(Day.WEDNESDAY, DayType.DEFAULT); calendar.setWorkingDay(Day.THURSDAY, DayType.DEFAULT); calendar.setWorkingDay(Day.FRIDAY, DayType.DEFAULT); calendar.setWorkingDay(Day.SATURDAY, DayType.DEFAULT); ProjectCalendar baseCalendar = m_projectFile.getCalendarByUniqueID(getInteger(plannerResource.getCalendar())); if (baseCalendar == null) { baseCalendar = m_defaultCalendar; } calendar.setParent(baseCalendar); m_eventManager.fireResourceReadEvent(mpxjResource); }
Example #23
Source File: PlannerWriter.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Process the standard working hours for a given day. * * @param mpxjCalendar MPXJ Calendar instance * @param uniqueID unique ID sequence generation * @param day Day instance * @param typeList Planner list of days */ private void processWorkingHours(ProjectCalendar mpxjCalendar, Sequence uniqueID, Day day, List<OverriddenDayType> typeList) { if (isWorkingDay(mpxjCalendar, day)) { ProjectCalendarHours mpxjHours = mpxjCalendar.getCalendarHours(day); if (mpxjHours != null) { OverriddenDayType odt = m_factory.createOverriddenDayType(); typeList.add(odt); odt.setId(getIntegerString(uniqueID.next())); List<Interval> intervalList = odt.getInterval(); for (DateRange mpxjRange : mpxjHours) { Date rangeStart = mpxjRange.getStart(); Date rangeEnd = mpxjRange.getEnd(); if (rangeStart != null && rangeEnd != null) { Interval interval = m_factory.createInterval(); intervalList.add(interval); interval.setStart(getTimeString(rangeStart)); interval.setEnd(getTimeString(rangeEnd)); } } } } }
Example #24
Source File: PlannerWriter.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Used to determine if a particular day of the week is normally * a working day. * * @param mpxjCalendar ProjectCalendar instance * @param day Day instance * @return boolean flag */ private boolean isWorkingDay(ProjectCalendar mpxjCalendar, Day day) { boolean result = false; net.sf.mpxj.DayType type = mpxjCalendar.getWorkingDay(day); if (type == null) { type = net.sf.mpxj.DayType.DEFAULT; } switch (type) { case WORKING: { result = true; break; } case NON_WORKING: { result = false; break; } case DEFAULT: { if (mpxjCalendar.getParent() == null) { result = false; } else { result = isWorkingDay(mpxjCalendar.getParent(), day); } break; } } return (result); }
Example #25
Source File: PlannerWriter.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns a flag represented as a String, indicating if * the supplied day is a working day. * * @param mpxjCalendar MPXJ ProjectCalendar instance * @param day Day instance * @return boolean flag as a string */ private String getWorkingDayString(ProjectCalendar mpxjCalendar, Day day) { String result = null; net.sf.mpxj.DayType type = mpxjCalendar.getWorkingDay(day); if (type == null) { type = net.sf.mpxj.DayType.DEFAULT; } switch (type) { case WORKING: { result = "0"; break; } case NON_WORKING: { result = "1"; break; } case DEFAULT: { result = "2"; break; } } return (result); }
Example #26
Source File: MerlinReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read project properties. */ private void processProject() throws SQLException { ProjectProperties props = m_project.getProjectProperties(); Row row = getRows("select * from zproject where z_pk=?", m_projectID).get(0); props.setWeekStartDay(Day.getInstance(row.getInt("ZFIRSTDAYOFWEEK") + 1)); props.setScheduleFrom(row.getInt("ZSCHEDULINGDIRECTION") == 1 ? ScheduleFrom.START : ScheduleFrom.FINISH); props.setMinutesPerDay(Integer.valueOf(row.getInt("ZHOURSPERDAY") * 60)); props.setDaysPerMonth(row.getInteger("ZDAYSPERMONTH")); props.setMinutesPerWeek(Integer.valueOf(row.getInt("ZHOURSPERWEEK") * 60)); props.setStatusDate(row.getTimestamp("ZGIVENSTATUSDATE")); props.setCurrencySymbol(row.getString("ZCURRENCYSYMBOL")); props.setName(row.getString("ZTITLE")); props.setUniqueID(row.getUUID("ZUNIQUEID").toString()); }
Example #27
Source File: MapRow.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} */ @Override public Day getDay(String name) { Day result = null; Integer value = getInteger(name); if (value != null) { result = Day.getInstance(value.intValue() + 1); } return result; }
Example #28
Source File: PrimaveraDatabaseReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Select the project properties from the database. * * @throws SQLException */ private void processProjectProperties() throws SQLException { // // Process common attributes // List<Row> rows = getRows("select * from " + m_schema + "project where proj_id=?", m_projectID); m_reader.processProjectProperties(rows, m_projectID); // // Process PMDB-specific attributes // rows = getRows("select * from " + m_schema + "prefer where prefer.delete_date is null"); if (!rows.isEmpty()) { Row row = rows.get(0); ProjectProperties ph = m_reader.getProject().getProjectProperties(); ph.setCreationDate(row.getDate("create_date")); ph.setLastSaved(row.getDate("update_date")); ph.setMinutesPerDay(Double.valueOf(row.getDouble("day_hr_cnt").doubleValue() * 60)); ph.setMinutesPerWeek(Double.valueOf(row.getDouble("week_hr_cnt").doubleValue() * 60)); ph.setWeekStartDay(Day.getInstance(row.getInt("week_start_day_num"))); processDefaultCurrency(row.getInteger("curr_id")); } processSchedulingProjectProperties(); }
Example #29
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 #30
Source File: GanttDesignerReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read the calendar data from a Gantt Designer file. * * @param gantt Gantt Designer file. */ private void readCalendar(Gantt gantt) { Gantt.Calendar ganttCalendar = gantt.getCalendar(); m_projectFile.getProjectProperties().setWeekStartDay(ganttCalendar.getWeekStart()); ProjectCalendar calendar = m_projectFile.addCalendar(); calendar.setName("Standard"); m_projectFile.setDefaultCalendar(calendar); String workingDays = ganttCalendar.getWorkDays(); calendar.setWorkingDay(Day.SUNDAY, workingDays.charAt(0) == '1'); calendar.setWorkingDay(Day.MONDAY, workingDays.charAt(1) == '1'); calendar.setWorkingDay(Day.TUESDAY, workingDays.charAt(2) == '1'); calendar.setWorkingDay(Day.WEDNESDAY, workingDays.charAt(3) == '1'); calendar.setWorkingDay(Day.THURSDAY, workingDays.charAt(4) == '1'); calendar.setWorkingDay(Day.FRIDAY, workingDays.charAt(5) == '1'); calendar.setWorkingDay(Day.SATURDAY, workingDays.charAt(6) == '1'); for (int i = 1; i <= 7; i++) { Day day = Day.getInstance(i); ProjectCalendarHours hours = calendar.addCalendarHours(day); if (calendar.isWorkingDay(day)) { hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING); hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON); } } for (Gantt.Holidays.Holiday holiday : gantt.getHolidays().getHoliday()) { ProjectCalendarException exception = calendar.addCalendarException(holiday.getDate(), holiday.getDate()); exception.setName(holiday.getContent()); } }