public List < ProjectFile > readAll ( InputStream is , boolean linkCrossProjectRelations ) throws MPXJException { try { m_tables = new HashMap < String , List < Row > > ( ) ; m_numberFormat = new DecimalFormat ( ) ; processFile ( is ) ; List < Row > rows = getRows ( "project" , null , null ) ; List < ProjectFile > result = new ArrayList < ProjectFile > ( rows . size ( ) ) ; List < ExternalPredecessorRelation > externalPredecessors = new ArrayList < ExternalPredecessorRelation > ( ) ; for ( Row row : rows ) { setProjectID ( row . getInt ( "proj_id" ) ) ; m_reader = new PrimaveraReader ( m_taskUdfCounters , m_resourceUdfCounters , m_assignmentUdfCounters , m_resourceFields , m_wbsFields , m_taskFields , m_assignmentFields , m_aliases , m_matchPrimaveraWBS ) ; ProjectFile project = m_reader . getProject ( ) ; project . getEventManager ( ) . addProjectListeners ( m_projectListeners ) ; processProjectProperties ( ) ; processUserDefinedFields ( ) ; processCalendars ( ) ; processResources ( ) ; processResourceRates ( ) ; processTasks ( ) ; processPredecessors ( ) ; processAssignments ( ) ; externalPredecessors . addAll ( m_reader . getExternalPredecessors ( ) ) ; m_reader = null ; project . updateStructure ( ) ; result . add ( project ) ; } if ( linkCrossProjectRelations ) { for ( ExternalPredecessorRelation externalRelation : externalPredecessors ) { Task predecessorTask ; // we could aggregate the project task id maps but that's likely more work // than just looping through the projects for ( ProjectFile proj : result ) { predecessorTask = proj . getTaskByUniqueID ( externalRelation . getSourceUniqueID ( ) ) ; if ( predecessorTask != null ) { Relation relation = externalRelation . getTargetTask ( ) . addPredecessor ( predecessorTask , externalRelation . getType ( ) , externalRelation . getLag ( ) ) ; relation . setUniqueID ( externalRelation . getUniqueID ( ) ) ; break ; } } // if predecessorTask not found the external task is outside of the file so ignore } } return result ; } finally { m_reader = null ; m_tables = null ; m_currentTableName = null ; m_currentTable = null ; m_currentFieldNames = null ; m_defaultCurrencyName = null ; m_currencyMap . clear ( ) ; m_numberFormat = null ; m_defaultCurrencyData = null ; } }
This is a convenience method which allows all projects in an XER file to be read in a single pass .