net.sf.mpxj.ProjectCalendar Java Examples
The following examples show how to use
net.sf.mpxj.ProjectCalendar.
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: TurboProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read exceptions for a calendar. * * @param table calendar exception data * @param calendar calendar * @param exceptionID first exception ID */ private void addCalendarExceptions(Table table, ProjectCalendar calendar, Integer exceptionID) { Integer currentExceptionID = exceptionID; while (true) { MapRow row = table.find(currentExceptionID); if (row == null) { break; } Date date = row.getDate("DATE"); ProjectCalendarException exception = calendar.addCalendarException(date, date); if (row.getBoolean("WORKING")) { exception.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING); exception.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON); } currentExceptionID = row.getInteger("NEXT_CALENDAR_EXCEPTION_ID"); } }
Example #2
Source File: SDEFWriter.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This will create a line in the SDEF file for each calendar * if there are more than 9 calendars, you'll have a big error, * as USACE numbers them 0-9. * * @param records list of ProjectCalendar instances */ private void writeCalendars(List<ProjectCalendar> records) { // // Write project calendars // for (ProjectCalendar record : records) { m_buffer.setLength(0); m_buffer.append("CLDR "); m_buffer.append(SDEFmethods.lset(record.getUniqueID().toString(), 2)); // 2 character used, USACE allows 1 String workDays = SDEFmethods.workDays(record); // custom line, like NYYYYYN for a week m_buffer.append(SDEFmethods.lset(workDays, 8)); m_buffer.append(SDEFmethods.lset(record.getName(), 30)); m_writer.println(m_buffer); } }
Example #3
Source File: SDEFmethods.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method takes a calendar of MPXJ library type, then returns a String of the * general working days USACE format. For example, the regular 5-day work week is * NYYYYYN * * If you get Fridays off work, then the String becomes NYYYYNN * * @param input ProjectCalendar instance * @return work days string */ public static String workDays(ProjectCalendar input) { StringBuilder result = new StringBuilder(); DayType[] test = input.getDays(); // get the array from MPXJ ProjectCalendar for (DayType i : test) { // go through every day in the given array if (i == DayType.NON_WORKING) { result.append("N"); // only put N for non-working day of the week } else { result.append("Y"); // Assume WORKING day unless NON_WORKING } } return result.toString(); // According to USACE specs., exceptions will be specified in HOLI records }
Example #4
Source File: MPD9AbstractReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Process a calendar exception. * * @param calendar parent calendar * @param row calendar exception data */ private void processCalendarException(ProjectCalendar calendar, Row row) { Date fromDate = row.getDate("CD_FROM_DATE"); Date toDate = row.getDate("CD_TO_DATE"); boolean working = row.getInt("CD_WORKING") != 0; ProjectCalendarException exception = calendar.addCalendarException(fromDate, toDate); if (working) { exception.addRange(new DateRange(row.getDate("CD_FROM_TIME1"), row.getDate("CD_TO_TIME1"))); exception.addRange(new DateRange(row.getDate("CD_FROM_TIME2"), row.getDate("CD_TO_TIME2"))); exception.addRange(new DateRange(row.getDate("CD_FROM_TIME3"), row.getDate("CD_TO_TIME3"))); exception.addRange(new DateRange(row.getDate("CD_FROM_TIME4"), row.getDate("CD_TO_TIME4"))); exception.addRange(new DateRange(row.getDate("CD_FROM_TIME5"), row.getDate("CD_TO_TIME5"))); } }
Example #5
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 #6
Source File: SDEFWriter.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Write calendar exceptions. * * @param records list of ProjectCalendars * @throws IOException */ private void writeExceptions(List<ProjectCalendar> records) throws IOException { for (ProjectCalendar record : records) { if (!record.getCalendarExceptions().isEmpty()) { // Need to move HOLI up here and get 15 exceptions per line as per USACE spec. // for now, we'll write one line for each calendar exception, hope there aren't too many // // changing this would be a serious upgrade, too much coding to do today.... for (ProjectCalendarException ex : record.getCalendarExceptions()) { writeCalendarException(record, ex); } } m_eventManager.fireCalendarWrittenEvent(record); // left here from MPX template, maybe not needed??? } }
Example #7
Source File: AbstractCalendarFactory.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * The way calendars are stored in an MPP14 file means that there * can be forward references between the base calendar unique ID for a * derived calendar, and the base calendar itself. To get around this, * we initially populate the base calendar name attribute with the * base calendar unique ID, and now in this method we can convert those * ID values into the correct names. * * @param baseCalendars list of calendars and base calendar IDs * @param map map of calendar ID values and calendar objects */ private void updateBaseCalendarNames(List<Pair<ProjectCalendar, Integer>> baseCalendars, HashMap<Integer, ProjectCalendar> map) { for (Pair<ProjectCalendar, Integer> pair : baseCalendars) { ProjectCalendar cal = pair.getFirst(); Integer baseCalendarID = pair.getSecond(); ProjectCalendar baseCal = map.get(baseCalendarID); if (baseCal != null && baseCal.getName() != null) { cal.setParent(baseCal); } else { // Remove invalid calendar to avoid serious problems later. m_file.removeCalendar(cal); } } }
Example #8
Source File: MSPDIReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * When projectmanager.com exports schedules as MSPDI (via Aspose tasks) * they do not have finish dates, just a start date and a duration. * This method populates finish dates. * * @param task task to validate */ private void validateFinishDate(Task task) { if (task.getFinish() == null) { Date startDate = task.getStart(); if (startDate != null) { if (task.getMilestone()) { task.setFinish(startDate); } else { Duration duration = task.getDuration(); if (duration != null) { ProjectCalendar calendar = task.getEffectiveCalendar(); task.setFinish(calendar.getDate(startDate, duration, false)); } } } } }
Example #9
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 #10
Source File: MultiDayExceptionsTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test an individual project. * * @param file project file */ private void testMultiDayExceptions(File file) throws Exception { ProjectReader reader = ProjectReaderUtility.getProjectReader(file.getName()); if (reader instanceof MPDDatabaseReader) { assumeJvm(); } DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); ProjectFile project = reader.read(file); ProjectCalendar calendar = project.getCalendarByName("Standard"); Date startDate = DateHelper.getDayStartDate(df.parse("23/12/2019")); Date endDate = DateHelper.getDayEndDate(df.parse("08/01/2020")); Duration duration = calendar.getWork(startDate, endDate, TimeUnit.DAYS); assertEquals("9.0d", duration.toString()); }
Example #11
Source File: InvalidCalendarTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test reading an XER file which contains invalid calendar data. */ @Test public void testInvalidPrimaveraCalendar() throws MPXJException { File testDataDir = new File(MpxjTestData.filePath("calendar/invalid")); File file = new File(testDataDir, "invalid-8.4.xer"); PrimaveraXERFileReader reader = new PrimaveraXERFileReader(); ProjectFile project = reader.read(file); ProjectCalendar calendar = project.getCalendarByUniqueID(Integer.valueOf(178)); assertEquals("Corporate - Standard Full Time", calendar.getName()); calendar = project.getCalendarByUniqueID(Integer.valueOf(179)); assertEquals("Test - Valid", calendar.getName()); calendar = project.getCalendarByUniqueID(Integer.valueOf(180)); assertEquals("Test - Invalid", calendar.getName()); }
Example #12
Source File: SDEFWriter.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Write a calendar exception. * * @param parentCalendar parent calendar instance * @param record calendar exception instance * @throws IOException */ private void writeCalendarException(ProjectCalendar parentCalendar, ProjectCalendarException record) throws IOException { m_buffer.setLength(0); Calendar stepDay = DateHelper.popCalendar(record.getFromDate()); // Start at From Date, then step through days... Calendar lastDay = DateHelper.popCalendar(record.getToDate()); // last day in this exception m_buffer.append("HOLI "); m_buffer.append(SDEFmethods.lset(parentCalendar.getUniqueID().toString(), 2)); while (stepDay.compareTo(lastDay) <= 0) { m_buffer.append(m_formatter.format(stepDay.getTime()).toUpperCase() + " "); stepDay.add(Calendar.DAY_OF_MONTH, 1); } m_writer.println(m_buffer.toString()); DateHelper.pushCalendar(stepDay); DateHelper.pushCalendar(lastDay); }
Example #13
Source File: DateHelper.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This utility method calculates the difference in working * time between two dates, given the context of a task. * * @param task parent task * @param date1 first date * @param date2 second date * @param format required format for the resulting duration * @return difference in working time between the two dates */ public static Duration getVariance(Task task, Date date1, Date date2, TimeUnit format) { Duration variance = null; if (date1 != null && date2 != null) { ProjectCalendar calendar = task.getEffectiveCalendar(); if (calendar != null) { variance = calendar.getWork(date1, date2, format); } } if (variance == null) { variance = Duration.getInstance(0, format); } return (variance); }
Example #14
Source File: TimephasedUtility.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * For a given date range, determine the cost, based on the * timephased resource assignment data. * * @param projectCalendar calendar used for the resource assignment calendar * @param rangeUnits timescale units * @param range target date range * @param assignments timephased resource assignments * @param startIndex index at which to start searching through the timephased resource assignments * @return work duration */ private Double getRangeCost(ProjectCalendar projectCalendar, TimescaleUnits rangeUnits, DateRange range, List<TimephasedCost> assignments, int startIndex) { Double result; switch (rangeUnits) { case MINUTES: case HOURS: { result = getRangeCostSubDay(projectCalendar, rangeUnits, range, assignments, startIndex); break; } default: { result = getRangeCostWholeDay(projectCalendar, rangeUnits, range, assignments, startIndex); break; } } return result; }
Example #15
Source File: TimephasedUtility.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * For a given date range, determine the duration of work, based on the * timephased resource assignment data. * * @param projectCalendar calendar used for the resource assignment calendar * @param rangeUnits timescale units * @param range target date range * @param assignments timephased resource assignments * @param startIndex index at which to start searching through the timephased resource assignments * @return work duration */ private Duration getRangeDuration(ProjectCalendar projectCalendar, TimescaleUnits rangeUnits, DateRange range, List<TimephasedWork> assignments, int startIndex) { Duration result; switch (rangeUnits) { case MINUTES: case HOURS: { result = getRangeDurationSubDay(projectCalendar, rangeUnits, range, assignments, startIndex); break; } default: { result = getRangeDurationWholeDay(projectCalendar, rangeUnits, range, assignments, startIndex); break; } } return result; }
Example #16
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 #17
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 #18
Source File: PlannerWriter.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method writes calendar data to a Planner file. * * @throws JAXBException on xml creation errors */ private void writeCalendars() throws JAXBException { // // Create the new Planner calendar list // Calendars calendars = m_factory.createCalendars(); m_plannerProject.setCalendars(calendars); writeDayTypes(calendars); List<net.sf.mpxj.planner.schema.Calendar> calendar = calendars.getCalendar(); // // Process each calendar in turn // for (ProjectCalendar mpxjCalendar : m_projectFile.getCalendars()) { net.sf.mpxj.planner.schema.Calendar plannerCalendar = m_factory.createCalendar(); calendar.add(plannerCalendar); writeCalendar(mpxjCalendar, plannerCalendar); } }
Example #19
Source File: PlannerWriter.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method writes data for a single resource to a Planner file. * * @param mpxjResource MPXJ Resource instance * @param plannerResource Planner Resource instance */ private void writeResource(Resource mpxjResource, net.sf.mpxj.planner.schema.Resource plannerResource) { ProjectCalendar resourceCalendar = mpxjResource.getResourceCalendar(); if (resourceCalendar != null) { plannerResource.setCalendar(getIntegerString(resourceCalendar.getUniqueID())); } plannerResource.setEmail(mpxjResource.getEmailAddress()); plannerResource.setId(getIntegerString(mpxjResource.getUniqueID())); plannerResource.setName(getString(mpxjResource.getName())); plannerResource.setNote(mpxjResource.getNotes()); plannerResource.setShortName(mpxjResource.getInitials()); plannerResource.setType(mpxjResource.getType() == ResourceType.MATERIAL ? "2" : "1"); //plannerResource.setStdRate(); //plannerResource.setOvtRate(); plannerResource.setUnits("0"); //plannerResource.setProperties(); m_eventManager.fireResourceWrittenEvent(mpxjResource); }
Example #20
Source File: BasicTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Common resource calendar tests. * * @param mpx project file */ private void validateResourceCalendars(ProjectFile mpx) { // // Resource calendar based on standard calendar // Resource resource = mpx.getResourceByUniqueID(Integer.valueOf(1)); ProjectCalendar calendar = resource.getResourceCalendar(); assertEquals("Resource One", calendar.getName()); assertTrue(calendar.isDerived()); assertEquals("Standard", calendar.getParent().getName()); assertTrue(calendar.getCalendarExceptions().isEmpty()); // // Resource calendar based on base calendar // resource = mpx.getResourceByUniqueID(Integer.valueOf(2)); calendar = resource.getResourceCalendar(); assertEquals("Resource Two", calendar.getName()); assertTrue(calendar.isDerived()); assertEquals("Base Calendar", calendar.getParent().getName()); assertTrue(calendar.getCalendarExceptions().isEmpty()); // // Resource calendar based on modified base calendar // resource = mpx.getResourceByUniqueID(Integer.valueOf(3)); calendar = resource.getResourceCalendar(); assertEquals("Resource Three", calendar.getName()); assertTrue(calendar.isDerived()); assertEquals("Base Calendar", calendar.getParent().getName()); assertFalse(calendar.getCalendarExceptions().isEmpty()); }
Example #21
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 #22
Source File: Context.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Add a calendar to the project. * * @param code calendar unique identifier * @return new calendar */ public ProjectCalendar addCalendar(String code) { ProjectCalendar calendar = m_project.addCalendar(); m_calendars.put(code, calendar); return calendar; }
Example #23
Source File: MSPDIReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method extracts calendar data from an MSPDI file. * * @param project Root node of the MSPDI file * @param map Map of calendar UIDs to names */ private void readCalendars(Project project, HashMap<BigInteger, ProjectCalendar> map) { Project.Calendars calendars = project.getCalendars(); if (calendars != null) { List<Pair<ProjectCalendar, BigInteger>> baseCalendars = new ArrayList<>(); for (Project.Calendars.Calendar cal : calendars.getCalendar()) { readCalendar(cal, map, baseCalendars); } updateBaseCalendarNames(baseCalendars, map); } try { ProjectProperties properties = m_projectFile.getProjectProperties(); BigInteger calendarID = new BigInteger(properties.getDefaultCalendarName()); ProjectCalendar calendar = map.get(calendarID); m_projectFile.setDefaultCalendar(calendar); } catch (Exception ex) { // Ignore exceptions } }
Example #24
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 #25
Source File: TimephasedUtility.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This is the main entry point used to convert the internal representation * of timephased work into an external form which can * be displayed to the user. * * @param projectCalendar calendar used by the resource assignment * @param work timephased resource assignment data * @param rangeUnits timescale units * @param dateList timescale date ranges * @return list of durations, one per timescale date range */ public ArrayList<Duration> segmentWork(ProjectCalendar projectCalendar, List<TimephasedWork> work, TimescaleUnits rangeUnits, List<DateRange> dateList) { ArrayList<Duration> result = new ArrayList<>(dateList.size()); int lastStartIndex = 0; // // Iterate through the list of dates range we are interested in. // Each date range in this list corresponds to a column // shown on the "timescale" view by MS Project // for (DateRange range : dateList) { // // If the current date range does not intersect with any of the // assignment date ranges in the list, then we show a zero // duration for this date range. // int startIndex = lastStartIndex == -1 ? -1 : getStartIndex(range, work, lastStartIndex); if (startIndex == -1) { result.add(Duration.getInstance(0, TimeUnit.HOURS)); } else { // // We have found an assignment which intersects with the current // date range, call the method below to determine how // much time from this resource assignment can be allocated // to the current date range. // result.add(getRangeDuration(projectCalendar, rangeUnits, range, work, startIndex)); lastStartIndex = startIndex; } } return result; }
Example #26
Source File: ConceptDrawProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Reads a single day for a calendar. * * @param mpxjCalendar ProjectCalendar instance * @param day ConceptDraw PROJECT week day */ private void readWeekDay(ProjectCalendar mpxjCalendar, WeekDay day) { if (day.isIsDayWorking()) { ProjectCalendarHours hours = mpxjCalendar.addCalendarHours(day.getDay()); for (Document.Calendars.Calendar.WeekDays.WeekDay.TimePeriods.TimePeriod period : day.getTimePeriods().getTimePeriod()) { hours.addRange(new DateRange(period.getFrom(), period.getTo())); } } }
Example #27
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 #28
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 #29
Source File: ConceptDrawProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read an exception day for a calendar. * * @param mpxjCalendar ProjectCalendar instance * @param day ConceptDraw PROJECT exception day */ private void readExceptionDay(ProjectCalendar mpxjCalendar, ExceptedDay day) { ProjectCalendarException mpxjException = mpxjCalendar.addCalendarException(day.getDate(), day.getDate()); if (day.isIsDayWorking()) { for (Document.Calendars.Calendar.ExceptedDays.ExceptedDay.TimePeriods.TimePeriod period : day.getTimePeriods().getTimePeriod()) { mpxjException.addRange(new DateRange(period.getFrom(), period.getTo())); } } }
Example #30
Source File: GanttProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Add a single exception to a calendar. * * @param mpxjCalendar MPXJ calendar * @param date calendar exception */ private void addException(ProjectCalendar mpxjCalendar, net.sf.mpxj.ganttproject.schema.Date date) { String year = date.getYear(); if (year == null || year.isEmpty()) { // In order to process recurring exceptions using MPXJ, we need a start and end date // to constrain the number of dates we generate. // May need to pre-process the tasks in order to calculate a start and finish date. // TODO: handle recurring exceptions } else { Calendar calendar = DateHelper.popCalendar(); calendar.set(Calendar.YEAR, Integer.parseInt(year)); calendar.set(Calendar.MONTH, NumberHelper.getInt(date.getMonth())); calendar.set(Calendar.DAY_OF_MONTH, NumberHelper.getInt(date.getDate())); Date exceptionDate = calendar.getTime(); DateHelper.pushCalendar(calendar); ProjectCalendarException exception = mpxjCalendar.addCalendarException(exceptionDate, exceptionDate); // TODO: not sure how NEUTRAL should be handled if ("WORKING_DAY".equals(date.getType())) { exception.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING); exception.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON); } } }