idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
143,500 | private Map < String , ColumnDefinition > makeColumnMap ( ColumnDefinition [ ] columns ) { Map < String , ColumnDefinition > map = new HashMap < String , ColumnDefinition > ( ) ; for ( ColumnDefinition def : columns ) { map . put ( def . getName ( ) , def ) ; } return map ; } | Convert an array of column definitions into a map keyed by column name . | 68 | 16 |
143,501 | private void writeProjectExtendedAttributes ( Project project ) { Project . ExtendedAttributes attributes = m_factory . createProjectExtendedAttributes ( ) ; project . setExtendedAttributes ( attributes ) ; List < Project . ExtendedAttributes . ExtendedAttribute > list = attributes . getExtendedAttribute ( ) ; Set < FieldType > customFields = new HashSet < FieldType > ( ) ; for ( CustomField customField : m_projectFile . getCustomFields ( ) ) { FieldType fieldType = customField . getFieldType ( ) ; if ( fieldType != null ) { customFields . add ( fieldType ) ; } } customFields . addAll ( m_extendedAttributesInUse ) ; List < FieldType > customFieldsList = new ArrayList < FieldType > ( ) ; customFieldsList . addAll ( customFields ) ; // Sort to ensure consistent order in file final CustomFieldContainer customFieldContainer = m_projectFile . getCustomFields ( ) ; Collections . sort ( customFieldsList , new Comparator < FieldType > ( ) { @ Override public int compare ( FieldType o1 , FieldType o2 ) { CustomField customField1 = customFieldContainer . getCustomField ( o1 ) ; CustomField customField2 = customFieldContainer . getCustomField ( o2 ) ; String name1 = o1 . getClass ( ) . getSimpleName ( ) + "." + o1 . getName ( ) + " " + customField1 . getAlias ( ) ; String name2 = o2 . getClass ( ) . getSimpleName ( ) + "." + o2 . getName ( ) + " " + customField2 . getAlias ( ) ; return name1 . compareTo ( name2 ) ; } } ) ; for ( FieldType fieldType : customFieldsList ) { Project . ExtendedAttributes . ExtendedAttribute attribute = m_factory . createProjectExtendedAttributesExtendedAttribute ( ) ; list . add ( attribute ) ; attribute . setFieldID ( String . valueOf ( FieldTypeHelper . getFieldID ( fieldType ) ) ) ; attribute . setFieldName ( fieldType . getName ( ) ) ; CustomField customField = customFieldContainer . getCustomField ( fieldType ) ; attribute . setAlias ( customField . getAlias ( ) ) ; } } | This method writes project extended attribute data into an MSPDI file . | 500 | 14 |
143,502 | private void writeCalendars ( Project project ) { // // Create the new MSPDI calendar list // Project . Calendars calendars = m_factory . createProjectCalendars ( ) ; project . setCalendars ( calendars ) ; List < Project . Calendars . Calendar > calendar = calendars . getCalendar ( ) ; // // Process each calendar in turn // for ( ProjectCalendar cal : m_projectFile . getCalendars ( ) ) { calendar . add ( writeCalendar ( cal ) ) ; } } | This method writes calendar data to an MSPDI file . | 108 | 12 |
143,503 | private Project . Calendars . Calendar writeCalendar ( ProjectCalendar bc ) { // // Create a calendar // Project . Calendars . Calendar calendar = m_factory . createProjectCalendarsCalendar ( ) ; calendar . setUID ( NumberHelper . getBigInteger ( bc . getUniqueID ( ) ) ) ; calendar . setIsBaseCalendar ( Boolean . valueOf ( ! bc . isDerived ( ) ) ) ; ProjectCalendar base = bc . getParent ( ) ; // SF-329: null default required to keep Powerproject happy when importing MSPDI files calendar . setBaseCalendarUID ( base == null ? NULL_CALENDAR_ID : NumberHelper . getBigInteger ( base . getUniqueID ( ) ) ) ; calendar . setName ( bc . getName ( ) ) ; // // Create a list of normal days // Project . Calendars . Calendar . WeekDays days = m_factory . createProjectCalendarsCalendarWeekDays ( ) ; Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes . WorkingTime time ; ProjectCalendarHours bch ; List < Project . Calendars . Calendar . WeekDays . WeekDay > dayList = days . getWeekDay ( ) ; for ( int loop = 1 ; loop < 8 ; loop ++ ) { DayType workingFlag = bc . getWorkingDay ( Day . getInstance ( loop ) ) ; if ( workingFlag != DayType . DEFAULT ) { Project . Calendars . Calendar . WeekDays . WeekDay day = m_factory . createProjectCalendarsCalendarWeekDaysWeekDay ( ) ; dayList . add ( day ) ; day . setDayType ( BigInteger . valueOf ( loop ) ) ; day . setDayWorking ( Boolean . valueOf ( workingFlag == DayType . WORKING ) ) ; if ( workingFlag == DayType . WORKING ) { Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes times = m_factory . createProjectCalendarsCalendarWeekDaysWeekDayWorkingTimes ( ) ; day . setWorkingTimes ( times ) ; List < Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes . WorkingTime > timesList = times . getWorkingTime ( ) ; bch = bc . getCalendarHours ( Day . getInstance ( loop ) ) ; if ( bch != null ) { for ( DateRange range : bch ) { if ( range != null ) { time = m_factory . createProjectCalendarsCalendarWeekDaysWeekDayWorkingTimesWorkingTime ( ) ; timesList . add ( time ) ; time . setFromTime ( range . getStart ( ) ) ; time . setToTime ( range . getEnd ( ) ) ; } } } } } } // // Create a list of exceptions // // A quirk of MS Project is that these exceptions must be // in date order in the file, otherwise they are ignored // List < ProjectCalendarException > exceptions = new ArrayList < ProjectCalendarException > ( bc . getCalendarExceptions ( ) ) ; if ( ! exceptions . isEmpty ( ) ) { Collections . sort ( exceptions ) ; writeExceptions ( calendar , dayList , exceptions ) ; } // // Do not add a weekdays tag to the calendar unless it // has valid entries. // Fixes SourceForge bug 1854747: MPXJ and MSP 2007 XML formats // if ( ! dayList . isEmpty ( ) ) { calendar . setWeekDays ( days ) ; } writeWorkWeeks ( calendar , bc ) ; m_eventManager . fireCalendarWrittenEvent ( bc ) ; return ( calendar ) ; } | This method writes data for a single calendar to an MSPDI file . | 772 | 15 |
143,504 | private void writeExceptions ( Project . Calendars . Calendar calendar , List < Project . Calendars . Calendar . WeekDays . WeekDay > dayList , List < ProjectCalendarException > exceptions ) { // Always write legacy exception data: // Powerproject appears not to recognise new format data at all, // and legacy data is ignored in preference to new data post MSP 2003 writeExceptions9 ( dayList , exceptions ) ; if ( m_saveVersion . getValue ( ) > SaveVersion . Project2003 . getValue ( ) ) { writeExceptions12 ( calendar , exceptions ) ; } } | Main entry point used to determine the format used to write calendar exceptions . | 124 | 14 |
143,505 | private void writeExceptions9 ( List < Project . Calendars . Calendar . WeekDays . WeekDay > dayList , List < ProjectCalendarException > exceptions ) { for ( ProjectCalendarException exception : exceptions ) { boolean working = exception . getWorking ( ) ; Project . Calendars . Calendar . WeekDays . WeekDay day = m_factory . createProjectCalendarsCalendarWeekDaysWeekDay ( ) ; dayList . add ( day ) ; day . setDayType ( BIGINTEGER_ZERO ) ; day . setDayWorking ( Boolean . valueOf ( working ) ) ; Project . Calendars . Calendar . WeekDays . WeekDay . TimePeriod period = m_factory . createProjectCalendarsCalendarWeekDaysWeekDayTimePeriod ( ) ; day . setTimePeriod ( period ) ; period . setFromDate ( exception . getFromDate ( ) ) ; period . setToDate ( exception . getToDate ( ) ) ; if ( working ) { Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes times = m_factory . createProjectCalendarsCalendarWeekDaysWeekDayWorkingTimes ( ) ; day . setWorkingTimes ( times ) ; List < Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes . WorkingTime > timesList = times . getWorkingTime ( ) ; for ( DateRange range : exception ) { Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes . WorkingTime time = m_factory . createProjectCalendarsCalendarWeekDaysWeekDayWorkingTimesWorkingTime ( ) ; timesList . add ( time ) ; time . setFromTime ( range . getStart ( ) ) ; time . setToTime ( range . getEnd ( ) ) ; } } } } | Write exceptions in the format used by MSPDI files prior to Project 2007 . | 379 | 16 |
143,506 | private void writeExceptions12 ( Project . Calendars . Calendar calendar , List < ProjectCalendarException > exceptions ) { Exceptions ce = m_factory . createProjectCalendarsCalendarExceptions ( ) ; calendar . setExceptions ( ce ) ; List < Exceptions . Exception > el = ce . getException ( ) ; for ( ProjectCalendarException exception : exceptions ) { Exceptions . Exception ex = m_factory . createProjectCalendarsCalendarExceptionsException ( ) ; el . add ( ex ) ; ex . setName ( exception . getName ( ) ) ; boolean working = exception . getWorking ( ) ; ex . setDayWorking ( Boolean . valueOf ( working ) ) ; if ( exception . getRecurring ( ) == null ) { ex . setEnteredByOccurrences ( Boolean . FALSE ) ; ex . setOccurrences ( BigInteger . ONE ) ; ex . setType ( BigInteger . ONE ) ; } else { populateRecurringException ( exception , ex ) ; } Project . Calendars . Calendar . Exceptions . Exception . TimePeriod period = m_factory . createProjectCalendarsCalendarExceptionsExceptionTimePeriod ( ) ; ex . setTimePeriod ( period ) ; period . setFromDate ( exception . getFromDate ( ) ) ; period . setToDate ( exception . getToDate ( ) ) ; if ( working ) { Project . Calendars . Calendar . Exceptions . Exception . WorkingTimes times = m_factory . createProjectCalendarsCalendarExceptionsExceptionWorkingTimes ( ) ; ex . setWorkingTimes ( times ) ; List < Project . Calendars . Calendar . Exceptions . Exception . WorkingTimes . WorkingTime > timesList = times . getWorkingTime ( ) ; for ( DateRange range : exception ) { Project . Calendars . Calendar . Exceptions . Exception . WorkingTimes . WorkingTime time = m_factory . createProjectCalendarsCalendarExceptionsExceptionWorkingTimesWorkingTime ( ) ; timesList . add ( time ) ; time . setFromTime ( range . getStart ( ) ) ; time . setToTime ( range . getEnd ( ) ) ; } } } } | Write exceptions into the format used by MSPDI files from Project 2007 onwards . | 461 | 16 |
143,507 | private void populateRecurringException ( ProjectCalendarException mpxjException , Exceptions . Exception xmlException ) { RecurringData data = mpxjException . getRecurring ( ) ; xmlException . setEnteredByOccurrences ( Boolean . TRUE ) ; xmlException . setOccurrences ( NumberHelper . getBigInteger ( data . getOccurrences ( ) ) ) ; switch ( data . getRecurrenceType ( ) ) { case DAILY : { xmlException . setType ( BigInteger . valueOf ( 7 ) ) ; xmlException . setPeriod ( NumberHelper . getBigInteger ( data . getFrequency ( ) ) ) ; break ; } case WEEKLY : { xmlException . setType ( BigInteger . valueOf ( 6 ) ) ; xmlException . setPeriod ( NumberHelper . getBigInteger ( data . getFrequency ( ) ) ) ; xmlException . setDaysOfWeek ( getDaysOfTheWeek ( data ) ) ; break ; } case MONTHLY : { xmlException . setPeriod ( NumberHelper . getBigInteger ( data . getFrequency ( ) ) ) ; if ( data . getRelative ( ) ) { xmlException . setType ( BigInteger . valueOf ( 5 ) ) ; xmlException . setMonthItem ( BigInteger . valueOf ( data . getDayOfWeek ( ) . getValue ( ) + 2 ) ) ; xmlException . setMonthPosition ( BigInteger . valueOf ( NumberHelper . getInt ( data . getDayNumber ( ) ) - 1 ) ) ; } else { xmlException . setType ( BigInteger . valueOf ( 4 ) ) ; xmlException . setMonthDay ( NumberHelper . getBigInteger ( data . getDayNumber ( ) ) ) ; } break ; } case YEARLY : { xmlException . setMonth ( BigInteger . valueOf ( NumberHelper . getInt ( data . getMonthNumber ( ) ) - 1 ) ) ; if ( data . getRelative ( ) ) { xmlException . setType ( BigInteger . valueOf ( 3 ) ) ; xmlException . setMonthItem ( BigInteger . valueOf ( data . getDayOfWeek ( ) . getValue ( ) + 2 ) ) ; xmlException . setMonthPosition ( BigInteger . valueOf ( NumberHelper . getInt ( data . getDayNumber ( ) ) - 1 ) ) ; } else { xmlException . setType ( BigInteger . valueOf ( 2 ) ) ; xmlException . setMonthDay ( NumberHelper . getBigInteger ( data . getDayNumber ( ) ) ) ; } } } } | Writes the details of a recurring exception . | 548 | 9 |
143,508 | private BigInteger getDaysOfTheWeek ( RecurringData data ) { int value = 0 ; for ( Day day : Day . values ( ) ) { if ( data . getWeeklyDay ( day ) ) { value = value | DAY_MASKS [ day . getValue ( ) ] ; } } return BigInteger . valueOf ( value ) ; } | Converts days of the week into a bit field . | 75 | 11 |
143,509 | private void writeWorkWeeks ( Project . Calendars . Calendar xmlCalendar , ProjectCalendar mpxjCalendar ) { List < ProjectCalendarWeek > weeks = mpxjCalendar . getWorkWeeks ( ) ; if ( ! weeks . isEmpty ( ) ) { WorkWeeks xmlWorkWeeks = m_factory . createProjectCalendarsCalendarWorkWeeks ( ) ; xmlCalendar . setWorkWeeks ( xmlWorkWeeks ) ; List < WorkWeek > xmlWorkWeekList = xmlWorkWeeks . getWorkWeek ( ) ; for ( ProjectCalendarWeek week : weeks ) { WorkWeek xmlWeek = m_factory . createProjectCalendarsCalendarWorkWeeksWorkWeek ( ) ; xmlWorkWeekList . add ( xmlWeek ) ; xmlWeek . setName ( week . getName ( ) ) ; TimePeriod xmlTimePeriod = m_factory . createProjectCalendarsCalendarWorkWeeksWorkWeekTimePeriod ( ) ; xmlWeek . setTimePeriod ( xmlTimePeriod ) ; xmlTimePeriod . setFromDate ( week . getDateRange ( ) . getStart ( ) ) ; xmlTimePeriod . setToDate ( week . getDateRange ( ) . getEnd ( ) ) ; WeekDays xmlWeekDays = m_factory . createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDays ( ) ; xmlWeek . setWeekDays ( xmlWeekDays ) ; List < Project . Calendars . Calendar . WorkWeeks . WorkWeek . WeekDays . WeekDay > dayList = xmlWeekDays . getWeekDay ( ) ; for ( int loop = 1 ; loop < 8 ; loop ++ ) { DayType workingFlag = week . getWorkingDay ( Day . getInstance ( loop ) ) ; if ( workingFlag != DayType . DEFAULT ) { Project . Calendars . Calendar . WorkWeeks . WorkWeek . WeekDays . WeekDay day = m_factory . createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDaysWeekDay ( ) ; dayList . add ( day ) ; day . setDayType ( BigInteger . valueOf ( loop ) ) ; day . setDayWorking ( Boolean . valueOf ( workingFlag == DayType . WORKING ) ) ; if ( workingFlag == DayType . WORKING ) { Project . Calendars . Calendar . WorkWeeks . WorkWeek . WeekDays . WeekDay . WorkingTimes times = m_factory . createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDaysWeekDayWorkingTimes ( ) ; day . setWorkingTimes ( times ) ; List < Project . Calendars . Calendar . WorkWeeks . WorkWeek . WeekDays . WeekDay . WorkingTimes . WorkingTime > timesList = times . getWorkingTime ( ) ; ProjectCalendarHours bch = week . getCalendarHours ( Day . getInstance ( loop ) ) ; if ( bch != null ) { for ( DateRange range : bch ) { if ( range != null ) { Project . Calendars . Calendar . WorkWeeks . WorkWeek . WeekDays . WeekDay . WorkingTimes . WorkingTime time = m_factory . createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDaysWeekDayWorkingTimesWorkingTime ( ) ; timesList . add ( time ) ; time . setFromTime ( range . getStart ( ) ) ; time . setToTime ( range . getEnd ( ) ) ; } } } } } } } } } | Write the work weeks associated with this calendar . | 738 | 9 |
143,510 | private void writeResources ( Project project ) { Project . Resources resources = m_factory . createProjectResources ( ) ; project . setResources ( resources ) ; List < Project . Resources . Resource > list = resources . getResource ( ) ; for ( Resource resource : m_projectFile . getResources ( ) ) { list . add ( writeResource ( resource ) ) ; } } | This method writes resource data to an MSPDI file . | 79 | 12 |
143,511 | private void writeResourceBaselines ( Project . Resources . Resource xmlResource , Resource mpxjResource ) { Project . Resources . Resource . Baseline baseline = m_factory . createProjectResourcesResourceBaseline ( ) ; boolean populated = false ; Number cost = mpxjResource . getBaselineCost ( ) ; if ( cost != null && cost . intValue ( ) != 0 ) { populated = true ; baseline . setCost ( DatatypeConverter . printCurrency ( cost ) ) ; } Duration work = mpxjResource . getBaselineWork ( ) ; if ( work != null && work . getDuration ( ) != 0 ) { populated = true ; baseline . setWork ( DatatypeConverter . printDuration ( this , work ) ) ; } if ( populated ) { xmlResource . getBaseline ( ) . add ( baseline ) ; baseline . setNumber ( BigInteger . ZERO ) ; } for ( int loop = 1 ; loop <= 10 ; loop ++ ) { baseline = m_factory . createProjectResourcesResourceBaseline ( ) ; populated = false ; cost = mpxjResource . getBaselineCost ( loop ) ; if ( cost != null && cost . intValue ( ) != 0 ) { populated = true ; baseline . setCost ( DatatypeConverter . printCurrency ( cost ) ) ; } work = mpxjResource . getBaselineWork ( loop ) ; if ( work != null && work . getDuration ( ) != 0 ) { populated = true ; baseline . setWork ( DatatypeConverter . printDuration ( this , work ) ) ; } if ( populated ) { xmlResource . getBaseline ( ) . add ( baseline ) ; baseline . setNumber ( BigInteger . valueOf ( loop ) ) ; } } } | Writes resource baseline data . | 381 | 6 |
143,512 | private void writeResourceExtendedAttributes ( Project . Resources . Resource xml , Resource mpx ) { Project . Resources . Resource . ExtendedAttribute attrib ; List < Project . Resources . Resource . ExtendedAttribute > extendedAttributes = xml . getExtendedAttribute ( ) ; for ( ResourceField mpxFieldID : getAllResourceExtendedAttributes ( ) ) { Object value = mpx . getCachedValue ( mpxFieldID ) ; if ( FieldTypeHelper . valueIsNotDefault ( mpxFieldID , value ) ) { m_extendedAttributesInUse . add ( mpxFieldID ) ; Integer xmlFieldID = Integer . valueOf ( MPPResourceField . getID ( mpxFieldID ) | MPPResourceField . RESOURCE_FIELD_BASE ) ; attrib = m_factory . createProjectResourcesResourceExtendedAttribute ( ) ; extendedAttributes . add ( attrib ) ; attrib . setFieldID ( xmlFieldID . toString ( ) ) ; attrib . setValue ( DatatypeConverter . printExtendedAttribute ( this , value , mpxFieldID . getDataType ( ) ) ) ; attrib . setDurationFormat ( printExtendedAttributeDurationFormat ( value ) ) ; } } } | This method writes extended attribute data for a resource . | 266 | 10 |
143,513 | private void writeCostRateTables ( Project . Resources . Resource xml , Resource mpx ) { //Rates rates = m_factory.createProjectResourcesResourceRates(); //xml.setRates(rates); //List<Project.Resources.Resource.Rates.Rate> ratesList = rates.getRate(); List < Project . Resources . Resource . Rates . Rate > ratesList = null ; for ( int tableIndex = 0 ; tableIndex < 5 ; tableIndex ++ ) { CostRateTable table = mpx . getCostRateTable ( tableIndex ) ; if ( table != null ) { Date from = DateHelper . FIRST_DATE ; for ( CostRateTableEntry entry : table ) { if ( costRateTableWriteRequired ( entry , from ) ) { if ( ratesList == null ) { Rates rates = m_factory . createProjectResourcesResourceRates ( ) ; xml . setRates ( rates ) ; ratesList = rates . getRate ( ) ; } Project . Resources . Resource . Rates . Rate rate = m_factory . createProjectResourcesResourceRatesRate ( ) ; ratesList . add ( rate ) ; rate . setCostPerUse ( DatatypeConverter . printCurrency ( entry . getCostPerUse ( ) ) ) ; rate . setOvertimeRate ( DatatypeConverter . printRate ( entry . getOvertimeRate ( ) ) ) ; rate . setOvertimeRateFormat ( DatatypeConverter . printTimeUnit ( entry . getOvertimeRateFormat ( ) ) ) ; rate . setRatesFrom ( from ) ; from = entry . getEndDate ( ) ; rate . setRatesTo ( from ) ; rate . setRateTable ( BigInteger . valueOf ( tableIndex ) ) ; rate . setStandardRate ( DatatypeConverter . printRate ( entry . getStandardRate ( ) ) ) ; rate . setStandardRateFormat ( DatatypeConverter . printTimeUnit ( entry . getStandardRateFormat ( ) ) ) ; } } } } } | Writes a resource s cost rate tables . | 441 | 9 |
143,514 | private boolean costRateTableWriteRequired ( CostRateTableEntry entry , Date from ) { boolean fromDate = ( DateHelper . compare ( from , DateHelper . FIRST_DATE ) > 0 ) ; boolean toDate = ( DateHelper . compare ( entry . getEndDate ( ) , DateHelper . LAST_DATE ) > 0 ) ; boolean costPerUse = ( NumberHelper . getDouble ( entry . getCostPerUse ( ) ) != 0 ) ; boolean overtimeRate = ( entry . getOvertimeRate ( ) != null && entry . getOvertimeRate ( ) . getAmount ( ) != 0 ) ; boolean standardRate = ( entry . getStandardRate ( ) != null && entry . getStandardRate ( ) . getAmount ( ) != 0 ) ; return ( fromDate || toDate || costPerUse || overtimeRate || standardRate ) ; } | This method determines whether the cost rate table should be written . A default cost rate table should not be written to the file . | 183 | 25 |
143,515 | private void writeAvailability ( Project . Resources . Resource xml , Resource mpx ) { AvailabilityPeriods periods = m_factory . createProjectResourcesResourceAvailabilityPeriods ( ) ; xml . setAvailabilityPeriods ( periods ) ; List < AvailabilityPeriod > list = periods . getAvailabilityPeriod ( ) ; for ( Availability availability : mpx . getAvailability ( ) ) { AvailabilityPeriod period = m_factory . createProjectResourcesResourceAvailabilityPeriodsAvailabilityPeriod ( ) ; list . add ( period ) ; DateRange range = availability . getRange ( ) ; period . setAvailableFrom ( range . getStart ( ) ) ; period . setAvailableTo ( range . getEnd ( ) ) ; period . setAvailableUnits ( DatatypeConverter . printUnits ( availability . getUnits ( ) ) ) ; } } | This method writes a resource s availability table . | 181 | 9 |
143,516 | private void writeTasks ( Project project ) { Project . Tasks tasks = m_factory . createProjectTasks ( ) ; project . setTasks ( tasks ) ; List < Project . Tasks . Task > list = tasks . getTask ( ) ; for ( Task task : m_projectFile . getTasks ( ) ) { list . add ( writeTask ( task ) ) ; } } | This method writes task data to an MSPDI file . | 85 | 12 |
143,517 | private void writeTaskBaselines ( Project . Tasks . Task xmlTask , Task mpxjTask ) { Project . Tasks . Task . Baseline baseline = m_factory . createProjectTasksTaskBaseline ( ) ; boolean populated = false ; Number cost = mpxjTask . getBaselineCost ( ) ; if ( cost != null && cost . intValue ( ) != 0 ) { populated = true ; baseline . setCost ( DatatypeConverter . printCurrency ( cost ) ) ; } Duration duration = mpxjTask . getBaselineDuration ( ) ; if ( duration != null && duration . getDuration ( ) != 0 ) { populated = true ; baseline . setDuration ( DatatypeConverter . printDuration ( this , duration ) ) ; baseline . setDurationFormat ( DatatypeConverter . printDurationTimeUnits ( duration , false ) ) ; } Date date = mpxjTask . getBaselineFinish ( ) ; if ( date != null ) { populated = true ; baseline . setFinish ( date ) ; } date = mpxjTask . getBaselineStart ( ) ; if ( date != null ) { populated = true ; baseline . setStart ( date ) ; } duration = mpxjTask . getBaselineWork ( ) ; if ( duration != null && duration . getDuration ( ) != 0 ) { populated = true ; baseline . setWork ( DatatypeConverter . printDuration ( this , duration ) ) ; } if ( populated ) { baseline . setNumber ( BigInteger . ZERO ) ; xmlTask . getBaseline ( ) . add ( baseline ) ; } for ( int loop = 1 ; loop <= 10 ; loop ++ ) { baseline = m_factory . createProjectTasksTaskBaseline ( ) ; populated = false ; cost = mpxjTask . getBaselineCost ( loop ) ; if ( cost != null && cost . intValue ( ) != 0 ) { populated = true ; baseline . setCost ( DatatypeConverter . printCurrency ( cost ) ) ; } duration = mpxjTask . getBaselineDuration ( loop ) ; if ( duration != null && duration . getDuration ( ) != 0 ) { populated = true ; baseline . setDuration ( DatatypeConverter . printDuration ( this , duration ) ) ; baseline . setDurationFormat ( DatatypeConverter . printDurationTimeUnits ( duration , false ) ) ; } date = mpxjTask . getBaselineFinish ( loop ) ; if ( date != null ) { populated = true ; baseline . setFinish ( date ) ; } date = mpxjTask . getBaselineStart ( loop ) ; if ( date != null ) { populated = true ; baseline . setStart ( date ) ; } duration = mpxjTask . getBaselineWork ( loop ) ; if ( duration != null && duration . getDuration ( ) != 0 ) { populated = true ; baseline . setWork ( DatatypeConverter . printDuration ( this , duration ) ) ; } if ( populated ) { baseline . setNumber ( BigInteger . valueOf ( loop ) ) ; xmlTask . getBaseline ( ) . add ( baseline ) ; } } } | Writes task baseline data . | 687 | 6 |
143,518 | private void writeTaskExtendedAttributes ( Project . Tasks . Task xml , Task mpx ) { Project . Tasks . Task . ExtendedAttribute attrib ; List < Project . Tasks . Task . ExtendedAttribute > extendedAttributes = xml . getExtendedAttribute ( ) ; for ( TaskField mpxFieldID : getAllTaskExtendedAttributes ( ) ) { Object value = mpx . getCachedValue ( mpxFieldID ) ; if ( FieldTypeHelper . valueIsNotDefault ( mpxFieldID , value ) ) { m_extendedAttributesInUse . add ( mpxFieldID ) ; Integer xmlFieldID = Integer . valueOf ( MPPTaskField . getID ( mpxFieldID ) | MPPTaskField . TASK_FIELD_BASE ) ; attrib = m_factory . createProjectTasksTaskExtendedAttribute ( ) ; extendedAttributes . add ( attrib ) ; attrib . setFieldID ( xmlFieldID . toString ( ) ) ; attrib . setValue ( DatatypeConverter . printExtendedAttribute ( this , value , mpxFieldID . getDataType ( ) ) ) ; attrib . setDurationFormat ( printExtendedAttributeDurationFormat ( value ) ) ; } } } | This method writes extended attribute data for a task . | 269 | 10 |
143,519 | private BigInteger printExtendedAttributeDurationFormat ( Object value ) { BigInteger result = null ; if ( value instanceof Duration ) { result = DatatypeConverter . printDurationTimeUnits ( ( ( Duration ) value ) . getUnits ( ) , false ) ; } return ( result ) ; } | Converts a duration to duration time units . | 66 | 9 |
143,520 | private BigInteger getTaskCalendarID ( Task mpx ) { BigInteger result = null ; ProjectCalendar cal = mpx . getCalendar ( ) ; if ( cal != null ) { result = NumberHelper . getBigInteger ( cal . getUniqueID ( ) ) ; } else { result = NULL_CALENDAR_ID ; } return ( result ) ; } | This method retrieves the UID for a calendar associated with a task . | 80 | 14 |
143,521 | private void writePredecessors ( Project . Tasks . Task xml , Task mpx ) { List < Project . Tasks . Task . PredecessorLink > list = xml . getPredecessorLink ( ) ; List < Relation > predecessors = mpx . getPredecessors ( ) ; for ( Relation rel : predecessors ) { Integer taskUniqueID = rel . getTargetTask ( ) . getUniqueID ( ) ; list . add ( writePredecessor ( taskUniqueID , rel . getType ( ) , rel . getLag ( ) ) ) ; m_eventManager . fireRelationWrittenEvent ( rel ) ; } } | This method writes predecessor data to an MSPDI 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 . | 137 | 96 |
143,522 | private Project . Tasks . Task . PredecessorLink writePredecessor ( Integer taskID , RelationType type , Duration lag ) { Project . Tasks . Task . PredecessorLink link = m_factory . createProjectTasksTaskPredecessorLink ( ) ; link . setPredecessorUID ( NumberHelper . getBigInteger ( taskID ) ) ; link . setType ( BigInteger . valueOf ( type . getValue ( ) ) ) ; link . setCrossProject ( Boolean . FALSE ) ; // SF-300: required to keep P6 happy when importing MSPDI files if ( lag != null && lag . getDuration ( ) != 0 ) { double linkLag = lag . getDuration ( ) ; if ( lag . getUnits ( ) != TimeUnit . PERCENT && lag . getUnits ( ) != TimeUnit . ELAPSED_PERCENT ) { linkLag = 10.0 * Duration . convertUnits ( linkLag , lag . getUnits ( ) , TimeUnit . MINUTES , m_projectFile . getProjectProperties ( ) ) . getDuration ( ) ; } link . setLinkLag ( BigInteger . valueOf ( ( long ) linkLag ) ) ; link . setLagFormat ( DatatypeConverter . printDurationTimeUnits ( lag . getUnits ( ) , false ) ) ; } else { // SF-329: default required to keep Powerproject happy when importing MSPDI files link . setLinkLag ( BIGINTEGER_ZERO ) ; link . setLagFormat ( DatatypeConverter . printDurationTimeUnits ( m_projectFile . getProjectProperties ( ) . getDefaultDurationUnits ( ) , false ) ) ; } return ( link ) ; } | This method writes a single predecessor link to the MSPDI file . | 385 | 14 |
143,523 | private void writeAssignments ( Project project ) { Project . Assignments assignments = m_factory . createProjectAssignments ( ) ; project . setAssignments ( assignments ) ; List < Project . Assignments . Assignment > list = assignments . getAssignment ( ) ; for ( ResourceAssignment assignment : m_projectFile . getResourceAssignments ( ) ) { list . add ( writeAssignment ( assignment ) ) ; } // // Check to see if we have any tasks that have a percent complete value // but do not have resource assignments. If any exist, then we must // write a dummy resource assignment record to ensure that the MSPDI // file shows the correct percent complete amount for the task. // ProjectConfig config = m_projectFile . getProjectConfig ( ) ; boolean autoUniqueID = config . getAutoAssignmentUniqueID ( ) ; if ( ! autoUniqueID ) { config . setAutoAssignmentUniqueID ( true ) ; } for ( Task task : m_projectFile . getTasks ( ) ) { double percentComplete = NumberHelper . getDouble ( task . getPercentageComplete ( ) ) ; if ( percentComplete != 0 && task . getResourceAssignments ( ) . isEmpty ( ) == true ) { ResourceAssignment dummy = new ResourceAssignment ( m_projectFile , task ) ; Duration duration = task . getDuration ( ) ; if ( duration == null ) { duration = Duration . getInstance ( 0 , TimeUnit . HOURS ) ; } double durationValue = duration . getDuration ( ) ; TimeUnit durationUnits = duration . getUnits ( ) ; double actualWork = ( durationValue * percentComplete ) / 100 ; double remainingWork = durationValue - actualWork ; dummy . setResourceUniqueID ( NULL_RESOURCE_ID ) ; dummy . setWork ( duration ) ; dummy . setActualWork ( Duration . getInstance ( actualWork , durationUnits ) ) ; dummy . setRemainingWork ( Duration . getInstance ( remainingWork , durationUnits ) ) ; // Without this, MS Project will mark a 100% complete milestone as 99% complete if ( percentComplete == 100 && duration . getDuration ( ) == 0 ) { dummy . setActualFinish ( task . getActualStart ( ) ) ; } list . add ( writeAssignment ( dummy ) ) ; } } config . setAutoAssignmentUniqueID ( autoUniqueID ) ; } | This method writes assignment data to an MSPDI file . | 514 | 12 |
143,524 | private void writeAssignmentBaselines ( Project . Assignments . Assignment xml , ResourceAssignment mpxj ) { Project . Assignments . Assignment . Baseline baseline = m_factory . createProjectAssignmentsAssignmentBaseline ( ) ; boolean populated = false ; Number cost = mpxj . getBaselineCost ( ) ; if ( cost != null && cost . intValue ( ) != 0 ) { populated = true ; baseline . setCost ( DatatypeConverter . printExtendedAttributeCurrency ( cost ) ) ; } Date date = mpxj . getBaselineFinish ( ) ; if ( date != null ) { populated = true ; baseline . setFinish ( DatatypeConverter . printExtendedAttributeDate ( date ) ) ; } date = mpxj . getBaselineStart ( ) ; if ( date != null ) { populated = true ; baseline . setStart ( DatatypeConverter . printExtendedAttributeDate ( date ) ) ; } Duration duration = mpxj . getBaselineWork ( ) ; if ( duration != null && duration . getDuration ( ) != 0 ) { populated = true ; baseline . setWork ( DatatypeConverter . printDuration ( this , duration ) ) ; } if ( populated ) { baseline . setNumber ( "0" ) ; xml . getBaseline ( ) . add ( baseline ) ; } for ( int loop = 1 ; loop <= 10 ; loop ++ ) { baseline = m_factory . createProjectAssignmentsAssignmentBaseline ( ) ; populated = false ; cost = mpxj . getBaselineCost ( loop ) ; if ( cost != null && cost . intValue ( ) != 0 ) { populated = true ; baseline . setCost ( DatatypeConverter . printExtendedAttributeCurrency ( cost ) ) ; } date = mpxj . getBaselineFinish ( loop ) ; if ( date != null ) { populated = true ; baseline . setFinish ( DatatypeConverter . printExtendedAttributeDate ( date ) ) ; } date = mpxj . getBaselineStart ( loop ) ; if ( date != null ) { populated = true ; baseline . setStart ( DatatypeConverter . printExtendedAttributeDate ( date ) ) ; } duration = mpxj . getBaselineWork ( loop ) ; if ( duration != null && duration . getDuration ( ) != 0 ) { populated = true ; baseline . setWork ( DatatypeConverter . printDuration ( this , duration ) ) ; } if ( populated ) { baseline . setNumber ( Integer . toString ( loop ) ) ; xml . getBaseline ( ) . add ( baseline ) ; } } } | Writes assignment baseline data . | 580 | 6 |
143,525 | private void writeAssignmentExtendedAttributes ( Project . Assignments . Assignment xml , ResourceAssignment mpx ) { Project . Assignments . Assignment . ExtendedAttribute attrib ; List < Project . Assignments . Assignment . ExtendedAttribute > extendedAttributes = xml . getExtendedAttribute ( ) ; for ( AssignmentField mpxFieldID : getAllAssignmentExtendedAttributes ( ) ) { Object value = mpx . getCachedValue ( mpxFieldID ) ; if ( FieldTypeHelper . valueIsNotDefault ( mpxFieldID , value ) ) { m_extendedAttributesInUse . add ( mpxFieldID ) ; Integer xmlFieldID = Integer . valueOf ( MPPAssignmentField . getID ( mpxFieldID ) | MPPAssignmentField . ASSIGNMENT_FIELD_BASE ) ; attrib = m_factory . createProjectAssignmentsAssignmentExtendedAttribute ( ) ; extendedAttributes . add ( attrib ) ; attrib . setFieldID ( xmlFieldID . toString ( ) ) ; attrib . setValue ( DatatypeConverter . printExtendedAttribute ( this , value , mpxFieldID . getDataType ( ) ) ) ; attrib . setDurationFormat ( printExtendedAttributeDurationFormat ( value ) ) ; } } } | This method writes extended attribute data for an assignment . | 280 | 10 |
143,526 | private void writeAssignmentTimephasedData ( ResourceAssignment mpx , Project . Assignments . Assignment xml ) { if ( m_writeTimphasedData && mpx . getHasTimephasedData ( ) ) { List < TimephasedDataType > list = xml . getTimephasedData ( ) ; ProjectCalendar calendar = mpx . getCalendar ( ) ; BigInteger assignmentID = xml . getUID ( ) ; List < TimephasedWork > complete = mpx . getTimephasedActualWork ( ) ; List < TimephasedWork > planned = mpx . getTimephasedWork ( ) ; if ( m_splitTimephasedAsDays ) { TimephasedWork lastComplete = null ; if ( complete != null && ! complete . isEmpty ( ) ) { lastComplete = complete . get ( complete . size ( ) - 1 ) ; } TimephasedWork firstPlanned = null ; if ( planned != null && ! planned . isEmpty ( ) ) { firstPlanned = planned . get ( 0 ) ; } if ( planned != null ) { planned = splitDays ( calendar , mpx . getTimephasedWork ( ) , null , lastComplete ) ; } if ( complete != null ) { complete = splitDays ( calendar , complete , firstPlanned , null ) ; } } if ( planned != null ) { writeAssignmentTimephasedData ( assignmentID , list , planned , 1 ) ; } if ( complete != null ) { writeAssignmentTimephasedData ( assignmentID , list , complete , 2 ) ; } } } | Writes the timephased data for a resource assignment . | 338 | 12 |
143,527 | private void writeAssignmentTimephasedData ( BigInteger assignmentID , List < TimephasedDataType > list , List < TimephasedWork > data , int type ) { for ( TimephasedWork mpx : data ) { TimephasedDataType xml = m_factory . createTimephasedDataType ( ) ; list . add ( xml ) ; xml . setStart ( mpx . getStart ( ) ) ; xml . setFinish ( mpx . getFinish ( ) ) ; xml . setType ( BigInteger . valueOf ( type ) ) ; xml . setUID ( assignmentID ) ; xml . setUnit ( DatatypeConverter . printDurationTimeUnits ( mpx . getTotalAmount ( ) , false ) ) ; xml . setValue ( DatatypeConverter . printDuration ( this , mpx . getTotalAmount ( ) ) ) ; } } | Writes a list of timephased data to the MSPDI file . | 191 | 16 |
143,528 | private List < AssignmentField > getAllAssignmentExtendedAttributes ( ) { ArrayList < AssignmentField > result = new ArrayList < AssignmentField > ( ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . CUSTOM_COST ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . CUSTOM_DATE ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . CUSTOM_DURATION ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . ENTERPRISE_COST ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . ENTERPRISE_DATE ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . ENTERPRISE_DURATION ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . ENTERPRISE_FLAG ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . ENTERPRISE_NUMBER ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . ENTERPRISE_RESOURCE_MULTI_VALUE ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . ENTERPRISE_RESOURCE_OUTLINE_CODE ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . ENTERPRISE_TEXT ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . CUSTOM_FINISH ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . CUSTOM_FLAG ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . CUSTOM_NUMBER ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . CUSTOM_START ) ) ; result . addAll ( Arrays . asList ( AssignmentFieldLists . CUSTOM_TEXT ) ) ; return result ; } | Retrieve list of assignment extended attributes . | 448 | 8 |
143,529 | private List < TaskField > getAllTaskExtendedAttributes ( ) { ArrayList < TaskField > result = new ArrayList < TaskField > ( ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_TEXT ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_START ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_FINISH ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_COST ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_DATE ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_FLAG ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_NUMBER ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_DURATION ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . CUSTOM_OUTLINE_CODE ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . ENTERPRISE_COST ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . ENTERPRISE_DATE ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . ENTERPRISE_DURATION ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . ENTERPRISE_FLAG ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . ENTERPRISE_NUMBER ) ) ; result . addAll ( Arrays . asList ( TaskFieldLists . ENTERPRISE_TEXT ) ) ; return result ; } | Retrieve list of task extended attributes . | 413 | 8 |
143,530 | private List < ResourceField > getAllResourceExtendedAttributes ( ) { ArrayList < ResourceField > result = new ArrayList < ResourceField > ( ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_TEXT ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_START ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_FINISH ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_COST ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_DATE ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_FLAG ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_NUMBER ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_DURATION ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . CUSTOM_OUTLINE_CODE ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . ENTERPRISE_COST ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . ENTERPRISE_DATE ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . ENTERPRISE_DURATION ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . ENTERPRISE_FLAG ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . ENTERPRISE_NUMBER ) ) ; result . addAll ( Arrays . asList ( ResourceFieldLists . ENTERPRISE_TEXT ) ) ; return result ; } | Retrieve list of resource extended attributes . | 413 | 8 |
143,531 | private void processUDF ( UDFTypeType udf ) { FieldTypeClass fieldType = FIELD_TYPE_MAP . get ( udf . getSubjectArea ( ) ) ; if ( fieldType != null ) { UserFieldDataType dataType = UserFieldDataType . getInstanceFromXmlName ( udf . getDataType ( ) ) ; String name = udf . getTitle ( ) ; FieldType field = addUserDefinedField ( fieldType , dataType , name ) ; if ( field != null ) { m_fieldTypeMap . put ( udf . getObjectId ( ) , field ) ; } } } | Process an individual UDF . | 136 | 6 |
143,532 | private FieldType addUserDefinedField ( FieldTypeClass fieldType , UserFieldDataType dataType , String name ) { FieldType field = null ; try { switch ( fieldType ) { case TASK : { do { field = m_taskUdfCounters . nextField ( TaskField . class , dataType ) ; } while ( RESERVED_TASK_FIELDS . contains ( field ) ) ; m_projectFile . getCustomFields ( ) . getCustomField ( field ) . setAlias ( name ) ; break ; } case RESOURCE : { field = m_resourceUdfCounters . nextField ( ResourceField . class , dataType ) ; m_projectFile . getCustomFields ( ) . getCustomField ( field ) . setAlias ( name ) ; break ; } case ASSIGNMENT : { field = m_assignmentUdfCounters . nextField ( AssignmentField . class , dataType ) ; m_projectFile . getCustomFields ( ) . getCustomField ( field ) . setAlias ( name ) ; break ; } default : { break ; } } } catch ( Exception ex ) { // // SF#227: If we get an exception thrown here... it's likely that // we've run out of user defined fields, for example // there are only 30 TEXT fields. We'll ignore this: the user // defined field won't be mapped to an alias, so we'll // ignore it when we read in the values. // } return field ; } | Map the Primavera UDF to a custom field . | 321 | 13 |
143,533 | private Double zeroIsNull ( Double value ) { if ( value != null && value . doubleValue ( ) == 0 ) { value = null ; } return value ; } | Render a zero Double as null . | 35 | 7 |
143,534 | private Duration getDuration ( Double duration ) { Duration result = null ; if ( duration != null ) { result = Duration . getInstance ( NumberHelper . getDouble ( duration ) , TimeUnit . HOURS ) ; } return result ; } | Extracts a duration from a JAXBElement instance . | 49 | 13 |
143,535 | private void readUDFTypes ( FieldContainer mpxj , List < UDFAssignmentType > udfs ) { for ( UDFAssignmentType udf : udfs ) { FieldType fieldType = m_fieldTypeMap . get ( Integer . valueOf ( udf . getTypeObjectId ( ) ) ) ; if ( fieldType != null ) { mpxj . set ( fieldType , getUdfValue ( udf ) ) ; } } } | Process UDFs for a specific object . | 101 | 9 |
143,536 | private Object getUdfValue ( UDFAssignmentType udf ) { if ( udf . getCostValue ( ) != null ) { return udf . getCostValue ( ) ; } if ( udf . getDoubleValue ( ) != null ) { return udf . getDoubleValue ( ) ; } if ( udf . getFinishDateValue ( ) != null ) { return udf . getFinishDateValue ( ) ; } if ( udf . getIndicatorValue ( ) != null ) { return udf . getIndicatorValue ( ) ; } if ( udf . getIntegerValue ( ) != null ) { return udf . getIntegerValue ( ) ; } if ( udf . getStartDateValue ( ) != null ) { return udf . getStartDateValue ( ) ; } if ( udf . getTextValue ( ) != null ) { return udf . getTextValue ( ) ; } return null ; } | Retrieve the value of a UDF . | 201 | 9 |
143,537 | private Integer mapTaskID ( Integer id ) { Integer mappedID = m_clashMap . get ( id ) ; if ( mappedID == null ) { mappedID = id ; } return ( mappedID ) ; } | Deals with the case where we have had to map a task ID to a new value . | 46 | 19 |
143,538 | public int evaluate ( FieldContainer container ) { // // First step - determine the list of criteria we are should use // List < GraphicalIndicatorCriteria > criteria ; if ( container instanceof Task ) { Task task = ( Task ) container ; if ( NumberHelper . getInt ( task . getUniqueID ( ) ) == 0 ) { if ( m_projectSummaryInheritsFromSummaryRows == false ) { criteria = m_projectSummaryCriteria ; } else { if ( m_summaryRowsInheritFromNonSummaryRows == false ) { criteria = m_summaryRowCriteria ; } else { criteria = m_nonSummaryRowCriteria ; } } } else { if ( task . getSummary ( ) == true ) { if ( m_summaryRowsInheritFromNonSummaryRows == false ) { criteria = m_summaryRowCriteria ; } else { criteria = m_nonSummaryRowCriteria ; } } else { criteria = m_nonSummaryRowCriteria ; } } } else { // It is possible to have a resource summary row, but at the moment // I can't see how you can determine this. criteria = m_nonSummaryRowCriteria ; } // // Now we have the criteria, evaluate each one until we get a result // int result = - 1 ; for ( GraphicalIndicatorCriteria gic : criteria ) { result = gic . evaluate ( container ) ; if ( result != - 1 ) { break ; } } // // If we still don't have a result at the end, return the // default value, which is 0 // if ( result == - 1 ) { result = 0 ; } return ( result ) ; } | This method evaluates a if a graphical indicator should be displayed given a set of Task or Resource data . The method will return - 1 if no indicator should be displayed . | 357 | 33 |
143,539 | private void writeFileCreationRecord ( ) throws IOException { ProjectProperties properties = m_projectFile . getProjectProperties ( ) ; m_buffer . setLength ( 0 ) ; m_buffer . append ( "MPX" ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( properties . getMpxProgramName ( ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( properties . getMpxFileVersion ( ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( properties . getMpxCodePage ( ) ) ; m_buffer . append ( MPXConstants . EOL ) ; m_writer . write ( m_buffer . toString ( ) ) ; } | Write file creation record . | 174 | 5 |
143,540 | private void writeCalendar ( ProjectCalendar record ) throws IOException { // // Test used to ensure that we don't write the default calendar used for the "Unassigned" resource // if ( record . getParent ( ) == null || record . getResource ( ) != null ) { m_buffer . setLength ( 0 ) ; if ( record . getParent ( ) == null ) { m_buffer . append ( MPXConstants . BASE_CALENDAR_RECORD_NUMBER ) ; m_buffer . append ( m_delimiter ) ; if ( record . getName ( ) != null ) { m_buffer . append ( record . getName ( ) ) ; } } else { m_buffer . append ( MPXConstants . RESOURCE_CALENDAR_RECORD_NUMBER ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( record . getParent ( ) . getName ( ) ) ; } for ( DayType day : record . getDays ( ) ) { if ( day == null ) { day = DayType . DEFAULT ; } m_buffer . append ( m_delimiter ) ; m_buffer . append ( day . getValue ( ) ) ; } m_buffer . append ( MPXConstants . EOL ) ; m_writer . write ( m_buffer . toString ( ) ) ; ProjectCalendarHours [ ] hours = record . getHours ( ) ; for ( int loop = 0 ; loop < hours . length ; loop ++ ) { if ( hours [ loop ] != null ) { writeCalendarHours ( record , hours [ loop ] ) ; } } if ( ! record . getCalendarExceptions ( ) . isEmpty ( ) ) { // // A quirk of MS Project is that these exceptions must be // in date order in the file, otherwise they are ignored. // The getCalendarExceptions method now guarantees that // the exceptions list is sorted when retrieved. // for ( ProjectCalendarException ex : record . getCalendarExceptions ( ) ) { writeCalendarException ( record , ex ) ; } } m_eventManager . fireCalendarWrittenEvent ( record ) ; } } | Write a calendar . | 469 | 4 |
143,541 | private void writeCalendarHours ( ProjectCalendar parentCalendar , ProjectCalendarHours record ) throws IOException { m_buffer . setLength ( 0 ) ; int recordNumber ; if ( ! parentCalendar . isDerived ( ) ) { recordNumber = MPXConstants . BASE_CALENDAR_HOURS_RECORD_NUMBER ; } else { recordNumber = MPXConstants . RESOURCE_CALENDAR_HOURS_RECORD_NUMBER ; } DateRange range1 = record . getRange ( 0 ) ; if ( range1 == null ) { range1 = DateRange . EMPTY_RANGE ; } DateRange range2 = record . getRange ( 1 ) ; if ( range2 == null ) { range2 = DateRange . EMPTY_RANGE ; } DateRange range3 = record . getRange ( 2 ) ; if ( range3 == null ) { range3 = DateRange . EMPTY_RANGE ; } m_buffer . append ( recordNumber ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( record . getDay ( ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatTime ( range1 . getStart ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatTime ( range1 . getEnd ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatTime ( range2 . getStart ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatTime ( range2 . getEnd ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatTime ( range3 . getStart ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatTime ( range3 . getEnd ( ) ) ) ) ; stripTrailingDelimiters ( m_buffer ) ; m_buffer . append ( MPXConstants . EOL ) ; m_writer . write ( m_buffer . toString ( ) ) ; } | Write calendar hours . | 502 | 4 |
143,542 | private void writeResource ( Resource record ) throws IOException { m_buffer . setLength ( 0 ) ; // // Write the resource record // int [ ] fields = m_resourceModel . getModel ( ) ; m_buffer . append ( MPXConstants . RESOURCE_RECORD_NUMBER ) ; for ( int loop = 0 ; loop < fields . length ; loop ++ ) { int mpxFieldType = fields [ loop ] ; if ( mpxFieldType == - 1 ) { break ; } ResourceField resourceField = MPXResourceField . getMpxjField ( mpxFieldType ) ; Object value = record . getCachedValue ( resourceField ) ; value = formatType ( resourceField . getDataType ( ) , value ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( value ) ) ; } stripTrailingDelimiters ( m_buffer ) ; m_buffer . append ( MPXConstants . EOL ) ; m_writer . write ( m_buffer . toString ( ) ) ; // // Write the resource notes // String notes = record . getNotes ( ) ; if ( notes . length ( ) != 0 ) { writeNotes ( MPXConstants . RESOURCE_NOTES_RECORD_NUMBER , notes ) ; } // // Write the resource calendar // if ( record . getResourceCalendar ( ) != null ) { writeCalendar ( record . getResourceCalendar ( ) ) ; } m_eventManager . fireResourceWrittenEvent ( record ) ; } | Write a resource . | 332 | 4 |
143,543 | private void writeNotes ( int recordNumber , String text ) throws IOException { m_buffer . setLength ( 0 ) ; m_buffer . append ( recordNumber ) ; m_buffer . append ( m_delimiter ) ; if ( text != null ) { String note = stripLineBreaks ( text , MPXConstants . EOL_PLACEHOLDER_STRING ) ; boolean quote = ( note . indexOf ( m_delimiter ) != - 1 || note . indexOf ( ' ' ) != - 1 ) ; int length = note . length ( ) ; char c ; if ( quote == true ) { m_buffer . append ( ' ' ) ; } for ( int loop = 0 ; loop < length ; loop ++ ) { c = note . charAt ( loop ) ; switch ( c ) { case ' ' : { m_buffer . append ( "\"\"" ) ; break ; } default : { m_buffer . append ( c ) ; break ; } } } if ( quote == true ) { m_buffer . append ( ' ' ) ; } } m_buffer . append ( MPXConstants . EOL ) ; m_writer . write ( m_buffer . toString ( ) ) ; } | Write notes . | 264 | 3 |
143,544 | private void writeResourceAssignment ( ResourceAssignment record ) throws IOException { m_buffer . setLength ( 0 ) ; m_buffer . append ( MPXConstants . RESOURCE_ASSIGNMENT_RECORD_NUMBER ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( formatResource ( record . getResource ( ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatUnits ( record . getUnits ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDuration ( record . getWork ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDuration ( record . getBaselineWork ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDuration ( record . getActualWork ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDuration ( record . getOvertimeWork ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatCurrency ( record . getCost ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatCurrency ( record . getBaselineCost ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatCurrency ( record . getActualCost ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDateTime ( record . getStart ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDateTime ( record . getFinish ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDuration ( record . getDelay ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( record . getResourceUniqueID ( ) ) ) ; stripTrailingDelimiters ( m_buffer ) ; m_buffer . append ( MPXConstants . EOL ) ; m_writer . write ( m_buffer . toString ( ) ) ; ResourceAssignmentWorkgroupFields workgroup = record . getWorkgroupAssignment ( ) ; if ( workgroup == null ) { workgroup = ResourceAssignmentWorkgroupFields . EMPTY ; } writeResourceAssignmentWorkgroupFields ( workgroup ) ; m_eventManager . fireAssignmentWrittenEvent ( record ) ; } | Write resource assignment . | 622 | 4 |
143,545 | private void writeResourceAssignmentWorkgroupFields ( ResourceAssignmentWorkgroupFields record ) throws IOException { m_buffer . setLength ( 0 ) ; m_buffer . append ( MPXConstants . RESOURCE_ASSIGNMENT_WORKGROUP_FIELDS_RECORD_NUMBER ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( record . getMessageUniqueID ( ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( record . getConfirmed ( ) ? "1" : "0" ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( record . getResponsePending ( ) ? "1" : "0" ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDateTimeNull ( record . getUpdateStart ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( formatDateTimeNull ( record . getUpdateFinish ( ) ) ) ) ; m_buffer . append ( m_delimiter ) ; m_buffer . append ( format ( record . getScheduleID ( ) ) ) ; stripTrailingDelimiters ( m_buffer ) ; m_buffer . append ( MPXConstants . EOL ) ; m_writer . write ( m_buffer . toString ( ) ) ; } | Write resource assignment workgroup . | 322 | 6 |
143,546 | private void writeTasks ( List < Task > tasks ) throws IOException { for ( Task task : tasks ) { writeTask ( task ) ; writeTasks ( task . getChildTasks ( ) ) ; } } | Recursively write tasks . | 46 | 6 |
143,547 | private Integer getIntegerTimeInMinutes ( Date date ) { Integer result = null ; if ( date != null ) { Calendar cal = DateHelper . popCalendar ( date ) ; int time = cal . get ( Calendar . HOUR_OF_DAY ) * 60 ; time += cal . get ( Calendar . MINUTE ) ; DateHelper . pushCalendar ( cal ) ; result = Integer . valueOf ( time ) ; } return ( result ) ; } | This internal method is used to convert from a Date instance to an integer representing the number of minutes past midnight . | 96 | 22 |
143,548 | private String escapeQuotes ( String value ) { StringBuilder sb = new StringBuilder ( ) ; int length = value . length ( ) ; char c ; sb . append ( ' ' ) ; for ( int index = 0 ; index < length ; index ++ ) { c = value . charAt ( index ) ; sb . append ( c ) ; if ( c == ' ' ) { sb . append ( ' ' ) ; } } sb . append ( ' ' ) ; return ( sb . toString ( ) ) ; } | This method is called when double quotes are found as part of a value . The quotes are escaped by adding a second quote character and the entire value is quoted . | 114 | 32 |
143,549 | private String stripLineBreaks ( String text , String replacement ) { if ( text . indexOf ( ' ' ) != - 1 || text . indexOf ( ' ' ) != - 1 ) { StringBuilder sb = new StringBuilder ( text ) ; int index ; while ( ( index = sb . indexOf ( "\r\n" ) ) != - 1 ) { sb . replace ( index , index + 2 , replacement ) ; } while ( ( index = sb . indexOf ( "\n\r" ) ) != - 1 ) { sb . replace ( index , index + 2 , replacement ) ; } while ( ( index = sb . indexOf ( "\r" ) ) != - 1 ) { sb . replace ( index , index + 1 , replacement ) ; } while ( ( index = sb . indexOf ( "\n" ) ) != - 1 ) { sb . replace ( index , index + 1 , replacement ) ; } text = sb . toString ( ) ; } return ( text ) ; } | This method removes line breaks from a piece of text and replaces them with the supplied text . | 221 | 18 |
143,550 | private String format ( Object o ) { String result ; if ( o == null ) { result = "" ; } else { if ( o instanceof Boolean == true ) { result = LocaleData . getString ( m_locale , ( ( ( Boolean ) o ) . booleanValue ( ) == true ? LocaleData . YES : LocaleData . NO ) ) ; } else { if ( o instanceof Float == true || o instanceof Double == true ) { result = ( m_formats . getDecimalFormat ( ) . format ( ( ( Number ) o ) . doubleValue ( ) ) ) ; } else { if ( o instanceof Day ) { result = Integer . toString ( ( ( Day ) o ) . getValue ( ) ) ; } else { result = o . toString ( ) ; } } } // // At this point there should be no line break characters in // the file. If we find any, replace them with spaces // result = stripLineBreaks ( result , MPXConstants . EOL_PLACEHOLDER_STRING ) ; // // Finally we check to ensure that there are no embedded // quotes or separator characters in the value. If there are, then // we quote the value and escape any existing quote characters. // if ( result . indexOf ( ' ' ) != - 1 ) { result = escapeQuotes ( result ) ; } else { if ( result . indexOf ( m_delimiter ) != - 1 ) { result = ' ' + result + ' ' ; } } } return ( result ) ; } | This method returns the string representation of an object . In most cases this will simply involve calling the normal toString method on the object but a couple of exceptions are handled here . | 332 | 35 |
143,551 | private void stripTrailingDelimiters ( StringBuilder buffer ) { int index = buffer . length ( ) - 1 ; while ( index > 0 && buffer . charAt ( index ) == m_delimiter ) { -- index ; } buffer . setLength ( index + 1 ) ; } | This method removes trailing delimiter characters . | 62 | 8 |
143,552 | private String formatTime ( Date value ) { return ( value == null ? null : m_formats . getTimeFormat ( ) . format ( value ) ) ; } | This method is called to format a time value . | 35 | 10 |
143,553 | private String formatCurrency ( Number value ) { return ( value == null ? null : m_formats . getCurrencyFormat ( ) . format ( value ) ) ; } | This method is called to format a currency value . | 37 | 10 |
143,554 | private String formatUnits ( Number value ) { return ( value == null ? null : m_formats . getUnitsDecimalFormat ( ) . format ( value . doubleValue ( ) / 100 ) ) ; } | This method is called to format a units value . | 46 | 10 |
143,555 | private String formatDateTimeNull ( Date value ) { return ( value == null ? m_formats . getNullText ( ) : m_formats . getDateTimeFormat ( ) . format ( value ) ) ; } | This method is called to format a date . It will return the null text if a null value is supplied . | 47 | 22 |
143,556 | private String formatPercentage ( Number value ) { return ( value == null ? null : m_formats . getPercentageDecimalFormat ( ) . format ( value ) + "%" ) ; } | This method is called to format a percentage value . | 42 | 10 |
143,557 | private String formatAccrueType ( AccrueType type ) { return ( type == null ? null : LocaleData . getStringArray ( m_locale , LocaleData . ACCRUE_TYPES ) [ type . getValue ( ) - 1 ] ) ; } | This method is called to format an accrue type value . | 59 | 12 |
143,558 | private String formatConstraintType ( ConstraintType type ) { return ( type == null ? null : LocaleData . getStringArray ( m_locale , LocaleData . CONSTRAINT_TYPES ) [ type . getValue ( ) ] ) ; } | This method is called to format a constraint type . | 60 | 10 |
143,559 | private String formatDuration ( Object value ) { String result = null ; if ( value instanceof Duration ) { Duration duration = ( Duration ) value ; result = m_formats . getDurationDecimalFormat ( ) . format ( duration . getDuration ( ) ) + formatTimeUnit ( duration . getUnits ( ) ) ; } return result ; } | This method is called to format a duration . | 73 | 9 |
143,560 | private String formatRate ( Rate value ) { String result = null ; if ( value != null ) { StringBuilder buffer = new StringBuilder ( m_formats . getCurrencyFormat ( ) . format ( value . getAmount ( ) ) ) ; buffer . append ( "/" ) ; buffer . append ( formatTimeUnit ( value . getUnits ( ) ) ) ; result = buffer . toString ( ) ; } return ( result ) ; } | This method is called to format a rate . | 94 | 9 |
143,561 | private String formatPriority ( Priority value ) { String result = null ; if ( value != null ) { String [ ] priorityTypes = LocaleData . getStringArray ( m_locale , LocaleData . PRIORITY_TYPES ) ; int priority = value . getValue ( ) ; if ( priority < Priority . LOWEST ) { priority = Priority . LOWEST ; } else { if ( priority > Priority . DO_NOT_LEVEL ) { priority = Priority . DO_NOT_LEVEL ; } } priority /= 100 ; result = priorityTypes [ priority - 1 ] ; } return ( result ) ; } | This method is called to format a priority . | 133 | 9 |
143,562 | private String formatTaskType ( TaskType value ) { return ( LocaleData . getString ( m_locale , ( value == TaskType . FIXED_DURATION ? LocaleData . YES : LocaleData . NO ) ) ) ; } | This method is called to format a task type . | 54 | 10 |
143,563 | private String formatRelationList ( List < Relation > value ) { String result = null ; if ( value != null && value . size ( ) != 0 ) { StringBuilder sb = new StringBuilder ( ) ; for ( Relation relation : value ) { if ( sb . length ( ) != 0 ) { sb . append ( m_delimiter ) ; } sb . append ( formatRelation ( relation ) ) ; } result = sb . toString ( ) ; } return ( result ) ; } | This method is called to format a relation list . | 111 | 10 |
143,564 | private String formatRelation ( Relation relation ) { String result = null ; if ( relation != null ) { StringBuilder sb = new StringBuilder ( relation . getTargetTask ( ) . getID ( ) . toString ( ) ) ; Duration duration = relation . getLag ( ) ; RelationType type = relation . getType ( ) ; double durationValue = duration . getDuration ( ) ; if ( ( durationValue != 0 ) || ( type != RelationType . FINISH_START ) ) { String [ ] typeNames = LocaleData . getStringArray ( m_locale , LocaleData . RELATION_TYPES ) ; sb . append ( typeNames [ type . getValue ( ) ] ) ; } if ( durationValue != 0 ) { if ( durationValue > 0 ) { sb . append ( ' ' ) ; } sb . append ( formatDuration ( duration ) ) ; } result = sb . toString ( ) ; } m_eventManager . fireRelationWrittenEvent ( relation ) ; return ( result ) ; } | This method is called to format a relation . | 228 | 9 |
143,565 | private String formatTimeUnit ( TimeUnit timeUnit ) { int units = timeUnit . getValue ( ) ; String result ; String [ ] [ ] unitNames = LocaleData . getStringArrays ( m_locale , LocaleData . TIME_UNITS_ARRAY ) ; if ( units < 0 || units >= unitNames . length ) { result = "" ; } else { result = unitNames [ units ] [ 0 ] ; } return ( result ) ; } | This method formats a time unit . | 100 | 7 |
143,566 | @ SuppressWarnings ( "unchecked" ) private Object formatType ( DataType type , Object value ) { switch ( type ) { case DATE : { value = formatDateTime ( value ) ; break ; } case CURRENCY : { value = formatCurrency ( ( Number ) value ) ; break ; } case UNITS : { value = formatUnits ( ( Number ) value ) ; break ; } case PERCENTAGE : { value = formatPercentage ( ( Number ) value ) ; break ; } case ACCRUE : { value = formatAccrueType ( ( AccrueType ) value ) ; break ; } case CONSTRAINT : { value = formatConstraintType ( ( ConstraintType ) value ) ; break ; } case WORK : case DURATION : { value = formatDuration ( value ) ; break ; } case RATE : { value = formatRate ( ( Rate ) value ) ; break ; } case PRIORITY : { value = formatPriority ( ( Priority ) value ) ; break ; } case RELATION_LIST : { value = formatRelationList ( ( List < Relation > ) value ) ; break ; } case TASK_TYPE : { value = formatTaskType ( ( TaskType ) value ) ; break ; } default : { break ; } } return ( value ) ; } | Converts a value to the appropriate type . | 284 | 9 |
143,567 | public final boolean getBoolean ( String name ) { boolean result = false ; Boolean value = ( Boolean ) getObject ( name ) ; if ( value != null ) { result = BooleanHelper . getBoolean ( value ) ; } return result ; } | Retrieve a boolean value . | 52 | 6 |
143,568 | public InputStream getInstance ( DirectoryEntry directory , String name ) throws IOException { DocumentEntry entry = ( DocumentEntry ) directory . getEntry ( name ) ; InputStream stream ; if ( m_encrypted ) { stream = new EncryptedDocumentInputStream ( entry , m_encryptionCode ) ; } else { stream = new DocumentInputStream ( entry ) ; } return stream ; } | Method used to instantiate the appropriate input stream reader a standard one or one which can deal with encrypted data . | 80 | 22 |
143,569 | private TaskField getTaskField ( int field ) { TaskField result = MPPTaskField14 . getInstance ( field ) ; if ( result != null ) { switch ( result ) { case START_TEXT : { result = TaskField . START ; break ; } case FINISH_TEXT : { result = TaskField . FINISH ; break ; } case DURATION_TEXT : { result = TaskField . DURATION ; break ; } default : { break ; } } } return result ; } | Maps an integer field ID to a field type . | 105 | 10 |
143,570 | public void updateUniqueCounters ( ) { // // Update task unique IDs // for ( Task task : m_parent . getTasks ( ) ) { int uniqueID = NumberHelper . getInt ( task . getUniqueID ( ) ) ; if ( uniqueID > m_taskUniqueID ) { m_taskUniqueID = uniqueID ; } } // // Update resource unique IDs // for ( Resource resource : m_parent . getResources ( ) ) { int uniqueID = NumberHelper . getInt ( resource . getUniqueID ( ) ) ; if ( uniqueID > m_resourceUniqueID ) { m_resourceUniqueID = uniqueID ; } } // // Update calendar unique IDs // for ( ProjectCalendar calendar : m_parent . getCalendars ( ) ) { int uniqueID = NumberHelper . getInt ( calendar . getUniqueID ( ) ) ; if ( uniqueID > m_calendarUniqueID ) { m_calendarUniqueID = uniqueID ; } } // // Update assignment unique IDs // for ( ResourceAssignment assignment : m_parent . getResourceAssignments ( ) ) { int uniqueID = NumberHelper . getInt ( assignment . getUniqueID ( ) ) ; if ( uniqueID > m_assignmentUniqueID ) { m_assignmentUniqueID = uniqueID ; } } } | This method is called to ensure that after a project file has been read the cached unique ID values used to generate new unique IDs start after the end of the existing set of unique IDs . | 279 | 37 |
143,571 | public static Date min ( Date d1 , Date d2 ) { Date result ; if ( d1 == null ) { result = d2 ; } else if ( d2 == null ) { result = d1 ; } else { result = ( d1 . compareTo ( d2 ) < 0 ) ? d1 : d2 ; } return result ; } | Returns the earlier of two dates handling null values . A non - null Date is always considered to be earlier than a null Date . | 75 | 26 |
143,572 | public static Date max ( Date d1 , Date d2 ) { Date result ; if ( d1 == null ) { result = d2 ; } else if ( d2 == null ) { result = d1 ; } else { result = ( d1 . compareTo ( d2 ) > 0 ) ? d1 : d2 ; } return result ; } | Returns the later of two dates handling null values . A non - null Date is always considered to be later than a null Date . | 75 | 26 |
143,573 | 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 ) ; } | This utility method calculates the difference in working time between two dates given the context of a task . | 106 | 19 |
143,574 | public static Date getDateFromLong ( long date ) { TimeZone tz = TimeZone . getDefault ( ) ; return ( new Date ( date - tz . getRawOffset ( ) ) ) ; } | Creates a date from the equivalent long value . This conversion takes account of the time zone . | 44 | 19 |
143,575 | public static Date getTimestampFromLong ( long timestamp ) { TimeZone tz = TimeZone . getDefault ( ) ; Date result = new Date ( timestamp - tz . getRawOffset ( ) ) ; if ( tz . inDaylightTime ( result ) == true ) { int savings ; if ( HAS_DST_SAVINGS == true ) { savings = tz . getDSTSavings ( ) ; } else { savings = DEFAULT_DST_SAVINGS ; } result = new Date ( result . getTime ( ) - savings ) ; } return ( result ) ; } | Creates a timestamp from the equivalent long value . This conversion takes account of the time zone and any daylight savings time . | 128 | 24 |
143,576 | public static Date getTime ( int hour , int minutes ) { Calendar cal = popCalendar ( ) ; cal . set ( Calendar . HOUR_OF_DAY , hour ) ; cal . set ( Calendar . MINUTE , minutes ) ; cal . set ( Calendar . SECOND , 0 ) ; Date result = cal . getTime ( ) ; pushCalendar ( cal ) ; return result ; } | Create a Date instance representing a specific time . | 83 | 9 |
143,577 | public static void setTime ( Calendar cal , Date time ) { if ( time != null ) { Calendar startCalendar = popCalendar ( time ) ; cal . set ( Calendar . HOUR_OF_DAY , startCalendar . get ( Calendar . HOUR_OF_DAY ) ) ; cal . set ( Calendar . MINUTE , startCalendar . get ( Calendar . MINUTE ) ) ; cal . set ( Calendar . SECOND , startCalendar . get ( Calendar . SECOND ) ) ; pushCalendar ( startCalendar ) ; } } | Given a date represented by a Calendar instance set the time component of the date based on the hours and minutes of the time supplied by the Date instance . | 117 | 30 |
143,578 | public static Date setTime ( Date date , Date canonicalTime ) { Date result ; if ( canonicalTime == null ) { result = date ; } else { // // The original naive implementation of this method generated // the "start of day" date (midnight) for the required day // then added the milliseconds from the canonical time // to move the time forward to the required point. Unfortunately // if the date we'e trying to do this for is the entry or // exit from DST, the result is wrong, hence I've switched to // the approach below. // Calendar cal = popCalendar ( canonicalTime ) ; int dayOffset = cal . get ( Calendar . DAY_OF_YEAR ) - 1 ; int hourOfDay = cal . get ( Calendar . HOUR_OF_DAY ) ; int minute = cal . get ( Calendar . MINUTE ) ; int second = cal . get ( Calendar . SECOND ) ; int millisecond = cal . get ( Calendar . MILLISECOND ) ; cal . setTime ( date ) ; if ( dayOffset != 0 ) { // The canonical time can be +1 day. // It's to do with the way we've historically // managed time ranges and midnight. cal . add ( Calendar . DAY_OF_YEAR , dayOffset ) ; } cal . set ( Calendar . MILLISECOND , millisecond ) ; cal . set ( Calendar . SECOND , second ) ; cal . set ( Calendar . MINUTE , minute ) ; cal . set ( Calendar . HOUR_OF_DAY , hourOfDay ) ; result = cal . getTime ( ) ; pushCalendar ( cal ) ; } return result ; } | Given a date represented by a Date instance set the time component of the date based on the hours and minutes of the time supplied by the Date instance . | 349 | 30 |
143,579 | public static Date addDays ( Date date , int days ) { Calendar cal = popCalendar ( date ) ; cal . add ( Calendar . DAY_OF_YEAR , days ) ; Date result = cal . getTime ( ) ; pushCalendar ( cal ) ; return result ; } | Add a number of days to the supplied date . | 60 | 10 |
143,580 | public static Calendar popCalendar ( ) { Calendar result ; Deque < Calendar > calendars = CALENDARS . get ( ) ; if ( calendars . isEmpty ( ) ) { result = Calendar . getInstance ( ) ; } else { result = calendars . pop ( ) ; } return result ; } | Acquire a calendar instance . | 62 | 6 |
143,581 | public List < MapRow > read ( ) throws IOException { List < MapRow > result = new ArrayList < MapRow > ( ) ; int fileCount = m_stream . readInt ( ) ; if ( fileCount != 0 ) { for ( int index = 0 ; index < fileCount ; index ++ ) { // We use a LinkedHashMap to preserve insertion order in iteration // Useful when debugging the file format. Map < String , Object > map = new LinkedHashMap < String , Object > ( ) ; readBlock ( map ) ; result . add ( new MapRow ( map ) ) ; } } return result ; } | Read a list of fixed sized blocks from the input stream . | 134 | 12 |
143,582 | protected int readByte ( InputStream is ) throws IOException { byte [ ] data = new byte [ 1 ] ; if ( is . read ( data ) != data . length ) { throw new EOFException ( ) ; } return ( MPPUtility . getByte ( data , 0 ) ) ; } | This method reads a single byte from the input stream . | 64 | 11 |
143,583 | protected int readShort ( InputStream is ) throws IOException { byte [ ] data = new byte [ 2 ] ; if ( is . read ( data ) != data . length ) { throw new EOFException ( ) ; } return ( MPPUtility . getShort ( data , 0 ) ) ; } | This method reads a two byte integer from the input stream . | 64 | 12 |
143,584 | protected int readInt ( InputStream is ) throws IOException { byte [ ] data = new byte [ 4 ] ; if ( is . read ( data ) != data . length ) { throw new EOFException ( ) ; } return ( MPPUtility . getInt ( data , 0 ) ) ; } | This method reads a four byte integer from the input stream . | 64 | 12 |
143,585 | protected byte [ ] readByteArray ( InputStream is , int size ) throws IOException { byte [ ] buffer = new byte [ size ] ; if ( is . read ( buffer ) != buffer . length ) { throw new EOFException ( ) ; } return ( buffer ) ; } | This method reads a byte array from the input stream . | 59 | 11 |
143,586 | public int blast ( InputStream input , OutputStream output ) throws IOException { m_input = input ; m_output = output ; int lit ; /* true if literals are coded */ int dict ; /* log2(dictionary size) - 6 */ int symbol ; /* decoded symbol, extra bits for distance */ int len ; /* length for copy */ int dist ; /* distance for copy */ int copy ; /* copy counter */ //unsigned char *from, *to; /* copy pointers */ /* read header */ lit = bits ( 8 ) ; if ( lit > 1 ) { return - 1 ; } dict = bits ( 8 ) ; if ( dict < 4 || dict > 6 ) { return - 2 ; } /* decode literals and length/distance pairs */ do { if ( bits ( 1 ) != 0 ) { /* get length */ symbol = decode ( LENCODE ) ; len = BASE [ symbol ] + bits ( EXTRA [ symbol ] ) ; if ( len == 519 ) { break ; /* end code */ } /* get distance */ symbol = len == 2 ? 2 : dict ; dist = decode ( DISTCODE ) << symbol ; dist += bits ( symbol ) ; dist ++ ; if ( m_first != 0 && dist > m_next ) { return - 3 ; /* distance too far back */ } /* copy length bytes from distance bytes back */ do { //to = m_out + m_next; int to = m_next ; int from = to - dist ; copy = MAXWIN ; if ( m_next < dist ) { from += copy ; copy = dist ; } copy -= m_next ; if ( copy > len ) { copy = len ; } len -= copy ; m_next += copy ; do { //*to++ = *from++; m_out [ to ++ ] = m_out [ from ++ ] ; } while ( -- copy != 0 ) ; if ( m_next == MAXWIN ) { //if (s->outfun(s->outhow, s->out, s->next)) return 1; m_output . write ( m_out , 0 , m_next ) ; m_next = 0 ; m_first = 0 ; } } while ( len != 0 ) ; } else { /* get literal and write it */ symbol = lit != 0 ? decode ( LITCODE ) : bits ( 8 ) ; m_out [ m_next ++ ] = ( byte ) symbol ; if ( m_next == MAXWIN ) { //if (s->outfun(s->outhow, s->out, s->next)) return 1; m_output . write ( m_out , 0 , m_next ) ; m_next = 0 ; m_first = 0 ; } } } while ( true ) ; if ( m_next != 0 ) { m_output . write ( m_out , 0 , m_next ) ; } return 0 ; } | Decode PKWare Compression Library stream . | 615 | 9 |
143,587 | private int decode ( Huffman h ) throws IOException { int len ; /* current number of bits in code */ int code ; /* len bits being decoded */ int first ; /* first code of length len */ int count ; /* number of codes of length len */ int index ; /* index of first code of length len in symbol table */ int bitbuf ; /* bits from stream */ int left ; /* bits left in next or left to process */ //short *next; /* next number of codes */ bitbuf = m_bitbuf ; left = m_bitcnt ; code = first = index = 0 ; len = 1 ; int nextIndex = 1 ; // next = h->count + 1; while ( true ) { while ( left -- != 0 ) { code |= ( bitbuf & 1 ) ^ 1 ; /* invert code */ bitbuf >>= 1 ; //count = *next++; count = h . m_count [ nextIndex ++ ] ; if ( code < first + count ) { /* if length len, return symbol */ m_bitbuf = bitbuf ; m_bitcnt = ( m_bitcnt - len ) & 7 ; return h . m_symbol [ index + ( code - first ) ] ; } index += count ; /* else update for next length */ first += count ; first <<= 1 ; code <<= 1 ; len ++ ; } left = ( MAXBITS + 1 ) - len ; if ( left == 0 ) { break ; } if ( m_left == 0 ) { m_in = m_input . read ( ) ; m_left = m_in == - 1 ? 0 : 1 ; if ( m_left == 0 ) { throw new IOException ( "out of input" ) ; /* out of input */ } } bitbuf = m_in ; m_left -- ; if ( left > 8 ) { left = 8 ; } } return - 9 ; /* ran out of codes */ } | Decode a code from the stream s using huffman table h . Return the symbol or a negative value if there is an error . If all of the lengths are zero i . e . an empty code or if the code is incomplete and an invalid code is received then - 9 is returned after reading MAXBITS bits . | 412 | 66 |
143,588 | private void validateSameDay ( ProjectCalendar calendar , LinkedList < TimephasedWork > list ) { for ( TimephasedWork assignment : list ) { Date assignmentStart = assignment . getStart ( ) ; Date calendarStartTime = calendar . getStartTime ( assignmentStart ) ; Date assignmentStartTime = DateHelper . getCanonicalTime ( assignmentStart ) ; Date assignmentFinish = assignment . getFinish ( ) ; Date calendarFinishTime = calendar . getFinishTime ( assignmentFinish ) ; Date assignmentFinishTime = DateHelper . getCanonicalTime ( assignmentFinish ) ; double totalWork = assignment . getTotalAmount ( ) . getDuration ( ) ; if ( assignmentStartTime != null && calendarStartTime != null ) { if ( ( totalWork == 0 && assignmentStartTime . getTime ( ) != calendarStartTime . getTime ( ) ) || ( assignmentStartTime . getTime ( ) < calendarStartTime . getTime ( ) ) ) { assignmentStart = DateHelper . setTime ( assignmentStart , calendarStartTime ) ; assignment . setStart ( assignmentStart ) ; } } if ( assignmentFinishTime != null && calendarFinishTime != null ) { if ( ( totalWork == 0 && assignmentFinishTime . getTime ( ) != calendarFinishTime . getTime ( ) ) || ( assignmentFinishTime . getTime ( ) > calendarFinishTime . getTime ( ) ) ) { assignmentFinish = DateHelper . setTime ( assignmentFinish , calendarFinishTime ) ; assignment . setFinish ( assignmentFinish ) ; } } } } | Ensures that the start and end dates for ranges fit within the working times for a given day . | 323 | 21 |
143,589 | public Table createTable ( ProjectFile file , byte [ ] data , VarMeta varMeta , Var2Data varData ) { Table table = new Table ( ) ; table . setID ( MPPUtility . getInt ( data , 0 ) ) ; table . setResourceFlag ( MPPUtility . getShort ( data , 108 ) == 1 ) ; table . setName ( MPPUtility . removeAmpersands ( MPPUtility . getUnicodeString ( data , 4 ) ) ) ; byte [ ] columnData = null ; Integer tableID = Integer . valueOf ( table . getID ( ) ) ; if ( m_tableColumnDataBaseline != null ) { columnData = varData . getByteArray ( varMeta . getOffset ( tableID , m_tableColumnDataBaseline ) ) ; } if ( columnData == null ) { columnData = varData . getByteArray ( varMeta . getOffset ( tableID , m_tableColumnDataEnterprise ) ) ; if ( columnData == null ) { columnData = varData . getByteArray ( varMeta . getOffset ( tableID , m_tableColumnDataStandard ) ) ; } } processColumnData ( file , table , columnData ) ; //System.out.println(table); return ( table ) ; } | Creates a new Table instance from data extracted from an MPP file . | 279 | 15 |
143,590 | private final boolean parseBoolean ( String value ) { return value != null && ( value . equalsIgnoreCase ( "true" ) || value . equalsIgnoreCase ( "y" ) || value . equalsIgnoreCase ( "yes" ) ) ; } | Parse a string representation of a Boolean value . XER files sometimes have N and Y to indicate boolean | 55 | 21 |
143,591 | public void processActivityCodes ( List < Row > types , List < Row > typeValues , List < Row > assignments ) { ActivityCodeContainer container = m_project . getActivityCodes ( ) ; Map < Integer , ActivityCode > map = new HashMap < Integer , ActivityCode > ( ) ; for ( Row row : types ) { ActivityCode code = new ActivityCode ( row . getInteger ( "actv_code_type_id" ) , row . getString ( "actv_code_type" ) ) ; container . add ( code ) ; map . put ( code . getUniqueID ( ) , code ) ; } for ( Row row : typeValues ) { ActivityCode code = map . get ( row . getInteger ( "actv_code_type_id" ) ) ; if ( code != null ) { ActivityCodeValue value = code . addValue ( row . getInteger ( "actv_code_id" ) , row . getString ( "short_name" ) , row . getString ( "actv_code_name" ) ) ; m_activityCodeMap . put ( value . getUniqueID ( ) , value ) ; } } for ( Row row : assignments ) { Integer taskID = row . getInteger ( "task_id" ) ; List < Integer > list = m_activityCodeAssignments . get ( taskID ) ; if ( list == null ) { list = new ArrayList < Integer > ( ) ; m_activityCodeAssignments . put ( taskID , list ) ; } list . add ( row . getInteger ( "actv_code_id" ) ) ; } } | Read activity code types and values . | 353 | 7 |
143,592 | public void processCalendar ( Row row ) { ProjectCalendar calendar = m_project . addCalendar ( ) ; Integer id = row . getInteger ( "clndr_id" ) ; m_calMap . put ( id , calendar ) ; calendar . setName ( row . getString ( "clndr_name" ) ) ; try { calendar . setMinutesPerDay ( Integer . valueOf ( ( int ) NumberHelper . getDouble ( row . getDouble ( "day_hr_cnt" ) ) * 60 ) ) ; calendar . setMinutesPerWeek ( Integer . valueOf ( ( int ) ( NumberHelper . getDouble ( row . getDouble ( "week_hr_cnt" ) ) * 60 ) ) ) ; calendar . setMinutesPerMonth ( Integer . valueOf ( ( int ) ( NumberHelper . getDouble ( row . getDouble ( "month_hr_cnt" ) ) * 60 ) ) ) ; calendar . setMinutesPerYear ( Integer . valueOf ( ( int ) ( NumberHelper . getDouble ( row . getDouble ( "year_hr_cnt" ) ) * 60 ) ) ) ; } catch ( ClassCastException ex ) { // We have seen examples of malformed calendar data where fields have been missing // from the record. We'll typically get a class cast exception here as we're trying // to process something which isn't a double. // We'll just return at this point as it's not clear that we can salvage anything // sensible from this record. return ; } // Process data String calendarData = row . getString ( "clndr_data" ) ; if ( calendarData != null && ! calendarData . isEmpty ( ) ) { Record root = Record . getRecord ( calendarData ) ; if ( root != null ) { processCalendarDays ( calendar , root ) ; processCalendarExceptions ( calendar , root ) ; } } else { // if there is not DaysOfWeek data, Primavera seems to default to Mon-Fri, 8:00-16:00 DateRange defaultHourRange = new DateRange ( DateHelper . getTime ( 8 , 0 ) , DateHelper . getTime ( 16 , 0 ) ) ; for ( Day day : Day . values ( ) ) { if ( day != Day . SATURDAY && day != Day . SUNDAY ) { calendar . setWorkingDay ( day , true ) ; ProjectCalendarHours hours = calendar . addCalendarHours ( day ) ; hours . addRange ( defaultHourRange ) ; } else { calendar . setWorkingDay ( day , false ) ; } } } m_eventManager . fireCalendarReadEvent ( calendar ) ; } | Process data for an individual calendar . | 572 | 7 |
143,593 | private void processCalendarDays ( ProjectCalendar calendar , Record root ) { // Retrieve working hours ... Record daysOfWeek = root . getChild ( "DaysOfWeek" ) ; if ( daysOfWeek != null ) { for ( Record dayRecord : daysOfWeek . getChildren ( ) ) { processCalendarHours ( calendar , dayRecord ) ; } } } | Process calendar days of the week . | 78 | 7 |
143,594 | private void processCalendarHours ( ProjectCalendar calendar , Record dayRecord ) { // ... for each day of the week Day day = Day . getInstance ( Integer . parseInt ( dayRecord . getField ( ) ) ) ; // Get hours List < Record > recHours = dayRecord . getChildren ( ) ; if ( recHours . size ( ) == 0 ) { // No data -> not working calendar . setWorkingDay ( day , false ) ; } else { calendar . setWorkingDay ( day , true ) ; // Read hours ProjectCalendarHours hours = calendar . addCalendarHours ( day ) ; for ( Record recWorkingHours : recHours ) { addHours ( hours , recWorkingHours ) ; } } } | Process hours in a working day . | 152 | 7 |
143,595 | private void addHours ( ProjectCalendarDateRanges ranges , Record hoursRecord ) { if ( hoursRecord . getValue ( ) != null ) { String [ ] wh = hoursRecord . getValue ( ) . split ( "\\|" ) ; try { String startText ; String endText ; if ( wh [ 0 ] . equals ( "s" ) ) { startText = wh [ 1 ] ; endText = wh [ 3 ] ; } else { startText = wh [ 3 ] ; endText = wh [ 1 ] ; } // for end time treat midnight as midnight next day if ( endText . equals ( "00:00" ) ) { endText = "24:00" ; } Date start = m_calendarTimeFormat . parse ( startText ) ; Date end = m_calendarTimeFormat . parse ( endText ) ; ranges . addRange ( new DateRange ( start , end ) ) ; } catch ( ParseException e ) { // silently ignore date parse exceptions } } } | Parses a record containing hours and add them to a container . | 213 | 14 |
143,596 | private ProjectCalendar getResourceCalendar ( Integer calendarID ) { ProjectCalendar result = null ; if ( calendarID != null ) { ProjectCalendar calendar = m_calMap . get ( calendarID ) ; if ( calendar != null ) { // // If the resource is linked to a base calendar, derive // a default calendar from the base calendar. // if ( ! calendar . isDerived ( ) ) { ProjectCalendar resourceCalendar = m_project . addCalendar ( ) ; resourceCalendar . setParent ( calendar ) ; resourceCalendar . setWorkingDay ( Day . MONDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . TUESDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . WEDNESDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . THURSDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . FRIDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . SATURDAY , DayType . DEFAULT ) ; resourceCalendar . setWorkingDay ( Day . SUNDAY , DayType . DEFAULT ) ; result = resourceCalendar ; } else { // // Primavera seems to allow a calendar to be shared between resources // whereas in the MS Project model there is a one-to-one // relationship. If we find a shared calendar, take a copy of it // if ( calendar . getResource ( ) == null ) { result = calendar ; } else { ProjectCalendar copy = m_project . addCalendar ( ) ; copy . copy ( calendar ) ; result = copy ; } } } } return result ; } | Retrieve the correct calendar for a resource . | 371 | 9 |
143,597 | private FieldType getActivityIDField ( Map < FieldType , String > map ) { FieldType result = null ; for ( Map . Entry < FieldType , String > entry : map . entrySet ( ) ) { if ( entry . getValue ( ) . equals ( "task_code" ) ) { result = entry . getKey ( ) ; break ; } } return result ; } | Determine which field the Activity ID has been mapped to . | 81 | 13 |
143,598 | private void addUserDefinedField ( FieldTypeClass fieldType , UserFieldDataType dataType , String name ) { try { switch ( fieldType ) { case TASK : TaskField taskField ; do { taskField = m_taskUdfCounters . nextField ( TaskField . class , dataType ) ; } while ( m_taskFields . containsKey ( taskField ) || m_wbsFields . containsKey ( taskField ) ) ; m_project . getCustomFields ( ) . getCustomField ( taskField ) . setAlias ( name ) ; break ; case RESOURCE : ResourceField resourceField ; do { resourceField = m_resourceUdfCounters . nextField ( ResourceField . class , dataType ) ; } while ( m_resourceFields . containsKey ( resourceField ) ) ; m_project . getCustomFields ( ) . getCustomField ( resourceField ) . setAlias ( name ) ; break ; case ASSIGNMENT : AssignmentField assignmentField ; do { assignmentField = m_assignmentUdfCounters . nextField ( AssignmentField . class , dataType ) ; } while ( m_assignmentFields . containsKey ( assignmentField ) ) ; m_project . getCustomFields ( ) . getCustomField ( assignmentField ) . setAlias ( name ) ; break ; default : break ; } } catch ( Exception ex ) { // // SF#227: If we get an exception thrown here... it's likely that // we've run out of user defined fields, for example // there are only 30 TEXT fields. We'll ignore this: the user // defined field won't be mapped to an alias, so we'll // ignore it when we read in the values. // } } | Configure a new user defined field . | 369 | 8 |
143,599 | private void addUDFValue ( FieldTypeClass fieldType , FieldContainer container , Row row ) { Integer fieldId = row . getInteger ( "udf_type_id" ) ; String fieldName = m_udfFields . get ( fieldId ) ; Object value = null ; FieldType field = m_project . getCustomFields ( ) . getFieldByAlias ( fieldType , fieldName ) ; if ( field != null ) { DataType fieldDataType = field . getDataType ( ) ; switch ( fieldDataType ) { case DATE : { value = row . getDate ( "udf_date" ) ; break ; } case CURRENCY : case NUMERIC : { value = row . getDouble ( "udf_number" ) ; break ; } case GUID : case INTEGER : { value = row . getInteger ( "udf_code_id" ) ; break ; } case BOOLEAN : { String text = row . getString ( "udf_text" ) ; if ( text != null ) { // before a normal boolean parse, we try to lookup the text as a P6 static type indicator UDF value = STATICTYPE_UDF_MAP . get ( text ) ; if ( value == null ) { value = Boolean . valueOf ( row . getBoolean ( "udf_text" ) ) ; } } else { value = Boolean . valueOf ( row . getBoolean ( "udf_number" ) ) ; } break ; } default : { value = row . getString ( "udf_text" ) ; break ; } } container . set ( field , value ) ; } } | Adds a user defined field value to a task . | 359 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.