idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
143,800 | private void processPredecessors ( Gantt gantt ) { for ( Gantt . Tasks . Task ganttTask : gantt . getTasks ( ) . getTask ( ) ) { String predecessors = ganttTask . getP ( ) ; if ( predecessors != null && ! predecessors . isEmpty ( ) ) { String wbs = ganttTask . getID ( ) ; Task task = m_taskMap . get ( wbs ) ; for ( String predecessor : predecessors . split ( ";" ) ) { Task predecessorTask = m_projectFile . getTaskByID ( Integer . valueOf ( predecessor ) ) ; task . addPredecessor ( predecessorTask , RelationType . FINISH_START , ganttTask . getL ( ) ) ; } } } } | Read predecessors from a Gantt Designer file . | 174 | 10 |
143,801 | private void processRemarks ( Gantt gantt ) { processRemarks ( gantt . getRemarks ( ) ) ; processRemarks ( gantt . getRemarks1 ( ) ) ; processRemarks ( gantt . getRemarks2 ( ) ) ; processRemarks ( gantt . getRemarks3 ( ) ) ; processRemarks ( gantt . getRemarks4 ( ) ) ; } | Read remarks from a Gantt Designer file . | 94 | 10 |
143,802 | private void processRemarks ( GanttDesignerRemark remark ) { for ( GanttDesignerRemark . Task remarkTask : remark . getTask ( ) ) { Integer id = remarkTask . getRow ( ) ; Task task = m_projectFile . getTaskByID ( id ) ; String notes = task . getNotes ( ) ; if ( notes . isEmpty ( ) ) { notes = remarkTask . getContent ( ) ; } else { notes = notes + ' ' + remarkTask . getContent ( ) ; } task . setNotes ( notes ) ; } } | Read an individual remark type from a Gantt Designer file . | 124 | 13 |
143,803 | private String getParentWBS ( String wbs ) { String result ; int index = wbs . lastIndexOf ( ' ' ) ; if ( index == - 1 ) { result = null ; } else { result = wbs . substring ( 0 , index ) ; } return result ; } | Extract the parent WBS from a WBS . | 62 | 11 |
143,804 | private ChildTaskContainer getParentTask ( String wbs ) { ChildTaskContainer result ; String parentWbs = getParentWBS ( wbs ) ; if ( parentWbs == null ) { result = m_projectFile ; } else { result = m_taskMap . get ( parentWbs ) ; } return result ; } | Retrieve the parent task based on its WBS . | 70 | 11 |
143,805 | private List < Entry > getChildNodes ( DirectoryEntry parent ) { List < Entry > result = new ArrayList < Entry > ( ) ; Iterator < Entry > entries = parent . getEntries ( ) ; while ( entries . hasNext ( ) ) { result . add ( entries . next ( ) ) ; } return result ; } | Retrieves child nodes from a directory entry . | 71 | 10 |
143,806 | private void fireTreeStructureChanged ( ) { // Guaranteed to return a non-null array Object [ ] listeners = m_listenerList . getListenerList ( ) ; TreeModelEvent e = null ; // Process the listeners last to first, notifying // those that are interested in this event for ( int i = listeners . length - 2 ; i >= 0 ; i -= 2 ) { if ( listeners [ i ] == TreeModelListener . class ) { // Lazily create the event: if ( e == null ) { e = new TreeModelEvent ( getRoot ( ) , new Object [ ] { getRoot ( ) } , null , null ) ; } ( ( TreeModelListener ) listeners [ i + 1 ] ) . treeStructureChanged ( e ) ; } } } | Notify listeners that the tree structure has changed . | 164 | 10 |
143,807 | public int getMinutesPerDay ( ) { return m_minutesPerDay == null ? NumberHelper . getInt ( getParentFile ( ) . getProjectProperties ( ) . getMinutesPerDay ( ) ) : m_minutesPerDay . intValue ( ) ; } | Retrieve the number of minutes per day for this calendar . | 61 | 12 |
143,808 | public int getMinutesPerWeek ( ) { return m_minutesPerWeek == null ? NumberHelper . getInt ( getParentFile ( ) . getProjectProperties ( ) . getMinutesPerWeek ( ) ) : m_minutesPerWeek . intValue ( ) ; } | Retrieve the number of minutes per week for this calendar . | 61 | 12 |
143,809 | public int getMinutesPerMonth ( ) { return m_minutesPerMonth == null ? NumberHelper . getInt ( getParentFile ( ) . getProjectProperties ( ) . getMinutesPerMonth ( ) ) : m_minutesPerMonth . intValue ( ) ; } | Retrieve the number of minutes per month for this calendar . | 61 | 12 |
143,810 | public int getMinutesPerYear ( ) { return m_minutesPerYear == null ? NumberHelper . getInt ( getParentFile ( ) . getProjectProperties ( ) . getMinutesPerYear ( ) ) : m_minutesPerYear . intValue ( ) ; } | Retrieve the number of minutes per year for this calendar . | 61 | 12 |
143,811 | public ProjectCalendarWeek addWorkWeek ( ) { ProjectCalendarWeek week = new ProjectCalendarWeek ( ) ; week . setParent ( this ) ; m_workWeeks . add ( week ) ; m_weeksSorted = false ; clearWorkingDateCache ( ) ; return week ; } | Add an empty work week . | 64 | 6 |
143,812 | public ProjectCalendarException addCalendarException ( Date fromDate , Date toDate ) { ProjectCalendarException bce = new ProjectCalendarException ( fromDate , toDate ) ; m_exceptions . add ( bce ) ; m_expandedExceptions . clear ( ) ; m_exceptionsSorted = false ; clearWorkingDateCache ( ) ; return bce ; } | Used to add exceptions to the calendar . The MPX standard defines a limit of 250 exceptions per calendar . | 82 | 21 |
143,813 | public void setParent ( ProjectCalendar calendar ) { // I've seen a malformed MSPDI file which sets the parent calendar to itself. // Silently ignore this here. if ( calendar != this ) { if ( getParent ( ) != null ) { getParent ( ) . removeDerivedCalendar ( this ) ; } super . setParent ( calendar ) ; if ( calendar != null ) { calendar . addDerivedCalendar ( this ) ; } clearWorkingDateCache ( ) ; } } | Sets the ProjectCalendar instance from which this calendar is derived . | 105 | 14 |
143,814 | public boolean isWorkingDay ( Day day ) { DayType value = getWorkingDay ( day ) ; boolean result ; if ( value == DayType . DEFAULT ) { ProjectCalendar cal = getParent ( ) ; if ( cal != null ) { result = cal . isWorkingDay ( day ) ; } else { result = ( day != Day . SATURDAY && day != Day . SUNDAY ) ; } } else { result = ( value == DayType . WORKING ) ; } return ( result ) ; } | Method indicating whether a day is a working or non - working day . | 108 | 14 |
143,815 | public Duration getDuration ( Date startDate , Date endDate ) { Calendar cal = DateHelper . popCalendar ( startDate ) ; int days = getDaysInRange ( startDate , endDate ) ; int duration = 0 ; Day day = Day . getInstance ( cal . get ( Calendar . DAY_OF_WEEK ) ) ; while ( days > 0 ) { if ( isWorkingDate ( cal . getTime ( ) , day ) == true ) { ++ duration ; } -- days ; day = day . getNextDay ( ) ; cal . set ( Calendar . DAY_OF_YEAR , cal . get ( Calendar . DAY_OF_YEAR ) + 1 ) ; } DateHelper . pushCalendar ( cal ) ; return ( Duration . getInstance ( duration , TimeUnit . DAYS ) ) ; } | This method is provided to allow an absolute period of time represented by start and end dates into a duration in working days based on this calendar instance . This method takes account of any exceptions defined for this calendar . | 173 | 41 |
143,816 | public Date getStartTime ( Date date ) { Date result = m_startTimeCache . get ( date ) ; if ( result == null ) { ProjectCalendarDateRanges ranges = getRanges ( date , null , null ) ; if ( ranges == null ) { result = getParentFile ( ) . getProjectProperties ( ) . getDefaultStartTime ( ) ; } else { result = ranges . getRange ( 0 ) . getStart ( ) ; } result = DateHelper . getCanonicalTime ( result ) ; m_startTimeCache . put ( new Date ( date . getTime ( ) ) , result ) ; } return result ; } | Retrieves the time at which work starts on the given date or returns null if this is a non - working day . | 139 | 25 |
143,817 | public Date getFinishTime ( Date date ) { Date result = null ; if ( date != null ) { ProjectCalendarDateRanges ranges = getRanges ( date , null , null ) ; if ( ranges == null ) { result = getParentFile ( ) . getProjectProperties ( ) . getDefaultEndTime ( ) ; result = DateHelper . getCanonicalTime ( result ) ; } else { Date rangeStart = result = ranges . getRange ( 0 ) . getStart ( ) ; Date rangeFinish = ranges . getRange ( ranges . getRangeCount ( ) - 1 ) . getEnd ( ) ; Date startDay = DateHelper . getDayStartDate ( rangeStart ) ; Date finishDay = DateHelper . getDayStartDate ( rangeFinish ) ; result = DateHelper . getCanonicalTime ( rangeFinish ) ; // // Handle the case where the end of the range is at midnight - // this will show up as the start and end days not matching // if ( startDay != null && finishDay != null && startDay . getTime ( ) != finishDay . getTime ( ) ) { result = DateHelper . addDays ( result , 1 ) ; } } } return result ; } | Retrieves the time at which work finishes on the given date or returns null if this is a non - working day . | 256 | 25 |
143,818 | private void updateToNextWorkStart ( Calendar cal ) { Date originalDate = cal . getTime ( ) ; // // Find the date ranges for the current day // ProjectCalendarDateRanges ranges = getRanges ( originalDate , cal , null ) ; if ( ranges != null ) { // // Do we have a start time today? // Date calTime = DateHelper . getCanonicalTime ( cal . getTime ( ) ) ; Date startTime = null ; for ( DateRange range : ranges ) { Date rangeStart = DateHelper . getCanonicalTime ( range . getStart ( ) ) ; Date rangeEnd = DateHelper . getCanonicalTime ( range . getEnd ( ) ) ; Date rangeStartDay = DateHelper . getDayStartDate ( range . getStart ( ) ) ; Date rangeEndDay = DateHelper . getDayStartDate ( range . getEnd ( ) ) ; if ( rangeStartDay . getTime ( ) != rangeEndDay . getTime ( ) ) { rangeEnd = DateHelper . addDays ( rangeEnd , 1 ) ; } if ( calTime . getTime ( ) < rangeEnd . getTime ( ) ) { if ( calTime . getTime ( ) > rangeStart . getTime ( ) ) { startTime = calTime ; } else { startTime = rangeStart ; } break ; } } // // If we don't have a start time today - find the next working day // then retrieve the start time. // if ( startTime == null ) { Day day ; int nonWorkingDayCount = 0 ; do { cal . set ( Calendar . DAY_OF_YEAR , cal . get ( Calendar . DAY_OF_YEAR ) + 1 ) ; day = Day . getInstance ( cal . get ( Calendar . DAY_OF_WEEK ) ) ; ++ nonWorkingDayCount ; if ( nonWorkingDayCount > MAX_NONWORKING_DAYS ) { cal . setTime ( originalDate ) ; break ; } } while ( ! isWorkingDate ( cal . getTime ( ) , day ) ) ; startTime = getStartTime ( cal . getTime ( ) ) ; } DateHelper . setTime ( cal , startTime ) ; } } | This method finds the start of the next working period . | 470 | 11 |
143,819 | public Date getNextWorkStart ( Date date ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; updateToNextWorkStart ( cal ) ; return cal . getTime ( ) ; } | Utility method to retrieve the next working date start time given a date and time as a starting point . | 47 | 21 |
143,820 | public Date getPreviousWorkFinish ( Date date ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; updateToPreviousWorkFinish ( cal ) ; return cal . getTime ( ) ; } | Utility method to retrieve the previous working date finish time given a date and time as a starting point . | 47 | 21 |
143,821 | public boolean isWorkingDate ( Date date ) { Calendar cal = DateHelper . popCalendar ( date ) ; Day day = Day . getInstance ( cal . get ( Calendar . DAY_OF_WEEK ) ) ; DateHelper . pushCalendar ( cal ) ; return isWorkingDate ( date , day ) ; } | This method allows the caller to determine if a given date is a working day . This method takes account of calendar exceptions . | 67 | 24 |
143,822 | private boolean isWorkingDate ( Date date , Day day ) { ProjectCalendarDateRanges ranges = getRanges ( date , null , day ) ; return ranges . getRangeCount ( ) != 0 ; } | This private method allows the caller to determine if a given date is a working day . This method takes account of calendar exceptions . It assumes that the caller has already calculated the day of the week on which the given day falls . | 44 | 45 |
143,823 | private int getDaysInRange ( Date startDate , Date endDate ) { int result ; Calendar cal = DateHelper . popCalendar ( endDate ) ; int endDateYear = cal . get ( Calendar . YEAR ) ; int endDateDayOfYear = cal . get ( Calendar . DAY_OF_YEAR ) ; cal . setTime ( startDate ) ; if ( endDateYear == cal . get ( Calendar . YEAR ) ) { result = ( endDateDayOfYear - cal . get ( Calendar . DAY_OF_YEAR ) ) + 1 ; } else { result = 0 ; do { result += ( cal . getActualMaximum ( Calendar . DAY_OF_YEAR ) - cal . get ( Calendar . DAY_OF_YEAR ) ) + 1 ; cal . roll ( Calendar . YEAR , 1 ) ; cal . set ( Calendar . DAY_OF_YEAR , 1 ) ; } while ( cal . get ( Calendar . YEAR ) < endDateYear ) ; result += endDateDayOfYear ; } DateHelper . pushCalendar ( cal ) ; return result ; } | This method calculates the absolute number of days between two dates . Note that where two date objects are provided that fall on the same day this method will return one not zero . Note also that this method assumes that the dates are passed in the correct order i . e . startDate < endDate . | 232 | 59 |
143,824 | @ Override public void setUniqueID ( Integer uniqueID ) { ProjectFile parent = getParentFile ( ) ; if ( m_uniqueID != null ) { parent . getCalendars ( ) . unmapUniqueID ( m_uniqueID ) ; } parent . getCalendars ( ) . mapUniqueID ( uniqueID , this ) ; m_uniqueID = uniqueID ; } | Modifier method to set the unique ID of this calendar . | 81 | 12 |
143,825 | public void setResource ( Resource resource ) { m_resource = resource ; String name = m_resource . getName ( ) ; if ( name == null || name . length ( ) == 0 ) { name = "Unnamed Resource" ; } setName ( name ) ; } | Sets the resource to which this calendar is linked . Note that this method updates the calendar s name to be the same as the resource name . If the resource does not yet have a name then the calendar is given a default name . | 58 | 47 |
143,826 | public ProjectCalendarException getException ( Date date ) { ProjectCalendarException exception = null ; // We're working with expanded exceptions, which includes any recurring exceptions // expanded into individual entries. populateExpandedExceptions ( ) ; if ( ! m_expandedExceptions . isEmpty ( ) ) { sortExceptions ( ) ; int low = 0 ; int high = m_expandedExceptions . size ( ) - 1 ; long targetDate = date . getTime ( ) ; while ( low <= high ) { int mid = ( low + high ) >>> 1 ; ProjectCalendarException midVal = m_expandedExceptions . get ( mid ) ; int cmp = 0 - DateHelper . compare ( midVal . getFromDate ( ) , midVal . getToDate ( ) , targetDate ) ; if ( cmp < 0 ) { low = mid + 1 ; } else { if ( cmp > 0 ) { high = mid - 1 ; } else { exception = midVal ; break ; } } } } if ( exception == null && getParent ( ) != null ) { // Check base calendar as well for an exception. exception = getParent ( ) . getException ( date ) ; } return ( exception ) ; } | Retrieve a calendar exception which applies to this date . | 260 | 11 |
143,827 | public ProjectCalendarWeek getWorkWeek ( Date date ) { ProjectCalendarWeek week = null ; if ( ! m_workWeeks . isEmpty ( ) ) { sortWorkWeeks ( ) ; int low = 0 ; int high = m_workWeeks . size ( ) - 1 ; long targetDate = date . getTime ( ) ; while ( low <= high ) { int mid = ( low + high ) >>> 1 ; ProjectCalendarWeek midVal = m_workWeeks . get ( mid ) ; int cmp = 0 - DateHelper . compare ( midVal . getDateRange ( ) . getStart ( ) , midVal . getDateRange ( ) . getEnd ( ) , targetDate ) ; if ( cmp < 0 ) { low = mid + 1 ; } else { if ( cmp > 0 ) { high = mid - 1 ; } else { week = midVal ; break ; } } } } if ( week == null && getParent ( ) != null ) { // Check base calendar as well for a work week. week = getParent ( ) . getWorkWeek ( date ) ; } return ( week ) ; } | Retrieve a work week which applies to this date . | 244 | 11 |
143,828 | public Duration getWork ( Date date , TimeUnit format ) { ProjectCalendarDateRanges ranges = getRanges ( date , null , null ) ; long time = getTotalTime ( ranges ) ; return convertFormat ( time , format ) ; } | Retrieves the amount of work on a given day and returns it in the specified format . | 52 | 19 |
143,829 | public Duration getWork ( Date startDate , Date endDate , TimeUnit format ) { DateRange range = new DateRange ( startDate , endDate ) ; Long cachedResult = m_workingDateCache . get ( range ) ; long totalTime = 0 ; if ( cachedResult == null ) { // // We want the start date to be the earliest date, and the end date // to be the latest date. Set a flag here to indicate if we have swapped // the order of the supplied date. // boolean invert = false ; if ( startDate . getTime ( ) > endDate . getTime ( ) ) { invert = true ; Date temp = startDate ; startDate = endDate ; endDate = temp ; } Date canonicalStartDate = DateHelper . getDayStartDate ( startDate ) ; Date canonicalEndDate = DateHelper . getDayStartDate ( endDate ) ; if ( canonicalStartDate . getTime ( ) == canonicalEndDate . getTime ( ) ) { ProjectCalendarDateRanges ranges = getRanges ( startDate , null , null ) ; if ( ranges . getRangeCount ( ) != 0 ) { totalTime = getTotalTime ( ranges , startDate , endDate ) ; } } else { // // Find the first working day in the range // Date currentDate = startDate ; Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( startDate ) ; Day day = Day . getInstance ( cal . get ( Calendar . DAY_OF_WEEK ) ) ; while ( isWorkingDate ( currentDate , day ) == false && currentDate . getTime ( ) < canonicalEndDate . getTime ( ) ) { cal . add ( Calendar . DAY_OF_YEAR , 1 ) ; currentDate = cal . getTime ( ) ; day = day . getNextDay ( ) ; } if ( currentDate . getTime ( ) < canonicalEndDate . getTime ( ) ) { // // Calculate the amount of working time for this day // totalTime += getTotalTime ( getRanges ( currentDate , null , day ) , currentDate , true ) ; // // Process each working day until we reach the last day // while ( true ) { cal . add ( Calendar . DAY_OF_YEAR , 1 ) ; currentDate = cal . getTime ( ) ; day = day . getNextDay ( ) ; // // We have reached the last day // if ( currentDate . getTime ( ) >= canonicalEndDate . getTime ( ) ) { break ; } // // Skip this day if it has no working time // ProjectCalendarDateRanges ranges = getRanges ( currentDate , null , day ) ; if ( ranges . getRangeCount ( ) == 0 ) { continue ; } // // Add the working time for the whole day // totalTime += getTotalTime ( ranges ) ; } } // // We are now at the last day // ProjectCalendarDateRanges ranges = getRanges ( endDate , null , day ) ; if ( ranges . getRangeCount ( ) != 0 ) { totalTime += getTotalTime ( ranges , DateHelper . getDayStartDate ( endDate ) , endDate ) ; } } if ( invert ) { totalTime = - totalTime ; } m_workingDateCache . put ( range , Long . valueOf ( totalTime ) ) ; } else { totalTime = cachedResult . longValue ( ) ; } return convertFormat ( totalTime , format ) ; } | This method retrieves a Duration instance representing the amount of work between two dates based on this calendar . | 735 | 20 |
143,830 | private Duration convertFormat ( long totalTime , TimeUnit format ) { double duration = totalTime ; switch ( format ) { case MINUTES : case ELAPSED_MINUTES : { duration /= ( 60 * 1000 ) ; break ; } case HOURS : case ELAPSED_HOURS : { duration /= ( 60 * 60 * 1000 ) ; break ; } case DAYS : { double minutesPerDay = getMinutesPerDay ( ) ; if ( minutesPerDay != 0 ) { duration /= ( minutesPerDay * 60 * 1000 ) ; } else { duration = 0 ; } break ; } case WEEKS : { double minutesPerWeek = getMinutesPerWeek ( ) ; if ( minutesPerWeek != 0 ) { duration /= ( minutesPerWeek * 60 * 1000 ) ; } else { duration = 0 ; } break ; } case MONTHS : { double daysPerMonth = getParentFile ( ) . getProjectProperties ( ) . getDaysPerMonth ( ) . doubleValue ( ) ; double minutesPerDay = getMinutesPerDay ( ) ; if ( daysPerMonth != 0 && minutesPerDay != 0 ) { duration /= ( daysPerMonth * minutesPerDay * 60 * 1000 ) ; } else { duration = 0 ; } break ; } case ELAPSED_DAYS : { duration /= ( 24 * 60 * 60 * 1000 ) ; break ; } case ELAPSED_WEEKS : { duration /= ( 7 * 24 * 60 * 60 * 1000 ) ; break ; } case ELAPSED_MONTHS : { duration /= ( 30 * 24 * 60 * 60 * 1000 ) ; break ; } default : { throw new IllegalArgumentException ( "TimeUnit " + format + " not supported" ) ; } } return ( Duration . getInstance ( duration , format ) ) ; } | Utility method used to convert an integer time representation into a Duration instance . | 394 | 15 |
143,831 | private long getTotalTime ( ProjectCalendarDateRanges exception , Date date , boolean after ) { long currentTime = DateHelper . getCanonicalTime ( date ) . getTime ( ) ; long total = 0 ; for ( DateRange range : exception ) { total += getTime ( range . getStart ( ) , range . getEnd ( ) , currentTime , after ) ; } return ( total ) ; } | Retrieves the amount of time represented by a calendar exception before or after an intersection point . | 88 | 19 |
143,832 | private long getTotalTime ( ProjectCalendarDateRanges exception ) { long total = 0 ; for ( DateRange range : exception ) { total += getTime ( range . getStart ( ) , range . getEnd ( ) ) ; } return ( total ) ; } | Retrieves the amount of working time represented by a calendar exception . | 56 | 14 |
143,833 | private long getTotalTime ( ProjectCalendarDateRanges hours , Date startDate , Date endDate ) { long total = 0 ; if ( startDate . getTime ( ) != endDate . getTime ( ) ) { Date start = DateHelper . getCanonicalTime ( startDate ) ; Date end = DateHelper . getCanonicalTime ( endDate ) ; for ( DateRange range : hours ) { Date rangeStart = range . getStart ( ) ; Date rangeEnd = range . getEnd ( ) ; if ( rangeStart != null && rangeEnd != null ) { Date canoncialRangeStart = DateHelper . getCanonicalTime ( rangeStart ) ; Date canonicalRangeEnd = DateHelper . getCanonicalTime ( rangeEnd ) ; Date startDay = DateHelper . getDayStartDate ( rangeStart ) ; Date finishDay = DateHelper . getDayStartDate ( rangeEnd ) ; // // Handle the case where the end of the range is at midnight - // this will show up as the start and end days not matching // if ( startDay . getTime ( ) != finishDay . getTime ( ) ) { canonicalRangeEnd = DateHelper . addDays ( canonicalRangeEnd , 1 ) ; } if ( canoncialRangeStart . getTime ( ) == canonicalRangeEnd . getTime ( ) && rangeEnd . getTime ( ) > rangeStart . getTime ( ) ) { total += ( 24 * 60 * 60 * 1000 ) ; } else { total += getTime ( start , end , canoncialRangeStart , canonicalRangeEnd ) ; } } } } return ( total ) ; } | This method calculates the total amount of working time in a single day which intersects with the supplied time range . | 340 | 22 |
143,834 | private long getTime ( Date start , Date end , long target , boolean after ) { long total = 0 ; if ( start != null && end != null ) { Date startTime = DateHelper . getCanonicalTime ( start ) ; Date endTime = DateHelper . getCanonicalTime ( end ) ; Date startDay = DateHelper . getDayStartDate ( start ) ; Date finishDay = DateHelper . getDayStartDate ( end ) ; // // Handle the case where the end of the range is at midnight - // this will show up as the start and end days not matching // if ( startDay . getTime ( ) != finishDay . getTime ( ) ) { endTime = DateHelper . addDays ( endTime , 1 ) ; } int diff = DateHelper . compare ( startTime , endTime , target ) ; if ( diff == 0 ) { if ( after == true ) { total = ( endTime . getTime ( ) - target ) ; } else { total = ( target - startTime . getTime ( ) ) ; } } else { if ( ( after == true && diff < 0 ) || ( after == false && diff > 0 ) ) { total = ( endTime . getTime ( ) - startTime . getTime ( ) ) ; } } } return ( total ) ; } | Calculates how much of a time range is before or after a target intersection point . | 278 | 18 |
143,835 | private long getTime ( Date start , Date end ) { long total = 0 ; if ( start != null && end != null ) { Date startTime = DateHelper . getCanonicalTime ( start ) ; Date endTime = DateHelper . getCanonicalTime ( end ) ; Date startDay = DateHelper . getDayStartDate ( start ) ; Date finishDay = DateHelper . getDayStartDate ( end ) ; // // Handle the case where the end of the range is at midnight - // this will show up as the start and end days not matching // if ( startDay . getTime ( ) != finishDay . getTime ( ) ) { endTime = DateHelper . addDays ( endTime , 1 ) ; } total = ( endTime . getTime ( ) - startTime . getTime ( ) ) ; } return ( total ) ; } | Retrieves the amount of time between two date time values . Note that these values are converted into canonical values to remove the date component . | 181 | 28 |
143,836 | private long getTime ( Date start1 , Date end1 , Date start2 , Date end2 ) { long total = 0 ; if ( start1 != null && end1 != null && start2 != null && end2 != null ) { long start ; long end ; if ( start1 . getTime ( ) < start2 . getTime ( ) ) { start = start2 . getTime ( ) ; } else { start = start1 . getTime ( ) ; } if ( end1 . getTime ( ) < end2 . getTime ( ) ) { end = end1 . getTime ( ) ; } else { end = end2 . getTime ( ) ; } if ( start < end ) { total = end - start ; } } return ( total ) ; } | This method returns the length of overlapping time between two time ranges . | 163 | 13 |
143,837 | public void copy ( ProjectCalendar cal ) { setName ( cal . getName ( ) ) ; setParent ( cal . getParent ( ) ) ; System . arraycopy ( cal . getDays ( ) , 0 , getDays ( ) , 0 , getDays ( ) . length ) ; for ( ProjectCalendarException ex : cal . m_exceptions ) { addCalendarException ( ex . getFromDate ( ) , ex . getToDate ( ) ) ; for ( DateRange range : ex ) { ex . addRange ( new DateRange ( range . getStart ( ) , range . getEnd ( ) ) ) ; } } for ( ProjectCalendarHours hours : getHours ( ) ) { if ( hours != null ) { ProjectCalendarHours copyHours = cal . addCalendarHours ( hours . getDay ( ) ) ; for ( DateRange range : hours ) { copyHours . addRange ( new DateRange ( range . getStart ( ) , range . getEnd ( ) ) ) ; } } } } | Copy the settings from another calendar to this calendar . | 217 | 10 |
143,838 | private void clearWorkingDateCache ( ) { m_workingDateCache . clear ( ) ; m_startTimeCache . clear ( ) ; m_getDateLastResult = null ; for ( ProjectCalendar calendar : m_derivedCalendars ) { calendar . clearWorkingDateCache ( ) ; } } | Utility method to clear cached calendar data . | 63 | 9 |
143,839 | private ProjectCalendarDateRanges getRanges ( Date date , Calendar cal , Day day ) { ProjectCalendarDateRanges ranges = getException ( date ) ; if ( ranges == null ) { ProjectCalendarWeek week = getWorkWeek ( date ) ; if ( week == null ) { week = this ; } if ( day == null ) { if ( cal == null ) { cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; } day = Day . getInstance ( cal . get ( Calendar . DAY_OF_WEEK ) ) ; } ranges = week . getHours ( day ) ; } return ranges ; } | Retrieves the working hours on the given date . | 137 | 11 |
143,840 | private void populateExpandedExceptions ( ) { if ( ! m_exceptions . isEmpty ( ) && m_expandedExceptions . isEmpty ( ) ) { for ( ProjectCalendarException exception : m_exceptions ) { RecurringData recurring = exception . getRecurring ( ) ; if ( recurring == null ) { m_expandedExceptions . add ( exception ) ; } else { for ( Date date : recurring . getDates ( ) ) { Date startDate = DateHelper . getDayStartDate ( date ) ; Date endDate = DateHelper . getDayEndDate ( date ) ; ProjectCalendarException newException = new ProjectCalendarException ( startDate , endDate ) ; int rangeCount = exception . getRangeCount ( ) ; for ( int rangeIndex = 0 ; rangeIndex < rangeCount ; rangeIndex ++ ) { newException . addRange ( exception . getRange ( rangeIndex ) ) ; } m_expandedExceptions . add ( newException ) ; } } } Collections . sort ( m_expandedExceptions ) ; } } | Populate the expanded exceptions list based on the main exceptions list . Where we find recurring exception definitions we generate individual exceptions for each recurrence to ensure that we account for them correctly . | 227 | 36 |
143,841 | private Map < String , Table > getIndex ( Table table ) { Map < String , Table > result ; if ( ! table . getResourceFlag ( ) ) { result = m_taskTablesByName ; } else { result = m_resourceTablesByName ; } return result ; } | Retrieve the correct index for the supplied Table instance . | 62 | 11 |
143,842 | public void saveFile ( File file , String type ) { if ( file != null ) { m_treeController . saveFile ( file , type ) ; } } | Saves the project file displayed in this panel . | 34 | 10 |
143,843 | public void addFilter ( Filter filter ) { if ( filter . isTaskFilter ( ) ) { m_taskFilters . add ( filter ) ; } if ( filter . isResourceFilter ( ) ) { m_resourceFilters . add ( filter ) ; } m_filtersByName . put ( filter . getName ( ) , filter ) ; m_filtersByID . put ( filter . getID ( ) , filter ) ; } | Adds a filter definition to this project file . | 94 | 9 |
143,844 | public void removeFilter ( String filterName ) { Filter filter = getFilterByName ( filterName ) ; if ( filter != null ) { if ( filter . isTaskFilter ( ) ) { m_taskFilters . remove ( filter ) ; } if ( filter . isResourceFilter ( ) ) { m_resourceFilters . remove ( filter ) ; } m_filtersByName . remove ( filterName ) ; m_filtersByID . remove ( filter . getID ( ) ) ; } } | Removes a filter from this project file . | 107 | 9 |
143,845 | private void writeProjectProperties ( ) { ProjectProperties properties = m_projectFile . getProjectProperties ( ) ; m_plannerProject . setCompany ( properties . getCompany ( ) ) ; m_plannerProject . setManager ( properties . getManager ( ) ) ; m_plannerProject . setName ( getString ( properties . getName ( ) ) ) ; m_plannerProject . setProjectStart ( getDateTime ( properties . getStartDate ( ) ) ) ; m_plannerProject . setCalendar ( getIntegerString ( m_projectFile . getDefaultCalendar ( ) . getUniqueID ( ) ) ) ; m_plannerProject . setMrprojectVersion ( "2" ) ; } | This method writes project properties to a Planner file . | 156 | 11 |
143,846 | 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 ) ; } } | This method writes calendar data to a Planner file . | 171 | 11 |
143,847 | private void writeDayTypes ( Calendars calendars ) { DayTypes dayTypes = m_factory . createDayTypes ( ) ; calendars . setDayTypes ( dayTypes ) ; List < DayType > typeList = dayTypes . getDayType ( ) ; DayType dayType = m_factory . createDayType ( ) ; typeList . add ( dayType ) ; dayType . setId ( "0" ) ; dayType . setName ( "Working" ) ; dayType . setDescription ( "A default working day" ) ; dayType = m_factory . createDayType ( ) ; typeList . add ( dayType ) ; dayType . setId ( "1" ) ; dayType . setName ( "Nonworking" ) ; dayType . setDescription ( "A default non working day" ) ; dayType = m_factory . createDayType ( ) ; typeList . add ( dayType ) ; dayType . setId ( "2" ) ; dayType . setName ( "Use base" ) ; dayType . setDescription ( "Use day from base calendar" ) ; } | Write the standard set of day types . | 238 | 8 |
143,848 | private void writeCalendar ( ProjectCalendar mpxjCalendar , net . sf . mpxj . planner . schema . Calendar plannerCalendar ) throws JAXBException { // // Populate basic details // plannerCalendar . setId ( getIntegerString ( mpxjCalendar . getUniqueID ( ) ) ) ; plannerCalendar . setName ( getString ( mpxjCalendar . getName ( ) ) ) ; // // Set working and non working days // DefaultWeek dw = m_factory . createDefaultWeek ( ) ; plannerCalendar . setDefaultWeek ( dw ) ; dw . setMon ( getWorkingDayString ( mpxjCalendar , Day . MONDAY ) ) ; dw . setTue ( getWorkingDayString ( mpxjCalendar , Day . TUESDAY ) ) ; dw . setWed ( getWorkingDayString ( mpxjCalendar , Day . WEDNESDAY ) ) ; dw . setThu ( getWorkingDayString ( mpxjCalendar , Day . THURSDAY ) ) ; dw . setFri ( getWorkingDayString ( mpxjCalendar , Day . FRIDAY ) ) ; dw . setSat ( getWorkingDayString ( mpxjCalendar , Day . SATURDAY ) ) ; dw . setSun ( getWorkingDayString ( mpxjCalendar , Day . SUNDAY ) ) ; // // Set working hours // OverriddenDayTypes odt = m_factory . createOverriddenDayTypes ( ) ; plannerCalendar . setOverriddenDayTypes ( odt ) ; List < OverriddenDayType > typeList = odt . getOverriddenDayType ( ) ; Sequence uniqueID = new Sequence ( 0 ) ; // // This is a bit arbitrary, so not ideal, however... // The idea here is that MS Project allows us to specify working hours // for each day of the week individually. Planner doesn't do this, // but instead allows us to specify working hours for each day type. // What we are doing here is stepping through the days of the week to // find the first working day, then using the hours for that day // as the hours for the working day type in Planner. // for ( int dayLoop = 1 ; dayLoop < 8 ; dayLoop ++ ) { Day day = Day . getInstance ( dayLoop ) ; if ( mpxjCalendar . isWorkingDay ( day ) ) { processWorkingHours ( mpxjCalendar , uniqueID , day , typeList ) ; break ; } } // // Process exception days // Days plannerDays = m_factory . createDays ( ) ; plannerCalendar . setDays ( plannerDays ) ; List < net . sf . mpxj . planner . schema . Day > dayList = plannerDays . getDay ( ) ; processExceptionDays ( mpxjCalendar , dayList ) ; m_eventManager . fireCalendarWrittenEvent ( mpxjCalendar ) ; // // Process any derived calendars // List < net . sf . mpxj . planner . schema . Calendar > calendarList = plannerCalendar . getCalendar ( ) ; for ( ProjectCalendar mpxjDerivedCalendar : mpxjCalendar . getDerivedCalendars ( ) ) { net . sf . mpxj . planner . schema . Calendar plannerDerivedCalendar = m_factory . createCalendar ( ) ; calendarList . add ( plannerDerivedCalendar ) ; writeCalendar ( mpxjDerivedCalendar , plannerDerivedCalendar ) ; } } | This method writes data for a single calendar to a Planner file . | 759 | 14 |
143,849 | 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 ) ) ; } } } } } | Process the standard working hours for a given day . | 259 | 10 |
143,850 | private void writeResources ( ) { Resources resources = m_factory . createResources ( ) ; m_plannerProject . setResources ( resources ) ; List < net . sf . mpxj . planner . schema . Resource > resourceList = resources . getResource ( ) ; for ( Resource mpxjResource : m_projectFile . getResources ( ) ) { net . sf . mpxj . planner . schema . Resource plannerResource = m_factory . createResource ( ) ; resourceList . add ( plannerResource ) ; writeResource ( mpxjResource , plannerResource ) ; } } | This method writes resource data to a Planner file . | 128 | 11 |
143,851 | 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 ) ; } | This method writes data for a single resource to a Planner file . | 269 | 14 |
143,852 | private void writeTasks ( ) throws JAXBException { Tasks tasks = m_factory . createTasks ( ) ; m_plannerProject . setTasks ( tasks ) ; List < net . sf . mpxj . planner . schema . Task > taskList = tasks . getTask ( ) ; for ( Task task : m_projectFile . getChildTasks ( ) ) { writeTask ( task , taskList ) ; } } | This method writes task data to a Planner file . | 97 | 11 |
143,853 | private void writeTask ( Task mpxjTask , List < net . sf . mpxj . planner . schema . Task > taskList ) throws JAXBException { net . sf . mpxj . planner . schema . Task plannerTask = m_factory . createTask ( ) ; taskList . add ( plannerTask ) ; plannerTask . setEnd ( getDateTimeString ( mpxjTask . getFinish ( ) ) ) ; plannerTask . setId ( getIntegerString ( mpxjTask . getUniqueID ( ) ) ) ; plannerTask . setName ( getString ( mpxjTask . getName ( ) ) ) ; plannerTask . setNote ( mpxjTask . getNotes ( ) ) ; plannerTask . setPercentComplete ( getIntegerString ( mpxjTask . getPercentageWorkComplete ( ) ) ) ; plannerTask . setPriority ( mpxjTask . getPriority ( ) == null ? null : getIntegerString ( mpxjTask . getPriority ( ) . getValue ( ) * 10 ) ) ; plannerTask . setScheduling ( getScheduling ( mpxjTask . getType ( ) ) ) ; plannerTask . setStart ( getDateTimeString ( DateHelper . getDayStartDate ( mpxjTask . getStart ( ) ) ) ) ; if ( mpxjTask . getMilestone ( ) ) { plannerTask . setType ( "milestone" ) ; } else { plannerTask . setType ( "normal" ) ; } plannerTask . setWork ( getDurationString ( mpxjTask . getWork ( ) ) ) ; plannerTask . setWorkStart ( getDateTimeString ( mpxjTask . getStart ( ) ) ) ; ConstraintType mpxjConstraintType = mpxjTask . getConstraintType ( ) ; if ( mpxjConstraintType != ConstraintType . AS_SOON_AS_POSSIBLE ) { Constraint plannerConstraint = m_factory . createConstraint ( ) ; plannerTask . setConstraint ( plannerConstraint ) ; if ( mpxjConstraintType == ConstraintType . START_NO_EARLIER_THAN ) { plannerConstraint . setType ( "start-no-earlier-than" ) ; } else { if ( mpxjConstraintType == ConstraintType . MUST_START_ON ) { plannerConstraint . setType ( "must-start-on" ) ; } } plannerConstraint . setTime ( getDateTimeString ( mpxjTask . getConstraintDate ( ) ) ) ; } // // Write predecessors // writePredecessors ( mpxjTask , plannerTask ) ; m_eventManager . fireTaskWrittenEvent ( mpxjTask ) ; // // Write child tasks // List < net . sf . mpxj . planner . schema . Task > childTaskList = plannerTask . getTask ( ) ; for ( Task task : mpxjTask . getChildTasks ( ) ) { writeTask ( task , childTaskList ) ; } } | This method writes data for a single task to a Planner file . | 680 | 14 |
143,854 | private void writePredecessors ( Task mpxjTask , net . sf . mpxj . planner . schema . Task plannerTask ) { Predecessors plannerPredecessors = m_factory . createPredecessors ( ) ; plannerTask . setPredecessors ( plannerPredecessors ) ; List < Predecessor > predecessorList = plannerPredecessors . getPredecessor ( ) ; int id = 0 ; List < Relation > predecessors = mpxjTask . getPredecessors ( ) ; for ( Relation rel : predecessors ) { Integer taskUniqueID = rel . getTargetTask ( ) . getUniqueID ( ) ; Predecessor plannerPredecessor = m_factory . createPredecessor ( ) ; plannerPredecessor . setId ( getIntegerString ( ++ id ) ) ; plannerPredecessor . setPredecessorId ( getIntegerString ( taskUniqueID ) ) ; plannerPredecessor . setLag ( getDurationString ( rel . getLag ( ) ) ) ; plannerPredecessor . setType ( RELATIONSHIP_TYPES . get ( rel . getType ( ) ) ) ; predecessorList . add ( plannerPredecessor ) ; m_eventManager . fireRelationWrittenEvent ( rel ) ; } } | This method writes predecessor data to a Planner file . We have to deal with a slight anomaly in this method that is introduced by the MPX file format . It would be possible for someone to create an MPX file with both the predecessor list and the unique ID predecessor list populated ... which means that we must process both and avoid adding duplicate predecessors . Also interesting to note is that MSP98 populates the predecessor list not the unique ID predecessor list as you might expect . | 273 | 95 |
143,855 | private void writeAssignments ( ) { Allocations allocations = m_factory . createAllocations ( ) ; m_plannerProject . setAllocations ( allocations ) ; List < Allocation > allocationList = allocations . getAllocation ( ) ; for ( ResourceAssignment mpxjAssignment : m_projectFile . getResourceAssignments ( ) ) { Allocation plannerAllocation = m_factory . createAllocation ( ) ; allocationList . add ( plannerAllocation ) ; plannerAllocation . setTaskId ( getIntegerString ( mpxjAssignment . getTask ( ) . getUniqueID ( ) ) ) ; plannerAllocation . setResourceId ( getIntegerString ( mpxjAssignment . getResourceUniqueID ( ) ) ) ; plannerAllocation . setUnits ( getIntegerString ( mpxjAssignment . getUnits ( ) ) ) ; m_eventManager . fireAssignmentWrittenEvent ( mpxjAssignment ) ; } } | This method writes assignment data to a Planner file . | 209 | 11 |
143,856 | private String getIntegerString ( Number value ) { return ( value == null ? null : Integer . toString ( value . intValue ( ) ) ) ; } | Convert an Integer value into a String . | 33 | 9 |
143,857 | 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 ) ; } | Used to determine if a particular day of the week is normally a working day . | 165 | 16 |
143,858 | 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 ) ; } | Returns a flag represented as a String indicating if the supplied day is a working day . | 132 | 17 |
143,859 | private String getTimeString ( Date value ) { Calendar cal = DateHelper . popCalendar ( value ) ; int hours = cal . get ( Calendar . HOUR_OF_DAY ) ; int minutes = cal . get ( Calendar . MINUTE ) ; DateHelper . pushCalendar ( cal ) ; StringBuilder sb = new StringBuilder ( 4 ) ; sb . append ( m_twoDigitFormat . format ( hours ) ) ; sb . append ( m_twoDigitFormat . format ( minutes ) ) ; return ( sb . toString ( ) ) ; } | Convert a Java date into a Planner time . | 123 | 11 |
143,860 | private String getDateString ( Date value ) { Calendar cal = DateHelper . popCalendar ( value ) ; int year = cal . get ( Calendar . YEAR ) ; int month = cal . get ( Calendar . MONTH ) + 1 ; int day = cal . get ( Calendar . DAY_OF_MONTH ) ; DateHelper . pushCalendar ( cal ) ; StringBuilder sb = new StringBuilder ( 8 ) ; sb . append ( m_fourDigitFormat . format ( year ) ) ; sb . append ( m_twoDigitFormat . format ( month ) ) ; sb . append ( m_twoDigitFormat . format ( day ) ) ; return ( sb . toString ( ) ) ; } | Convert a Java date into a Planner date . | 155 | 11 |
143,861 | private String getDateTimeString ( Date value ) { String result = null ; if ( value != null ) { Calendar cal = DateHelper . popCalendar ( value ) ; StringBuilder sb = new StringBuilder ( 16 ) ; sb . append ( m_fourDigitFormat . format ( cal . get ( Calendar . YEAR ) ) ) ; sb . append ( m_twoDigitFormat . format ( cal . get ( Calendar . MONTH ) + 1 ) ) ; sb . append ( m_twoDigitFormat . format ( cal . get ( Calendar . DAY_OF_MONTH ) ) ) ; sb . append ( ' ' ) ; sb . append ( m_twoDigitFormat . format ( cal . get ( Calendar . HOUR_OF_DAY ) ) ) ; sb . append ( m_twoDigitFormat . format ( cal . get ( Calendar . MINUTE ) ) ) ; sb . append ( m_twoDigitFormat . format ( cal . get ( Calendar . SECOND ) ) ) ; sb . append ( ' ' ) ; result = sb . toString ( ) ; DateHelper . pushCalendar ( cal ) ; } return result ; } | Convert a Java date into a Planner date - time string . | 256 | 14 |
143,862 | private String getDurationString ( Duration value ) { String result = null ; if ( value != null ) { double seconds = 0 ; switch ( value . getUnits ( ) ) { case MINUTES : case ELAPSED_MINUTES : { seconds = value . getDuration ( ) * 60 ; break ; } case HOURS : case ELAPSED_HOURS : { seconds = value . getDuration ( ) * ( 60 * 60 ) ; break ; } case DAYS : { double minutesPerDay = m_projectFile . getProjectProperties ( ) . getMinutesPerDay ( ) . doubleValue ( ) ; seconds = value . getDuration ( ) * ( minutesPerDay * 60 ) ; break ; } case ELAPSED_DAYS : { seconds = value . getDuration ( ) * ( 24 * 60 * 60 ) ; break ; } case WEEKS : { double minutesPerWeek = m_projectFile . getProjectProperties ( ) . getMinutesPerWeek ( ) . doubleValue ( ) ; seconds = value . getDuration ( ) * ( minutesPerWeek * 60 ) ; break ; } case ELAPSED_WEEKS : { seconds = value . getDuration ( ) * ( 7 * 24 * 60 * 60 ) ; break ; } case MONTHS : { double minutesPerDay = m_projectFile . getProjectProperties ( ) . getMinutesPerDay ( ) . doubleValue ( ) ; double daysPerMonth = m_projectFile . getProjectProperties ( ) . getDaysPerMonth ( ) . doubleValue ( ) ; seconds = value . getDuration ( ) * ( daysPerMonth * minutesPerDay * 60 ) ; break ; } case ELAPSED_MONTHS : { seconds = value . getDuration ( ) * ( 30 * 24 * 60 * 60 ) ; break ; } case YEARS : { double minutesPerDay = m_projectFile . getProjectProperties ( ) . getMinutesPerDay ( ) . doubleValue ( ) ; double daysPerMonth = m_projectFile . getProjectProperties ( ) . getDaysPerMonth ( ) . doubleValue ( ) ; seconds = value . getDuration ( ) * ( 12 * daysPerMonth * minutesPerDay * 60 ) ; break ; } case ELAPSED_YEARS : { seconds = value . getDuration ( ) * ( 365 * 24 * 60 * 60 ) ; break ; } default : { break ; } } result = Long . toString ( ( long ) seconds ) ; } return ( result ) ; } | Converts an MPXJ Duration instance into the string representation of a Planner duration . | 540 | 18 |
143,863 | private void readProjectProperties ( Project project ) throws MPXJException { ProjectProperties properties = m_projectFile . getProjectProperties ( ) ; properties . setCompany ( project . getCompany ( ) ) ; properties . setManager ( project . getManager ( ) ) ; properties . setName ( project . getName ( ) ) ; properties . setStartDate ( getDateTime ( project . getProjectStart ( ) ) ) ; } | This method extracts project properties from a Planner file . | 93 | 11 |
143,864 | private void readCalendars ( Project project ) throws MPXJException { Calendars calendars = project . getCalendars ( ) ; if ( calendars != null ) { for ( net . sf . mpxj . planner . schema . Calendar cal : calendars . getCalendar ( ) ) { readCalendar ( cal , null ) ; } Integer defaultCalendarID = getInteger ( project . getCalendar ( ) ) ; m_defaultCalendar = m_projectFile . getCalendarByUniqueID ( defaultCalendarID ) ; if ( m_defaultCalendar != null ) { m_projectFile . getProjectProperties ( ) . setDefaultCalendarName ( m_defaultCalendar . getName ( ) ) ; } } } | This method extracts calendar data from a Planner file . | 157 | 11 |
143,865 | 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 ) ; } } | This method extracts data for a single calendar from a Planner file . | 460 | 14 |
143,866 | private void readResources ( Project plannerProject ) throws MPXJException { Resources resources = plannerProject . getResources ( ) ; if ( resources != null ) { for ( net . sf . mpxj . planner . schema . Resource res : resources . getResource ( ) ) { readResource ( res ) ; } } } | This method extracts resource data from a Planner file . | 68 | 11 |
143,867 | 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 ) ; } | This method extracts data for a single resource from a Planner file . | 478 | 14 |
143,868 | private void readTasks ( Project plannerProject ) throws MPXJException { Tasks tasks = plannerProject . getTasks ( ) ; if ( tasks != null ) { for ( net . sf . mpxj . planner . schema . Task task : tasks . getTask ( ) ) { readTask ( null , task ) ; } for ( net . sf . mpxj . planner . schema . Task task : tasks . getTask ( ) ) { readPredecessors ( task ) ; } } m_projectFile . updateStructure ( ) ; } | This method extracts task data from a Planner file . | 119 | 11 |
143,869 | private void readPredecessors ( net . sf . mpxj . planner . schema . Task plannerTask ) { Task mpxjTask = m_projectFile . getTaskByUniqueID ( getInteger ( plannerTask . getId ( ) ) ) ; Predecessors predecessors = plannerTask . getPredecessors ( ) ; if ( predecessors != null ) { List < Predecessor > predecessorList = predecessors . getPredecessor ( ) ; for ( Predecessor predecessor : predecessorList ) { Integer predecessorID = getInteger ( predecessor . getPredecessorId ( ) ) ; Task predecessorTask = m_projectFile . getTaskByUniqueID ( predecessorID ) ; if ( predecessorTask != null ) { Duration lag = getDuration ( predecessor . getLag ( ) ) ; if ( lag == null ) { lag = Duration . getInstance ( 0 , TimeUnit . HOURS ) ; } Relation relation = mpxjTask . addPredecessor ( predecessorTask , RELATIONSHIP_TYPES . get ( predecessor . getType ( ) ) , lag ) ; m_eventManager . fireRelationReadEvent ( relation ) ; } } } // // Process child tasks // List < net . sf . mpxj . planner . schema . Task > childTasks = plannerTask . getTask ( ) ; for ( net . sf . mpxj . planner . schema . Task childTask : childTasks ) { readPredecessors ( childTask ) ; } } | This method extracts predecessor data from a Planner file . | 315 | 11 |
143,870 | private void readAssignments ( Project plannerProject ) { Allocations allocations = plannerProject . getAllocations ( ) ; List < Allocation > allocationList = allocations . getAllocation ( ) ; Set < Task > tasksWithAssignments = new HashSet < Task > ( ) ; for ( Allocation allocation : allocationList ) { Integer taskID = getInteger ( allocation . getTaskId ( ) ) ; Integer resourceID = getInteger ( allocation . getResourceId ( ) ) ; Integer units = getInteger ( allocation . getUnits ( ) ) ; Task task = m_projectFile . getTaskByUniqueID ( taskID ) ; Resource resource = m_projectFile . getResourceByUniqueID ( resourceID ) ; if ( task != null && resource != null ) { Duration work = task . getWork ( ) ; int percentComplete = NumberHelper . getInt ( task . getPercentageComplete ( ) ) ; ResourceAssignment assignment = task . addResourceAssignment ( resource ) ; assignment . setUnits ( units ) ; assignment . setWork ( work ) ; if ( percentComplete != 0 ) { Duration actualWork = Duration . getInstance ( ( work . getDuration ( ) * percentComplete ) / 100 , work . getUnits ( ) ) ; assignment . setActualWork ( actualWork ) ; assignment . setRemainingWork ( Duration . getInstance ( work . getDuration ( ) - actualWork . getDuration ( ) , work . getUnits ( ) ) ) ; } else { assignment . setRemainingWork ( work ) ; } assignment . setStart ( task . getStart ( ) ) ; assignment . setFinish ( task . getFinish ( ) ) ; tasksWithAssignments . add ( task ) ; m_eventManager . fireAssignmentReadEvent ( assignment ) ; } } // // Adjust work per assignment for tasks with multiple assignments // for ( Task task : tasksWithAssignments ) { List < ResourceAssignment > assignments = task . getResourceAssignments ( ) ; if ( assignments . size ( ) > 1 ) { double maxUnits = 0 ; for ( ResourceAssignment assignment : assignments ) { maxUnits += assignment . getUnits ( ) . doubleValue ( ) ; } for ( ResourceAssignment assignment : assignments ) { Duration work = assignment . getWork ( ) ; double factor = assignment . getUnits ( ) . doubleValue ( ) / maxUnits ; work = Duration . getInstance ( work . getDuration ( ) * factor , work . getUnits ( ) ) ; assignment . setWork ( work ) ; Duration actualWork = assignment . getActualWork ( ) ; if ( actualWork != null ) { actualWork = Duration . getInstance ( actualWork . getDuration ( ) * factor , actualWork . getUnits ( ) ) ; assignment . setActualWork ( actualWork ) ; } Duration remainingWork = assignment . getRemainingWork ( ) ; if ( remainingWork != null ) { remainingWork = Duration . getInstance ( remainingWork . getDuration ( ) * factor , remainingWork . getUnits ( ) ) ; assignment . setRemainingWork ( remainingWork ) ; } } } } } | This method extracts assignment data from a Planner file . | 668 | 11 |
143,871 | private Date getDateTime ( String value ) throws MPXJException { try { Number year = m_fourDigitFormat . parse ( value . substring ( 0 , 4 ) ) ; Number month = m_twoDigitFormat . parse ( value . substring ( 4 , 6 ) ) ; Number day = m_twoDigitFormat . parse ( value . substring ( 6 , 8 ) ) ; Number hours = m_twoDigitFormat . parse ( value . substring ( 9 , 11 ) ) ; Number minutes = m_twoDigitFormat . parse ( value . substring ( 11 , 13 ) ) ; Calendar cal = DateHelper . popCalendar ( ) ; cal . set ( Calendar . YEAR , year . intValue ( ) ) ; cal . set ( Calendar . MONTH , month . intValue ( ) - 1 ) ; cal . set ( Calendar . DAY_OF_MONTH , day . intValue ( ) ) ; cal . set ( Calendar . HOUR_OF_DAY , hours . intValue ( ) ) ; cal . set ( Calendar . MINUTE , minutes . intValue ( ) ) ; cal . set ( Calendar . SECOND , 0 ) ; cal . set ( Calendar . MILLISECOND , 0 ) ; Date result = cal . getTime ( ) ; DateHelper . pushCalendar ( cal ) ; return result ; } catch ( ParseException ex ) { throw new MPXJException ( "Failed to parse date-time " + value , ex ) ; } } | Convert a Planner date - time value into a Java date . | 320 | 14 |
143,872 | private Date getTime ( String value ) throws MPXJException { try { Number hours = m_twoDigitFormat . parse ( value . substring ( 0 , 2 ) ) ; Number minutes = m_twoDigitFormat . parse ( value . substring ( 2 , 4 ) ) ; Calendar cal = DateHelper . popCalendar ( ) ; cal . set ( Calendar . HOUR_OF_DAY , hours . intValue ( ) ) ; cal . set ( Calendar . MINUTE , minutes . intValue ( ) ) ; cal . set ( Calendar . SECOND , 0 ) ; cal . set ( Calendar . MILLISECOND , 0 ) ; Date result = cal . getTime ( ) ; DateHelper . pushCalendar ( cal ) ; return result ; } catch ( ParseException ex ) { throw new MPXJException ( "Failed to parse time " + value , ex ) ; } } | Convert a Planner time into a Java date . | 192 | 11 |
143,873 | private Duration getDuration ( String value ) { Duration result = null ; if ( value != null && value . length ( ) != 0 ) { double seconds = getLong ( value ) ; double hours = seconds / ( 60 * 60 ) ; double days = hours / 8 ; if ( days < 1 ) { result = Duration . getInstance ( hours , TimeUnit . HOURS ) ; } else { double durationDays = hours / 8 ; result = Duration . getInstance ( durationDays , TimeUnit . DAYS ) ; } } return ( result ) ; } | Converts the string representation of a Planner duration into an MPXJ Duration instance . | 115 | 18 |
143,874 | public ArrayList < Duration > segmentWork ( ProjectCalendar projectCalendar , List < TimephasedWork > work , TimescaleUnits rangeUnits , List < DateRange > dateList ) { ArrayList < Duration > result = new ArrayList < Duration > ( 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 ; } | 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 . | 293 | 29 |
143,875 | public ArrayList < Duration > segmentBaselineWork ( ProjectFile file , List < TimephasedWork > work , TimescaleUnits rangeUnits , ArrayList < DateRange > dateList ) { return segmentWork ( file . getBaselineCalendar ( ) , work , rangeUnits , dateList ) ; } | This is the main entry point used to convert the internal representation of timephased baseline work into an external form which can be displayed to the user . | 67 | 30 |
143,876 | public ArrayList < Double > segmentCost ( ProjectCalendar projectCalendar , List < TimephasedCost > cost , TimescaleUnits rangeUnits , ArrayList < DateRange > dateList ) { ArrayList < Double > result = new ArrayList < Double > ( 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 , cost , lastStartIndex ) ; if ( startIndex == - 1 ) { result . add ( NumberHelper . DOUBLE_ZERO ) ; } 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 ( getRangeCost ( projectCalendar , rangeUnits , range , cost , startIndex ) ) ; lastStartIndex = startIndex ; } } return result ; } | This is the main entry point used to convert the internal representation of timephased cost into an external form which can be displayed to the user . | 290 | 29 |
143,877 | public ArrayList < Double > segmentBaselineCost ( ProjectFile file , List < TimephasedCost > cost , TimescaleUnits rangeUnits , ArrayList < DateRange > dateList ) { return segmentCost ( file . getBaselineCalendar ( ) , cost , rangeUnits , dateList ) ; } | This is the main entry point used to convert the internal representation of timephased baseline cost into an external form which can be displayed to the user . | 67 | 30 |
143,878 | private < T extends TimephasedItem < ? > > int getStartIndex ( DateRange range , List < T > assignments , int startIndex ) { int result = - 1 ; if ( assignments != null ) { long rangeStart = range . getStart ( ) . getTime ( ) ; long rangeEnd = range . getEnd ( ) . getTime ( ) ; for ( int loop = startIndex ; loop < assignments . size ( ) ; loop ++ ) { T assignment = assignments . get ( loop ) ; int compareResult = DateHelper . compare ( assignment . getStart ( ) , assignment . getFinish ( ) , rangeStart ) ; // // The start of the target range falls after the assignment end - // move on to test the next assignment. // if ( compareResult > 0 ) { continue ; } // // The start of the target range falls within the assignment - // return the index of this assignment to the caller. // if ( compareResult == 0 ) { result = loop ; break ; } // // At this point, we know that the start of the target range is before // the assignment start. We need to determine if the end of the // target range overlaps the assignment. // compareResult = DateHelper . compare ( assignment . getStart ( ) , assignment . getFinish ( ) , rangeEnd ) ; if ( compareResult >= 0 ) { result = loop ; break ; } } } return result ; } | Used to locate the first timephased resource assignment block which intersects with the target date range . | 296 | 20 |
143,879 | private void processCalendarHours ( byte [ ] data , ProjectCalendar defaultCalendar , ProjectCalendar cal , boolean isBaseCalendar ) { // Dump out the calendar related data and fields. //MPPUtility.dataDump(data, true, false, false, false, true, false, true); int offset ; ProjectCalendarHours hours ; int periodIndex ; int index ; int defaultFlag ; int periodCount ; Date start ; long duration ; Day day ; List < DateRange > dateRanges = new ArrayList < DateRange > ( 5 ) ; for ( index = 0 ; index < 7 ; index ++ ) { offset = getCalendarHoursOffset ( ) + ( 60 * index ) ; defaultFlag = data == null ? 1 : MPPUtility . getShort ( data , offset ) ; day = Day . getInstance ( index + 1 ) ; if ( defaultFlag == 1 ) { if ( isBaseCalendar ) { if ( defaultCalendar == null ) { cal . setWorkingDay ( day , DEFAULT_WORKING_WEEK [ index ] ) ; if ( cal . isWorkingDay ( day ) ) { hours = cal . addCalendarHours ( Day . getInstance ( index + 1 ) ) ; hours . addRange ( ProjectCalendarWeek . DEFAULT_WORKING_MORNING ) ; hours . addRange ( ProjectCalendarWeek . DEFAULT_WORKING_AFTERNOON ) ; } } else { boolean workingDay = defaultCalendar . isWorkingDay ( day ) ; cal . setWorkingDay ( day , workingDay ) ; if ( workingDay ) { hours = cal . addCalendarHours ( Day . getInstance ( index + 1 ) ) ; for ( DateRange range : defaultCalendar . getHours ( day ) ) { hours . addRange ( range ) ; } } } } else { cal . setWorkingDay ( day , DayType . DEFAULT ) ; } } else { dateRanges . clear ( ) ; periodIndex = 0 ; periodCount = MPPUtility . getShort ( data , offset + 2 ) ; while ( periodIndex < periodCount ) { int startOffset = offset + 8 + ( periodIndex * 2 ) ; start = MPPUtility . getTime ( data , startOffset ) ; int durationOffset = offset + 20 + ( periodIndex * 4 ) ; duration = MPPUtility . getDuration ( data , durationOffset ) ; Date end = new Date ( start . getTime ( ) + duration ) ; dateRanges . add ( new DateRange ( start , end ) ) ; ++ periodIndex ; } if ( dateRanges . isEmpty ( ) ) { cal . setWorkingDay ( day , false ) ; } else { cal . setWorkingDay ( day , true ) ; hours = cal . addCalendarHours ( Day . getInstance ( index + 1 ) ) ; for ( DateRange range : dateRanges ) { hours . addRange ( range ) ; } } } } } | For a given set of calendar data this method sets the working day status for each day and if present sets the hours for that day . | 633 | 27 |
143,880 | 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 ) ; } } } | 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 . | 147 | 68 |
143,881 | public void fireTaskReadEvent ( Task task ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . taskRead ( task ) ; } } } | This method is called to alert project listeners to the fact that a task has been read from a project file . | 46 | 22 |
143,882 | public void fireTaskWrittenEvent ( Task task ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . taskWritten ( task ) ; } } } | This method is called to alert project listeners to the fact that a task has been written to a project file . | 46 | 22 |
143,883 | public void fireResourceReadEvent ( Resource resource ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . resourceRead ( resource ) ; } } } | This method is called to alert project listeners to the fact that a resource has been read from a project file . | 46 | 22 |
143,884 | public void fireResourceWrittenEvent ( Resource resource ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . resourceWritten ( resource ) ; } } } | This method is called to alert project listeners to the fact that a resource has been written to a project file . | 46 | 22 |
143,885 | public void fireCalendarReadEvent ( ProjectCalendar calendar ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . calendarRead ( calendar ) ; } } } | This method is called to alert project listeners to the fact that a calendar has been read from a project file . | 49 | 22 |
143,886 | public void fireAssignmentReadEvent ( ResourceAssignment resourceAssignment ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . assignmentRead ( resourceAssignment ) ; } } } | This method is called to alert project listeners to the fact that a resource assignment has been read from a project file . | 53 | 23 |
143,887 | public void fireAssignmentWrittenEvent ( ResourceAssignment resourceAssignment ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . assignmentWritten ( resourceAssignment ) ; } } } | This method is called to alert project listeners to the fact that a resource assignment has been written to a project file . | 53 | 23 |
143,888 | public void fireRelationReadEvent ( Relation relation ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . relationRead ( relation ) ; } } } | This method is called to alert project listeners to the fact that a relation has been read from a project file . | 48 | 22 |
143,889 | public void fireRelationWrittenEvent ( Relation relation ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . relationWritten ( relation ) ; } } } | This method is called to alert project listeners to the fact that a relation has been written to a project file . | 48 | 22 |
143,890 | public void fireCalendarWrittenEvent ( ProjectCalendar calendar ) { if ( m_projectListeners != null ) { for ( ProjectListener listener : m_projectListeners ) { listener . calendarWritten ( calendar ) ; } } } | This method is called to alert project listeners to the fact that a calendar has been written to a project file . | 49 | 22 |
143,891 | public void addProjectListeners ( List < ProjectListener > listeners ) { if ( listeners != null ) { for ( ProjectListener listener : listeners ) { addProjectListener ( listener ) ; } } } | Adds a collection of listeners to the current project . | 41 | 10 |
143,892 | public < E extends Enum < E > & FieldType > E nextField ( Class < E > clazz , UserFieldDataType type ) { for ( String name : m_names [ type . ordinal ( ) ] ) { int i = NumberHelper . getInt ( m_counters . get ( name ) ) + 1 ; try { E e = Enum . valueOf ( clazz , name + i ) ; m_counters . put ( name , Integer . valueOf ( i ) ) ; return e ; } catch ( IllegalArgumentException ex ) { // try the next name } } // no more fields available throw new IllegalArgumentException ( "No fields for type " + type + " available" ) ; } | Generate the next available field for a user defined field . | 155 | 12 |
143,893 | private ProjectFile read ( ) throws Exception { m_project = new ProjectFile ( ) ; m_eventManager = m_project . getEventManager ( ) ; ProjectConfig config = m_project . getProjectConfig ( ) ; config . setAutoCalendarUniqueID ( false ) ; config . setAutoTaskID ( false ) ; config . setAutoTaskUniqueID ( false ) ; config . setAutoResourceUniqueID ( false ) ; config . setAutoWBS ( false ) ; config . setAutoOutlineNumber ( false ) ; m_project . getProjectProperties ( ) . setFileApplication ( "FastTrack" ) ; m_project . getProjectProperties ( ) . setFileType ( "FTS" ) ; m_eventManager . addProjectListeners ( m_projectListeners ) ; // processProject(); // processCalendars(); processResources ( ) ; processTasks ( ) ; processDependencies ( ) ; processAssignments ( ) ; return m_project ; } | Read FTS file data from the configured source and return a populated ProjectFile instance . | 212 | 17 |
143,894 | private void processDependencies ( ) { Set < Task > tasksWithBars = new HashSet < Task > ( ) ; FastTrackTable table = m_data . getTable ( FastTrackTableType . ACTBARS ) ; for ( MapRow row : table ) { Task task = m_project . getTaskByUniqueID ( row . getInteger ( ActBarField . _ACTIVITY ) ) ; if ( task == null || tasksWithBars . contains ( task ) ) { continue ; } tasksWithBars . add ( task ) ; String predecessors = row . getString ( ActBarField . PREDECESSORS ) ; if ( predecessors == null || predecessors . isEmpty ( ) ) { continue ; } for ( String predecessor : predecessors . split ( ", " ) ) { Matcher matcher = RELATION_REGEX . matcher ( predecessor ) ; matcher . matches ( ) ; Integer id = Integer . valueOf ( matcher . group ( 1 ) ) ; RelationType type = RELATION_TYPE_MAP . get ( matcher . group ( 3 ) ) ; if ( type == null ) { type = RelationType . FINISH_START ; } String sign = matcher . group ( 4 ) ; double lag = NumberHelper . getDouble ( matcher . group ( 5 ) ) ; if ( "-" . equals ( sign ) ) { lag = - lag ; } Task targetTask = m_project . getTaskByID ( id ) ; if ( targetTask != null ) { Duration lagDuration = Duration . getInstance ( lag , m_data . getDurationTimeUnit ( ) ) ; Relation relation = task . addPredecessor ( targetTask , type , lagDuration ) ; m_eventManager . fireRelationReadEvent ( relation ) ; } } } } | Process task dependencies . | 382 | 4 |
143,895 | private Integer getOutlineLevel ( Task task ) { String value = task . getWBS ( ) ; Integer result = Integer . valueOf ( 1 ) ; if ( value != null && value . length ( ) > 0 ) { String [ ] path = WBS_SPLIT_REGEX . split ( value ) ; result = Integer . valueOf ( path . length ) ; } return result ; } | Extract the outline level from a task s WBS attribute . | 85 | 13 |
143,896 | public void setWeeklyDay ( Day day , boolean value ) { if ( value ) { m_days . add ( day ) ; } else { m_days . remove ( day ) ; } } | Set the state of an individual day in a weekly recurrence . | 42 | 13 |
143,897 | public void setWeeklyDaysFromBitmap ( Integer days , int [ ] masks ) { if ( days != null ) { int value = days . intValue ( ) ; for ( Day day : Day . values ( ) ) { setWeeklyDay ( day , ( ( value & masks [ day . getValue ( ) ] ) != 0 ) ) ; } } } | Converts from a bitmap to individual day flags for a weekly recurrence using the array of masks . | 77 | 21 |
143,898 | public Day getDayOfWeek ( ) { Day result = null ; if ( ! m_days . isEmpty ( ) ) { result = m_days . iterator ( ) . next ( ) ; } return result ; } | Retrieves the monthly or yearly relative day of the week . | 46 | 13 |
143,899 | public Date [ ] getDates ( ) { int frequency = NumberHelper . getInt ( m_frequency ) ; if ( frequency < 1 ) { frequency = 1 ; } Calendar calendar = DateHelper . popCalendar ( m_startDate ) ; List < Date > dates = new ArrayList < Date > ( ) ; switch ( m_recurrenceType ) { case DAILY : { getDailyDates ( calendar , frequency , dates ) ; break ; } case WEEKLY : { getWeeklyDates ( calendar , frequency , dates ) ; break ; } case MONTHLY : { getMonthlyDates ( calendar , frequency , dates ) ; break ; } case YEARLY : { getYearlyDates ( calendar , dates ) ; break ; } } DateHelper . pushCalendar ( calendar ) ; return dates . toArray ( new Date [ dates . size ( ) ] ) ; } | Retrieve the set of start dates represented by this recurrence data . | 187 | 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.