idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
20,100
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 .
20,101
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 .
20,102
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 .
20,103
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 .
20,104
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 .
20,105
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 .
20,106
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 ) ; 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 { 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 .
20,107
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 ) ) ; } 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 ) ) ; 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 .
20,108
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 .
20,109
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 .
20,110
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 .
20,111
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 .
20,112
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 .
20,113
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 .
20,114
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 .
20,115
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 .
20,116
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 ) { } return field ; }
Map the Primavera UDF to a custom field .
20,117
private Double zeroIsNull ( Double value ) { if ( value != null && value . doubleValue ( ) == 0 ) { value = null ; } return value ; }
Render a zero Double as null .
20,118
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 .
20,119
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 .
20,120
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 .
20,121
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 .
20,122
public int evaluate ( FieldContainer container ) { 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 { criteria = m_nonSummaryRowCriteria ; } int result = - 1 ; for ( GraphicalIndicatorCriteria gic : criteria ) { result = gic . evaluate ( container ) ; if ( result != - 1 ) { break ; } } 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 .
20,123
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 .
20,124
private void writeCalendar ( ProjectCalendar record ) throws IOException { 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 ( ) ) { for ( ProjectCalendarException ex : record . getCalendarExceptions ( ) ) { writeCalendarException ( record , ex ) ; } } m_eventManager . fireCalendarWrittenEvent ( record ) ; } }
Write a calendar .
20,125
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 .
20,126
private void writeResource ( Resource record ) throws IOException { m_buffer . setLength ( 0 ) ; 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 ( ) ) ; String notes = record . getNotes ( ) ; if ( notes . length ( ) != 0 ) { writeNotes ( MPXConstants . RESOURCE_NOTES_RECORD_NUMBER , notes ) ; } if ( record . getResourceCalendar ( ) != null ) { writeCalendar ( record . getResourceCalendar ( ) ) ; } m_eventManager . fireResourceWrittenEvent ( record ) ; }
Write a resource .
20,127
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 .
20,128
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 .
20,129
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 .
20,130
private void writeTasks ( List < Task > tasks ) throws IOException { for ( Task task : tasks ) { writeTask ( task ) ; writeTasks ( task . getChildTasks ( ) ) ; } }
Recursively write tasks .
20,131
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 .
20,132
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 .
20,133
private String stripLineBreaks ( String text , String replacement ) { if ( text . indexOf ( '\r' ) != - 1 || text . indexOf ( '\n' ) != - 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 .
20,134
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 ( ) ; } } } result = stripLineBreaks ( result , MPXConstants . EOL_PLACEHOLDER_STRING ) ; 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 .
20,135
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 .
20,136
private String formatTime ( Date value ) { return ( value == null ? null : m_formats . getTimeFormat ( ) . format ( value ) ) ; }
This method is called to format a time value .
20,137
private String formatCurrency ( Number value ) { return ( value == null ? null : m_formats . getCurrencyFormat ( ) . format ( value ) ) ; }
This method is called to format a currency value .
20,138
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 .
20,139
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 .
20,140
private String formatPercentage ( Number value ) { return ( value == null ? null : m_formats . getPercentageDecimalFormat ( ) . format ( value ) + "%" ) ; }
This method is called to format a percentage value .
20,141
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 .
20,142
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 .
20,143
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 .
20,144
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 .
20,145
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 .
20,146
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 .
20,147
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 .
20,148
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 .
20,149
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 .
20,150
@ 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 .
20,151
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 .
20,152
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 .
20,153
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 .
20,154
public void updateUniqueCounters ( ) { for ( Task task : m_parent . getTasks ( ) ) { int uniqueID = NumberHelper . getInt ( task . getUniqueID ( ) ) ; if ( uniqueID > m_taskUniqueID ) { m_taskUniqueID = uniqueID ; } } for ( Resource resource : m_parent . getResources ( ) ) { int uniqueID = NumberHelper . getInt ( resource . getUniqueID ( ) ) ; if ( uniqueID > m_resourceUniqueID ) { m_resourceUniqueID = uniqueID ; } } for ( ProjectCalendar calendar : m_parent . getCalendars ( ) ) { int uniqueID = NumberHelper . getInt ( calendar . getUniqueID ( ) ) ; if ( uniqueID > m_calendarUniqueID ) { m_calendarUniqueID = uniqueID ; } } 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 .
20,155
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 .
20,156
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 .
20,157
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 .
20,158
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 .
20,159
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 .
20,160
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 .
20,161
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 .
20,162
public static Date setTime ( Date date , Date canonicalTime ) { Date result ; if ( canonicalTime == null ) { result = date ; } else { 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 ) { 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 .
20,163
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 .
20,164
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 .
20,165
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 ++ ) { 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 .
20,166
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 .
20,167
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 .
20,168
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 .
20,169
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 .
20,170
public int blast ( InputStream input , OutputStream output ) throws IOException { m_input = input ; m_output = output ; int lit ; int dict ; int symbol ; int len ; int dist ; int copy ; lit = bits ( 8 ) ; if ( lit > 1 ) { return - 1 ; } dict = bits ( 8 ) ; if ( dict < 4 || dict > 6 ) { return - 2 ; } do { if ( bits ( 1 ) != 0 ) { symbol = decode ( LENCODE ) ; len = BASE [ symbol ] + bits ( EXTRA [ symbol ] ) ; if ( len == 519 ) { break ; } symbol = len == 2 ? 2 : dict ; dist = decode ( DISTCODE ) << symbol ; dist += bits ( symbol ) ; dist ++ ; if ( m_first != 0 && dist > m_next ) { return - 3 ; } do { 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 { m_out [ to ++ ] = m_out [ from ++ ] ; } while ( -- copy != 0 ) ; if ( m_next == MAXWIN ) { m_output . write ( m_out , 0 , m_next ) ; m_next = 0 ; m_first = 0 ; } } while ( len != 0 ) ; } else { symbol = lit != 0 ? decode ( LITCODE ) : bits ( 8 ) ; m_out [ m_next ++ ] = ( byte ) symbol ; if ( m_next == MAXWIN ) { 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 .
20,171
private int decode ( Huffman h ) throws IOException { int len ; int code ; int first ; int count ; int index ; int bitbuf ; int left ; bitbuf = m_bitbuf ; left = m_bitcnt ; code = first = index = 0 ; len = 1 ; int nextIndex = 1 ; while ( true ) { while ( left -- != 0 ) { code |= ( bitbuf & 1 ) ^ 1 ; bitbuf >>= 1 ; count = h . m_count [ nextIndex ++ ] ; if ( code < first + count ) { m_bitbuf = bitbuf ; m_bitcnt = ( m_bitcnt - len ) & 7 ; return h . m_symbol [ index + ( code - first ) ] ; } index += count ; 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" ) ; } } bitbuf = m_in ; m_left -- ; if ( left > 8 ) { left = 8 ; } } return - 9 ; }
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 .
20,172
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 .
20,173
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 ) ; return ( table ) ; }
Creates a new Table instance from data extracted from an MPP file .
20,174
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
20,175
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 .
20,176
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 ) { return ; } 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 { 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 .
20,177
private void processCalendarDays ( ProjectCalendar calendar , Record root ) { Record daysOfWeek = root . getChild ( "DaysOfWeek" ) ; if ( daysOfWeek != null ) { for ( Record dayRecord : daysOfWeek . getChildren ( ) ) { processCalendarHours ( calendar , dayRecord ) ; } } }
Process calendar days of the week .
20,178
private void processCalendarHours ( ProjectCalendar calendar , Record dayRecord ) { Day day = Day . getInstance ( Integer . parseInt ( dayRecord . getField ( ) ) ) ; List < Record > recHours = dayRecord . getChildren ( ) ; if ( recHours . size ( ) == 0 ) { calendar . setWorkingDay ( day , false ) ; } else { calendar . setWorkingDay ( day , true ) ; ProjectCalendarHours hours = calendar . addCalendarHours ( day ) ; for ( Record recWorkingHours : recHours ) { addHours ( hours , recWorkingHours ) ; } } }
Process hours in a working day .
20,179
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 ] ; } 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 ) { } } }
Parses a record containing hours and add them to a container .
20,180
private ProjectCalendar getResourceCalendar ( Integer calendarID ) { ProjectCalendar result = null ; if ( calendarID != null ) { ProjectCalendar calendar = m_calMap . get ( calendarID ) ; if ( calendar != null ) { 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 { 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 .
20,181
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 .
20,182
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 ) { } }
Configure a new user defined field .
20,183
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 ) { 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 .
20,184
private void populateUserDefinedFieldValues ( String tableName , FieldTypeClass type , FieldContainer container , Integer uniqueID ) { Map < Integer , List < Row > > tableData = m_udfValues . get ( tableName ) ; if ( tableData != null ) { List < Row > udf = tableData . get ( uniqueID ) ; if ( udf != null ) { for ( Row r : udf ) { addUDFValue ( type , container , r ) ; } } } }
Populate the UDF values for this entity .
20,185
public void processDefaultCurrency ( Row row ) { ProjectProperties properties = m_project . getProjectProperties ( ) ; properties . setCurrencySymbol ( row . getString ( "curr_symbol" ) ) ; properties . setSymbolPosition ( CURRENCY_SYMBOL_POSITION_MAP . get ( row . getString ( "pos_curr_fmt_type" ) ) ) ; properties . setCurrencyDigits ( row . getInteger ( "decimal_digit_cnt" ) ) ; properties . setThousandsSeparator ( row . getString ( "digit_group_symbol" ) . charAt ( 0 ) ) ; properties . setDecimalSeparator ( row . getString ( "decimal_symbol" ) . charAt ( 0 ) ) ; }
Code common to both XER and database readers to extract currency format data .
20,186
private void processFields ( Map < FieldType , String > map , Row row , FieldContainer container ) { for ( Map . Entry < FieldType , String > entry : map . entrySet ( ) ) { FieldType field = entry . getKey ( ) ; String name = entry . getValue ( ) ; Object value ; switch ( field . getDataType ( ) ) { case INTEGER : { value = row . getInteger ( name ) ; break ; } case BOOLEAN : { value = Boolean . valueOf ( row . getBoolean ( name ) ) ; break ; } case DATE : { value = row . getDate ( name ) ; break ; } case CURRENCY : case NUMERIC : case PERCENTAGE : { value = row . getDouble ( name ) ; break ; } case DELAY : case WORK : case DURATION : { value = row . getDuration ( name ) ; break ; } case RESOURCE_TYPE : { value = RESOURCE_TYPE_MAP . get ( row . getString ( name ) ) ; break ; } case TASK_TYPE : { value = TASK_TYPE_MAP . get ( row . getString ( name ) ) ; break ; } case CONSTRAINT : { value = CONSTRAINT_TYPE_MAP . get ( row . getString ( name ) ) ; break ; } case PRIORITY : { value = PRIORITY_MAP . get ( row . getString ( name ) ) ; break ; } case GUID : { value = row . getUUID ( name ) ; break ; } default : { value = row . getString ( name ) ; break ; } } container . set ( field , value ) ; } }
Generic method to extract Primavera fields and assign to MPXJ fields .
20,187
private void applyAliases ( Map < FieldType , String > aliases ) { CustomFieldContainer fields = m_project . getCustomFields ( ) ; for ( Map . Entry < FieldType , String > entry : aliases . entrySet ( ) ) { fields . getCustomField ( entry . getKey ( ) ) . setAlias ( entry . getValue ( ) ) ; } }
Apply aliases to task and resource fields .
20,188
private Number calculatePercentComplete ( Row row ) { Number result ; switch ( PercentCompleteType . getInstance ( row . getString ( "complete_pct_type" ) ) ) { case UNITS : { result = calculateUnitsPercentComplete ( row ) ; break ; } case DURATION : { result = calculateDurationPercentComplete ( row ) ; break ; } default : { result = calculatePhysicalPercentComplete ( row ) ; break ; } } return result ; }
Determine which type of percent complete is used on on this task and calculate the required value .
20,189
private Number calculateUnitsPercentComplete ( Row row ) { double result = 0 ; double actualWorkQuantity = NumberHelper . getDouble ( row . getDouble ( "act_work_qty" ) ) ; double actualEquipmentQuantity = NumberHelper . getDouble ( row . getDouble ( "act_equip_qty" ) ) ; double numerator = actualWorkQuantity + actualEquipmentQuantity ; if ( numerator != 0 ) { double remainingWorkQuantity = NumberHelper . getDouble ( row . getDouble ( "remain_work_qty" ) ) ; double remainingEquipmentQuantity = NumberHelper . getDouble ( row . getDouble ( "remain_equip_qty" ) ) ; double denominator = remainingWorkQuantity + actualWorkQuantity + remainingEquipmentQuantity + actualEquipmentQuantity ; result = denominator == 0 ? 0 : ( ( numerator * 100 ) / denominator ) ; } return NumberHelper . getDouble ( result ) ; }
Calculate the units percent complete .
20,190
private Number calculateDurationPercentComplete ( Row row ) { double result = 0 ; double targetDuration = row . getDuration ( "target_drtn_hr_cnt" ) . getDuration ( ) ; double remainingDuration = row . getDuration ( "remain_drtn_hr_cnt" ) . getDuration ( ) ; if ( targetDuration == 0 ) { if ( remainingDuration == 0 ) { if ( "TK_Complete" . equals ( row . getString ( "status_code" ) ) ) { result = 100 ; } } } else { if ( remainingDuration < targetDuration ) { result = ( ( targetDuration - remainingDuration ) * 100 ) / targetDuration ; } } return NumberHelper . getDouble ( result ) ; }
Calculate the duration percent complete .
20,191
public static Map < FieldType , String > getDefaultResourceFieldMap ( ) { Map < FieldType , String > map = new LinkedHashMap < FieldType , String > ( ) ; map . put ( ResourceField . UNIQUE_ID , "rsrc_id" ) ; map . put ( ResourceField . GUID , "guid" ) ; map . put ( ResourceField . NAME , "rsrc_name" ) ; map . put ( ResourceField . CODE , "employee_code" ) ; map . put ( ResourceField . EMAIL_ADDRESS , "email_addr" ) ; map . put ( ResourceField . NOTES , "rsrc_notes" ) ; map . put ( ResourceField . CREATED , "create_date" ) ; map . put ( ResourceField . TYPE , "rsrc_type" ) ; map . put ( ResourceField . INITIALS , "rsrc_short_name" ) ; map . put ( ResourceField . PARENT_ID , "parent_rsrc_id" ) ; return map ; }
Retrieve the default mapping between MPXJ resource fields and Primavera resource field names .
20,192
public static Map < FieldType , String > getDefaultWbsFieldMap ( ) { Map < FieldType , String > map = new LinkedHashMap < FieldType , String > ( ) ; map . put ( TaskField . UNIQUE_ID , "wbs_id" ) ; map . put ( TaskField . GUID , "guid" ) ; map . put ( TaskField . NAME , "wbs_name" ) ; map . put ( TaskField . BASELINE_COST , "orig_cost" ) ; map . put ( TaskField . REMAINING_COST , "indep_remain_total_cost" ) ; map . put ( TaskField . REMAINING_WORK , "indep_remain_work_qty" ) ; map . put ( TaskField . DEADLINE , "anticip_end_date" ) ; map . put ( TaskField . DATE1 , "suspend_date" ) ; map . put ( TaskField . DATE2 , "resume_date" ) ; map . put ( TaskField . TEXT1 , "task_code" ) ; map . put ( TaskField . WBS , "wbs_short_name" ) ; return map ; }
Retrieve the default mapping between MPXJ task fields and Primavera wbs field names .
20,193
public static Map < FieldType , String > getDefaultTaskFieldMap ( ) { Map < FieldType , String > map = new LinkedHashMap < FieldType , String > ( ) ; map . put ( TaskField . UNIQUE_ID , "task_id" ) ; map . put ( TaskField . GUID , "guid" ) ; map . put ( TaskField . NAME , "task_name" ) ; map . put ( TaskField . ACTUAL_DURATION , "act_drtn_hr_cnt" ) ; map . put ( TaskField . REMAINING_DURATION , "remain_drtn_hr_cnt" ) ; map . put ( TaskField . ACTUAL_WORK , "act_work_qty" ) ; map . put ( TaskField . REMAINING_WORK , "remain_work_qty" ) ; map . put ( TaskField . BASELINE_WORK , "target_work_qty" ) ; map . put ( TaskField . BASELINE_DURATION , "target_drtn_hr_cnt" ) ; map . put ( TaskField . DURATION , "target_drtn_hr_cnt" ) ; map . put ( TaskField . CONSTRAINT_DATE , "cstr_date" ) ; map . put ( TaskField . ACTUAL_START , "act_start_date" ) ; map . put ( TaskField . ACTUAL_FINISH , "act_end_date" ) ; map . put ( TaskField . LATE_START , "late_start_date" ) ; map . put ( TaskField . LATE_FINISH , "late_end_date" ) ; map . put ( TaskField . EARLY_START , "early_start_date" ) ; map . put ( TaskField . EARLY_FINISH , "early_end_date" ) ; map . put ( TaskField . REMAINING_EARLY_START , "restart_date" ) ; map . put ( TaskField . REMAINING_EARLY_FINISH , "reend_date" ) ; map . put ( TaskField . BASELINE_START , "target_start_date" ) ; map . put ( TaskField . BASELINE_FINISH , "target_end_date" ) ; map . put ( TaskField . CONSTRAINT_TYPE , "cstr_type" ) ; map . put ( TaskField . PRIORITY , "priority_type" ) ; map . put ( TaskField . CREATED , "create_date" ) ; map . put ( TaskField . TYPE , "duration_type" ) ; map . put ( TaskField . FREE_SLACK , "free_float_hr_cnt" ) ; map . put ( TaskField . TOTAL_SLACK , "total_float_hr_cnt" ) ; map . put ( TaskField . TEXT1 , "task_code" ) ; map . put ( TaskField . TEXT2 , "task_type" ) ; map . put ( TaskField . TEXT3 , "status_code" ) ; map . put ( TaskField . NUMBER1 , "rsrc_id" ) ; return map ; }
Retrieve the default mapping between MPXJ task fields and Primavera task field names .
20,194
public static Map < FieldType , String > getDefaultAssignmentFieldMap ( ) { Map < FieldType , String > map = new LinkedHashMap < FieldType , String > ( ) ; map . put ( AssignmentField . UNIQUE_ID , "taskrsrc_id" ) ; map . put ( AssignmentField . GUID , "guid" ) ; map . put ( AssignmentField . REMAINING_WORK , "remain_qty" ) ; map . put ( AssignmentField . BASELINE_WORK , "target_qty" ) ; map . put ( AssignmentField . ACTUAL_OVERTIME_WORK , "act_ot_qty" ) ; map . put ( AssignmentField . BASELINE_COST , "target_cost" ) ; map . put ( AssignmentField . ACTUAL_OVERTIME_COST , "act_ot_cost" ) ; map . put ( AssignmentField . REMAINING_COST , "remain_cost" ) ; map . put ( AssignmentField . ACTUAL_START , "act_start_date" ) ; map . put ( AssignmentField . ACTUAL_FINISH , "act_end_date" ) ; map . put ( AssignmentField . BASELINE_START , "target_start_date" ) ; map . put ( AssignmentField . BASELINE_FINISH , "target_end_date" ) ; map . put ( AssignmentField . ASSIGNMENT_DELAY , "target_lag_drtn_hr_cnt" ) ; return map ; }
Retrieve the default mapping between MPXJ assignment fields and Primavera assignment field names .
20,195
public static Map < FieldType , String > getDefaultAliases ( ) { Map < FieldType , String > map = new HashMap < FieldType , String > ( ) ; map . put ( TaskField . DATE1 , "Suspend Date" ) ; map . put ( TaskField . DATE2 , "Resume Date" ) ; map . put ( TaskField . TEXT1 , "Code" ) ; map . put ( TaskField . TEXT2 , "Activity Type" ) ; map . put ( TaskField . TEXT3 , "Status" ) ; map . put ( TaskField . NUMBER1 , "Primary Resource Unique ID" ) ; return map ; }
Retrieve the default aliases to be applied to MPXJ task and resource fields .
20,196
private static void filter ( String filename , String filtername ) throws Exception { ProjectFile project = new UniversalProjectReader ( ) . read ( filename ) ; Filter filter = project . getFilters ( ) . getFilterByName ( filtername ) ; if ( filter == null ) { displayAvailableFilters ( project ) ; } else { System . out . println ( filter ) ; System . out . println ( ) ; if ( filter . isTaskFilter ( ) ) { processTaskFilter ( project , filter ) ; } else { processResourceFilter ( project , filter ) ; } } }
This method opens the named project applies the named filter and displays the filtered list of tasks or resources . If an invalid filter name is supplied a list of valid filter names is shown .
20,197
private static void displayAvailableFilters ( ProjectFile project ) { System . out . println ( "Unknown filter name supplied." ) ; System . out . println ( "Available task filters:" ) ; for ( Filter filter : project . getFilters ( ) . getTaskFilters ( ) ) { System . out . println ( " " + filter . getName ( ) ) ; } System . out . println ( "Available resource filters:" ) ; for ( Filter filter : project . getFilters ( ) . getResourceFilters ( ) ) { System . out . println ( " " + filter . getName ( ) ) ; } }
This utility displays a list of available task filters and a list of available resource filters .
20,198
private static void processTaskFilter ( ProjectFile project , Filter filter ) { for ( Task task : project . getTasks ( ) ) { if ( filter . evaluate ( task , null ) ) { System . out . println ( task . getID ( ) + "," + task . getUniqueID ( ) + "," + task . getName ( ) ) ; } } }
Apply a filter to the list of all tasks and show the results .
20,199
private static void processResourceFilter ( ProjectFile project , Filter filter ) { for ( Resource resource : project . getResources ( ) ) { if ( filter . evaluate ( resource , null ) ) { System . out . println ( resource . getID ( ) + "," + resource . getUniqueID ( ) + "," + resource . getName ( ) ) ; } } }
Apply a filter to the list of all resources and show the results .