idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
20,500
private void processCalendars ( ) throws SQLException { for ( ResultSetRow row : getRows ( "SELECT * FROM MSP_CALENDARS WHERE PROJ_ID=?" , m_projectID ) ) { processCalendar ( row ) ; } updateBaseCalendarNames ( ) ; processCalendarData ( m_project . getCalendars ( ) ) ; }
Select calendar data from the database .
20,501
private void processCalendarData ( List < ProjectCalendar > calendars ) throws SQLException { for ( ProjectCalendar calendar : calendars ) { processCalendarData ( calendar , getRows ( "SELECT * FROM MSP_CALENDAR_DATA WHERE PROJ_ID=? AND CAL_UID=?" , m_projectID , calendar . getUniqueID ( ) ) ) ; } }
Process calendar hours and exception data from the database .
20,502
private void processCalendarData ( ProjectCalendar calendar , List < ResultSetRow > calendarData ) { for ( ResultSetRow row : calendarData ) { processCalendarData ( calendar , row ) ; } }
Process the hours and exceptions for an individual calendar .
20,503
private void processSubProjects ( ) { int subprojectIndex = 1 ; for ( Task task : m_project . getTasks ( ) ) { String subProjectFileName = task . getSubprojectName ( ) ; if ( subProjectFileName != null ) { String fileName = subProjectFileName ; int offset = 0x01000000 + ( subprojectIndex * 0x00400000 ) ; int index = subProjectFileName . lastIndexOf ( '\\' ) ; if ( index != - 1 ) { fileName = subProjectFileName . substring ( index + 1 ) ; } SubProject sp = new SubProject ( ) ; sp . setFileName ( fileName ) ; sp . setFullPath ( subProjectFileName ) ; sp . setUniqueIDOffset ( Integer . valueOf ( offset ) ) ; sp . setTaskUniqueID ( task . getUniqueID ( ) ) ; task . setSubProject ( sp ) ; ++ subprojectIndex ; } } }
The only indication that a task is a SubProject is the contents of the subproject file name field . We test these here then add a skeleton subproject structure to match the way we do things with MPP files .
20,504
private void processOutlineCodeFields ( Row parentRow ) throws SQLException { Integer entityID = parentRow . getInteger ( "CODE_REF_UID" ) ; Integer outlineCodeEntityID = parentRow . getInteger ( "CODE_UID" ) ; for ( ResultSetRow row : getRows ( "SELECT * FROM MSP_OUTLINE_CODES WHERE CODE_UID=?" , outlineCodeEntityID ) ) { processOutlineCodeField ( entityID , row ) ; } }
Process a single outline code .
20,505
private void allocateConnection ( ) throws SQLException { if ( m_connection == null ) { m_connection = m_dataSource . getConnection ( ) ; m_allocatedConnection = true ; queryDatabaseMetaData ( ) ; } }
Allocates a database connection .
20,506
private void queryDatabaseMetaData ( ) { ResultSet rs = null ; try { Set < String > tables = new HashSet < String > ( ) ; DatabaseMetaData dmd = m_connection . getMetaData ( ) ; rs = dmd . getTables ( null , null , null , null ) ; while ( rs . next ( ) ) { tables . add ( rs . getString ( "TABLE_NAME" ) ) ; } m_hasResourceBaselines = tables . contains ( "MSP_RESOURCE_BASELINES" ) ; m_hasTaskBaselines = tables . contains ( "MSP_TASK_BASELINES" ) ; m_hasAssignmentBaselines = tables . contains ( "MSP_ASSIGNMENT_BASELINES" ) ; } catch ( Exception ex ) { } finally { if ( rs != null ) { try { rs . close ( ) ; } catch ( SQLException ex ) { } rs = null ; } } }
Queries database meta data to check for the existence of specific tables .
20,507
public static final UUID parseUUID ( String value ) { UUID result = null ; if ( value != null && ! value . isEmpty ( ) ) { if ( value . charAt ( 0 ) == '{' ) { result = UUID . fromString ( value . substring ( 1 , value . length ( ) - 1 ) ) ; } else { byte [ ] data = javax . xml . bind . DatatypeConverter . parseBase64Binary ( value + "==" ) ; long msb = 0 ; long lsb = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { msb = ( msb << 8 ) | ( data [ i ] & 0xff ) ; } for ( int i = 8 ; i < 16 ; i ++ ) { lsb = ( lsb << 8 ) | ( data [ i ] & 0xff ) ; } result = new UUID ( msb , lsb ) ; } } return result ; }
Convert the Primavera string representation of a UUID into a Java UUID instance .
20,508
public static String printUUID ( UUID guid ) { return guid == null ? null : "{" + guid . toString ( ) . toUpperCase ( ) + "}" ; }
Retrieve a UUID in the form required by Primavera PMXML .
20,509
public static final String printTime ( Date value ) { return ( value == null ? null : TIME_FORMAT . get ( ) . format ( value ) ) ; }
Print a time value .
20,510
public void renumberUniqueIDs ( ) { int uid = firstUniqueID ( ) ; for ( T entity : this ) { entity . setUniqueID ( Integer . valueOf ( uid ++ ) ) ; } }
Renumbers all entity unique IDs .
20,511
public void validateUniqueIDsForMicrosoftProject ( ) { if ( ! isEmpty ( ) ) { for ( T entity : this ) { if ( NumberHelper . getInt ( entity . getUniqueID ( ) ) > MS_PROJECT_MAX_UNIQUE_ID ) { renumberUniqueIDs ( ) ; break ; } } } }
Validate that the Unique IDs for the entities in this container are valid for MS Project . If they are not valid i . e one or more of them are too large renumber them .
20,512
private void readDefinitions ( ) { for ( MapRow row : m_tables . get ( "TTL" ) ) { Integer id = row . getInteger ( "DEFINITION_ID" ) ; List < MapRow > list = m_definitions . get ( id ) ; if ( list == null ) { list = new ArrayList < MapRow > ( ) ; m_definitions . put ( id , list ) ; } list . add ( row ) ; } List < MapRow > rows = m_definitions . get ( WBS_FORMAT_ID ) ; if ( rows != null ) { m_wbsFormat = new SureTrakWbsFormat ( rows . get ( 0 ) ) ; } }
Extract definition records from the table and divide into groups .
20,513
private void readCalendars ( ) { Table cal = m_tables . get ( "CAL" ) ; for ( MapRow row : cal ) { ProjectCalendar calendar = m_projectFile . addCalendar ( ) ; m_calendarMap . put ( row . getInteger ( "CALENDAR_ID" ) , calendar ) ; Integer [ ] days = { row . getInteger ( "SUNDAY_HOURS" ) , row . getInteger ( "MONDAY_HOURS" ) , row . getInteger ( "TUESDAY_HOURS" ) , row . getInteger ( "WEDNESDAY_HOURS" ) , row . getInteger ( "THURSDAY_HOURS" ) , row . getInteger ( "FRIDAY_HOURS" ) , row . getInteger ( "SATURDAY_HOURS" ) } ; calendar . setName ( row . getString ( "NAME" ) ) ; readHours ( calendar , Day . SUNDAY , days [ 0 ] ) ; readHours ( calendar , Day . MONDAY , days [ 1 ] ) ; readHours ( calendar , Day . TUESDAY , days [ 2 ] ) ; readHours ( calendar , Day . WEDNESDAY , days [ 3 ] ) ; readHours ( calendar , Day . THURSDAY , days [ 4 ] ) ; readHours ( calendar , Day . FRIDAY , days [ 5 ] ) ; readHours ( calendar , Day . SATURDAY , days [ 6 ] ) ; int workingDaysPerWeek = 0 ; for ( Day day : Day . values ( ) ) { if ( calendar . isWorkingDay ( day ) ) { ++ workingDaysPerWeek ; } } Integer workingHours = null ; for ( int index = 0 ; index < 7 ; index ++ ) { if ( days [ index ] . intValue ( ) != 0 ) { workingHours = days [ index ] ; break ; } } if ( workingHours != null ) { int workingHoursPerDay = countHours ( workingHours ) ; int minutesPerDay = workingHoursPerDay * 60 ; int minutesPerWeek = minutesPerDay * workingDaysPerWeek ; int minutesPerMonth = 4 * minutesPerWeek ; int minutesPerYear = 52 * minutesPerWeek ; calendar . setMinutesPerDay ( Integer . valueOf ( minutesPerDay ) ) ; calendar . setMinutesPerWeek ( Integer . valueOf ( minutesPerWeek ) ) ; calendar . setMinutesPerMonth ( Integer . valueOf ( minutesPerMonth ) ) ; calendar . setMinutesPerYear ( Integer . valueOf ( minutesPerYear ) ) ; } } }
Read project calendars .
20,514
private void readHours ( ProjectCalendar calendar , Day day , Integer hours ) { int value = hours . intValue ( ) ; int startHour = 0 ; ProjectCalendarHours calendarHours = null ; Calendar cal = DateHelper . popCalendar ( ) ; cal . set ( Calendar . HOUR_OF_DAY , 0 ) ; cal . set ( Calendar . MINUTE , 0 ) ; cal . set ( Calendar . SECOND , 0 ) ; cal . set ( Calendar . MILLISECOND , 0 ) ; calendar . setWorkingDay ( day , false ) ; while ( value != 0 ) { while ( startHour < 24 && ( value & 0x1 ) == 0 ) { value = value >> 1 ; ++ startHour ; } if ( startHour >= 24 ) { break ; } int endHour = startHour ; while ( endHour < 24 && ( value & 0x1 ) != 0 ) { value = value >> 1 ; ++ endHour ; } cal . set ( Calendar . HOUR_OF_DAY , startHour ) ; Date startDate = cal . getTime ( ) ; cal . set ( Calendar . HOUR_OF_DAY , endHour ) ; Date endDate = cal . getTime ( ) ; if ( calendarHours == null ) { calendarHours = calendar . addCalendarHours ( day ) ; calendar . setWorkingDay ( day , true ) ; } calendarHours . addRange ( new DateRange ( startDate , endDate ) ) ; startHour = endHour ; } DateHelper . pushCalendar ( cal ) ; }
Reads the integer representation of calendar hours for a given day and populates the calendar .
20,515
private int countHours ( Integer hours ) { int value = hours . intValue ( ) ; int hoursPerDay = 0 ; int hour = 0 ; while ( value > 0 ) { while ( hour < 24 ) { if ( ( value & 0x1 ) != 0 ) { ++ hoursPerDay ; } value = value >> 1 ; ++ hour ; } } return hoursPerDay ; }
Count the number of working hours in a day based in the integer representation of the working hours .
20,516
private void readHolidays ( ) { for ( MapRow row : m_tables . get ( "HOL" ) ) { ProjectCalendar calendar = m_calendarMap . get ( row . getInteger ( "CALENDAR_ID" ) ) ; if ( calendar != null ) { Date date = row . getDate ( "DATE" ) ; ProjectCalendarException exception = calendar . addCalendarException ( date , date ) ; if ( row . getBoolean ( "ANNUAL" ) ) { RecurringData recurring = new RecurringData ( ) ; recurring . setRecurrenceType ( RecurrenceType . YEARLY ) ; recurring . setYearlyAbsoluteFromDate ( date ) ; recurring . setStartDate ( date ) ; exception . setRecurring ( recurring ) ; } } } }
Read holidays from the database and create calendar exceptions .
20,517
private void readActivities ( ) { List < MapRow > items = new ArrayList < MapRow > ( ) ; for ( MapRow row : m_tables . get ( "ACT" ) ) { items . add ( row ) ; } final AlphanumComparator comparator = new AlphanumComparator ( ) ; Collections . sort ( items , new Comparator < MapRow > ( ) { public int compare ( MapRow o1 , MapRow o2 ) { return comparator . compare ( o1 . getString ( "ACTIVITY_ID" ) , o2 . getString ( "ACTIVITY_ID" ) ) ; } } ) ; for ( MapRow row : items ) { String activityID = row . getString ( "ACTIVITY_ID" ) ; String wbs ; if ( m_wbsFormat == null ) { wbs = null ; } else { m_wbsFormat . parseRawValue ( row . getString ( "WBS" ) ) ; wbs = m_wbsFormat . getFormattedValue ( ) ; } ChildTaskContainer parent = m_wbsMap . get ( wbs ) ; if ( parent == null ) { parent = m_projectFile ; } Task task = parent . addTask ( ) ; setFields ( TASK_FIELDS , row , task ) ; task . setStart ( task . getEarlyStart ( ) ) ; task . setFinish ( task . getEarlyFinish ( ) ) ; task . setMilestone ( task . getDuration ( ) . getDuration ( ) == 0 ) ; task . setWBS ( wbs ) ; Duration duration = task . getDuration ( ) ; Duration remainingDuration = task . getRemainingDuration ( ) ; task . setActualDuration ( Duration . getInstance ( duration . getDuration ( ) - remainingDuration . getDuration ( ) , TimeUnit . HOURS ) ) ; m_activityMap . put ( activityID , task ) ; } }
Read activities .
20,518
public void process ( Resource resource , int index , byte [ ] data ) { CostRateTable result = new CostRateTable ( ) ; if ( data != null ) { for ( int i = 16 ; i + 44 <= data . length ; i += 44 ) { Rate standardRate = new Rate ( MPPUtility . getDouble ( data , i ) , TimeUnit . HOURS ) ; TimeUnit standardRateFormat = getFormat ( MPPUtility . getShort ( data , i + 8 ) ) ; Rate overtimeRate = new Rate ( MPPUtility . getDouble ( data , i + 16 ) , TimeUnit . HOURS ) ; TimeUnit overtimeRateFormat = getFormat ( MPPUtility . getShort ( data , i + 24 ) ) ; Double costPerUse = NumberHelper . getDouble ( MPPUtility . getDouble ( data , i + 32 ) / 100.0 ) ; Date endDate = MPPUtility . getTimestampFromTenths ( data , i + 40 ) ; CostRateTableEntry entry = new CostRateTableEntry ( standardRate , standardRateFormat , overtimeRate , overtimeRateFormat , costPerUse , endDate ) ; result . add ( entry ) ; } Collections . sort ( result ) ; } else { if ( index == 0 ) { Rate standardRate = resource . getStandardRate ( ) ; Rate overtimeRate = resource . getOvertimeRate ( ) ; Number costPerUse = resource . getCostPerUse ( ) ; CostRateTableEntry entry = new CostRateTableEntry ( standardRate , standardRate . getUnits ( ) , overtimeRate , overtimeRate . getUnits ( ) , costPerUse , CostRateTableEntry . DEFAULT_ENTRY . getEndDate ( ) ) ; result . add ( entry ) ; } else { result . add ( CostRateTableEntry . DEFAULT_ENTRY ) ; } } resource . setCostRateTable ( index , result ) ; }
Creates a CostRateTable instance from a block of data .
20,519
private TimeUnit getFormat ( int format ) { TimeUnit result ; if ( format == 0xFFFF ) { result = TimeUnit . HOURS ; } else { result = MPPUtility . getWorkTimeUnits ( format ) ; } return result ; }
Converts an integer into a time format .
20,520
public static ConstraintType getInstance ( Locale locale , String type ) { int index = 0 ; String [ ] constraintTypes = LocaleData . getStringArray ( locale , LocaleData . CONSTRAINT_TYPES ) ; for ( int loop = 0 ; loop < constraintTypes . length ; loop ++ ) { if ( constraintTypes [ loop ] . equalsIgnoreCase ( type ) == true ) { index = loop ; break ; } } return ( ConstraintType . getInstance ( index ) ) ; }
This method takes the textual version of a constraint name and returns an appropriate class instance . Note that unrecognised values are treated as As Soon As Possible constraints .
20,521
private static void query ( String filename ) throws Exception { ProjectFile mpx = new UniversalProjectReader ( ) . read ( filename ) ; listProjectProperties ( mpx ) ; listResources ( mpx ) ; listTasks ( mpx ) ; listAssignments ( mpx ) ; listAssignmentsByTask ( mpx ) ; listAssignmentsByResource ( mpx ) ; listHierarchy ( mpx ) ; listTaskNotes ( mpx ) ; listResourceNotes ( mpx ) ; listRelationships ( mpx ) ; listSlack ( mpx ) ; listCalendars ( mpx ) ; }
This method performs a set of queries to retrieve information from the an MPP or an MPX file .
20,522
private static void listProjectProperties ( ProjectFile file ) { SimpleDateFormat df = new SimpleDateFormat ( "dd/MM/yyyy HH:mm z" ) ; ProjectProperties properties = file . getProjectProperties ( ) ; Date startDate = properties . getStartDate ( ) ; Date finishDate = properties . getFinishDate ( ) ; String formattedStartDate = startDate == null ? "(none)" : df . format ( startDate ) ; String formattedFinishDate = finishDate == null ? "(none)" : df . format ( finishDate ) ; System . out . println ( "MPP file type: " + properties . getMppFileType ( ) ) ; System . out . println ( "Project Properties: StartDate=" + formattedStartDate + " FinishDate=" + formattedFinishDate ) ; System . out . println ( ) ; }
Reads basic summary details from the project properties .
20,523
private static void listResources ( ProjectFile file ) { for ( Resource resource : file . getResources ( ) ) { System . out . println ( "Resource: " + resource . getName ( ) + " (Unique ID=" + resource . getUniqueID ( ) + ") Start=" + resource . getStart ( ) + " Finish=" + resource . getFinish ( ) ) ; } System . out . println ( ) ; }
This method lists all resources defined in the file .
20,524
private static void listTasks ( ProjectFile file ) { SimpleDateFormat df = new SimpleDateFormat ( "dd/MM/yyyy HH:mm z" ) ; for ( Task task : file . getTasks ( ) ) { Date date = task . getStart ( ) ; String text = task . getStartText ( ) ; String startDate = text != null ? text : ( date != null ? df . format ( date ) : "(no start date supplied)" ) ; date = task . getFinish ( ) ; text = task . getFinishText ( ) ; String finishDate = text != null ? text : ( date != null ? df . format ( date ) : "(no finish date supplied)" ) ; Duration dur = task . getDuration ( ) ; text = task . getDurationText ( ) ; String duration = text != null ? text : ( dur != null ? dur . toString ( ) : "(no duration supplied)" ) ; dur = task . getActualDuration ( ) ; String actualDuration = dur != null ? dur . toString ( ) : "(no actual duration supplied)" ; String baselineDuration = task . getBaselineDurationText ( ) ; if ( baselineDuration == null ) { dur = task . getBaselineDuration ( ) ; if ( dur != null ) { baselineDuration = dur . toString ( ) ; } else { baselineDuration = "(no duration supplied)" ; } } System . out . println ( "Task: " + task . getName ( ) + " ID=" + task . getID ( ) + " Unique ID=" + task . getUniqueID ( ) + " (Start Date=" + startDate + " Finish Date=" + finishDate + " Duration=" + duration + " Actual Duration" + actualDuration + " Baseline Duration=" + baselineDuration + " Outline Level=" + task . getOutlineLevel ( ) + " Outline Number=" + task . getOutlineNumber ( ) + " Recurring=" + task . getRecurring ( ) + ")" ) ; } System . out . println ( ) ; }
This method lists all tasks defined in the file .
20,525
private static void listHierarchy ( ProjectFile file ) { for ( Task task : file . getChildTasks ( ) ) { System . out . println ( "Task: " + task . getName ( ) + "\t" + task . getStart ( ) + "\t" + task . getFinish ( ) ) ; listHierarchy ( task , " " ) ; } System . out . println ( ) ; }
This method lists all tasks defined in the file in a hierarchical format reflecting the parent - child relationships between them .
20,526
private static void listHierarchy ( Task task , String indent ) { for ( Task child : task . getChildTasks ( ) ) { System . out . println ( indent + "Task: " + child . getName ( ) + "\t" + child . getStart ( ) + "\t" + child . getFinish ( ) ) ; listHierarchy ( child , indent + " " ) ; } }
Helper method called recursively to list child tasks .
20,527
private static void listAssignments ( ProjectFile file ) { Task task ; Resource resource ; String taskName ; String resourceName ; for ( ResourceAssignment assignment : file . getResourceAssignments ( ) ) { task = assignment . getTask ( ) ; if ( task == null ) { taskName = "(null task)" ; } else { taskName = task . getName ( ) ; } resource = assignment . getResource ( ) ; if ( resource == null ) { resourceName = "(null resource)" ; } else { resourceName = resource . getName ( ) ; } System . out . println ( "Assignment: Task=" + taskName + " Resource=" + resourceName ) ; if ( task != null ) { listTimephasedWork ( assignment ) ; } } System . out . println ( ) ; }
This method lists all resource assignments defined in the file .
20,528
private static void listTimephasedWork ( ResourceAssignment assignment ) { Task task = assignment . getTask ( ) ; int days = ( int ) ( ( task . getFinish ( ) . getTime ( ) - task . getStart ( ) . getTime ( ) ) / ( 1000 * 60 * 60 * 24 ) ) + 1 ; if ( days > 1 ) { SimpleDateFormat df = new SimpleDateFormat ( "dd/MM/yy" ) ; TimescaleUtility timescale = new TimescaleUtility ( ) ; ArrayList < DateRange > dates = timescale . createTimescale ( task . getStart ( ) , TimescaleUnits . DAYS , days ) ; TimephasedUtility timephased = new TimephasedUtility ( ) ; ArrayList < Duration > durations = timephased . segmentWork ( assignment . getCalendar ( ) , assignment . getTimephasedWork ( ) , TimescaleUnits . DAYS , dates ) ; for ( DateRange range : dates ) { System . out . print ( df . format ( range . getStart ( ) ) + "\t" ) ; } System . out . println ( ) ; for ( Duration duration : durations ) { System . out . print ( duration . toString ( ) + " " . substring ( 0 , 7 ) + "\t" ) ; } System . out . println ( ) ; } }
Dump timephased work for an assignment .
20,529
private static void listAssignmentsByTask ( ProjectFile file ) { for ( Task task : file . getTasks ( ) ) { System . out . println ( "Assignments for task " + task . getName ( ) + ":" ) ; for ( ResourceAssignment assignment : task . getResourceAssignments ( ) ) { Resource resource = assignment . getResource ( ) ; String resourceName ; if ( resource == null ) { resourceName = "(null resource)" ; } else { resourceName = resource . getName ( ) ; } System . out . println ( " " + resourceName ) ; } } System . out . println ( ) ; }
This method displays the resource assignments for each task . This time rather than just iterating through the list of all assignments in the file we extract the assignments on a task - by - task basis .
20,530
private static void listAssignmentsByResource ( ProjectFile file ) { for ( Resource resource : file . getResources ( ) ) { System . out . println ( "Assignments for resource " + resource . getName ( ) + ":" ) ; for ( ResourceAssignment assignment : resource . getTaskAssignments ( ) ) { Task task = assignment . getTask ( ) ; System . out . println ( " " + task . getName ( ) ) ; } } System . out . println ( ) ; }
This method displays the resource assignments for each resource . This time rather than just iterating through the list of all assignments in the file we extract the assignments on a resource - by - resource basis .
20,531
private static void listTaskNotes ( ProjectFile file ) { for ( Task task : file . getTasks ( ) ) { String notes = task . getNotes ( ) ; if ( notes . length ( ) != 0 ) { System . out . println ( "Notes for " + task . getName ( ) + ": " + notes ) ; } } System . out . println ( ) ; }
This method lists any notes attached to tasks .
20,532
private static void listResourceNotes ( ProjectFile file ) { for ( Resource resource : file . getResources ( ) ) { String notes = resource . getNotes ( ) ; if ( notes . length ( ) != 0 ) { System . out . println ( "Notes for " + resource . getName ( ) + ": " + notes ) ; } } System . out . println ( ) ; }
This method lists any notes attached to resources .
20,533
private static void listRelationships ( ProjectFile file ) { for ( Task task : file . getTasks ( ) ) { System . out . print ( task . getID ( ) ) ; System . out . print ( '\t' ) ; System . out . print ( task . getName ( ) ) ; System . out . print ( '\t' ) ; dumpRelationList ( task . getPredecessors ( ) ) ; System . out . print ( '\t' ) ; dumpRelationList ( task . getSuccessors ( ) ) ; System . out . println ( ) ; } }
This method lists task predecessor and successor relationships .
20,534
private static void dumpRelationList ( List < Relation > relations ) { if ( relations != null && relations . isEmpty ( ) == false ) { if ( relations . size ( ) > 1 ) { System . out . print ( '"' ) ; } boolean first = true ; for ( Relation relation : relations ) { if ( ! first ) { System . out . print ( ',' ) ; } first = false ; System . out . print ( relation . getTargetTask ( ) . getID ( ) ) ; Duration lag = relation . getLag ( ) ; if ( relation . getType ( ) != RelationType . FINISH_START || lag . getDuration ( ) != 0 ) { System . out . print ( relation . getType ( ) ) ; } if ( lag . getDuration ( ) != 0 ) { if ( lag . getDuration ( ) > 0 ) { System . out . print ( "+" ) ; } System . out . print ( lag ) ; } } if ( relations . size ( ) > 1 ) { System . out . print ( '"' ) ; } } }
Internal utility to dump relationship lists in a structured format that can easily be compared with the tabular data in MS Project .
20,535
private static void listSlack ( ProjectFile file ) { for ( Task task : file . getTasks ( ) ) { System . out . println ( task . getName ( ) + " Total Slack=" + task . getTotalSlack ( ) + " Start Slack=" + task . getStartSlack ( ) + " Finish Slack=" + task . getFinishSlack ( ) ) ; } }
List the slack values for each task .
20,536
private static void listCalendars ( ProjectFile file ) { for ( ProjectCalendar cal : file . getCalendars ( ) ) { System . out . println ( cal . toString ( ) ) ; } }
List details of all calendars in the file .
20,537
public ProjectCalendar addDefaultBaseCalendar ( ) { ProjectCalendar calendar = add ( ) ; calendar . setName ( ProjectCalendar . DEFAULT_BASE_CALENDAR_NAME ) ; calendar . setWorkingDay ( Day . SUNDAY , false ) ; calendar . setWorkingDay ( Day . MONDAY , true ) ; calendar . setWorkingDay ( Day . TUESDAY , true ) ; calendar . setWorkingDay ( Day . WEDNESDAY , true ) ; calendar . setWorkingDay ( Day . THURSDAY , true ) ; calendar . setWorkingDay ( Day . FRIDAY , true ) ; calendar . setWorkingDay ( Day . SATURDAY , false ) ; calendar . addDefaultCalendarHours ( ) ; return ( calendar ) ; }
This is a convenience method used to add a calendar called Standard to the project and populate it with a default working week and default working hours .
20,538
public ProjectCalendar addDefaultDerivedCalendar ( ) { ProjectCalendar calendar = add ( ) ; calendar . setWorkingDay ( Day . SUNDAY , DayType . DEFAULT ) ; calendar . setWorkingDay ( Day . MONDAY , DayType . DEFAULT ) ; calendar . setWorkingDay ( Day . TUESDAY , DayType . DEFAULT ) ; calendar . setWorkingDay ( Day . WEDNESDAY , DayType . DEFAULT ) ; calendar . setWorkingDay ( Day . THURSDAY , DayType . DEFAULT ) ; calendar . setWorkingDay ( Day . FRIDAY , DayType . DEFAULT ) ; calendar . setWorkingDay ( Day . SATURDAY , DayType . DEFAULT ) ; return ( calendar ) ; }
This is a convenience method to add a default derived calendar to the project .
20,539
public ProjectCalendar getByName ( String calendarName ) { ProjectCalendar calendar = null ; if ( calendarName != null && calendarName . length ( ) != 0 ) { Iterator < ProjectCalendar > iter = iterator ( ) ; while ( iter . hasNext ( ) == true ) { calendar = iter . next ( ) ; String name = calendar . getName ( ) ; if ( ( name != null ) && ( name . equalsIgnoreCase ( calendarName ) == true ) ) { break ; } calendar = null ; } } return ( calendar ) ; }
Retrieves the named calendar . This method will return null if the named calendar is not located .
20,540
public ProjectFile read ( ) throws MPXJException { MPD9DatabaseReader reader = new MPD9DatabaseReader ( ) ; reader . setProjectID ( m_projectID ) ; reader . setPreserveNoteFormatting ( m_preserveNoteFormatting ) ; reader . setDataSource ( m_dataSource ) ; reader . setConnection ( m_connection ) ; ProjectFile project = reader . read ( ) ; return ( project ) ; }
Read project data from a database .
20,541
public ProjectFile read ( String accessDatabaseFileName ) throws MPXJException { try { Class . forName ( "sun.jdbc.odbc.JdbcOdbcDriver" ) ; String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=" + accessDatabaseFileName ; m_connection = DriverManager . getConnection ( url ) ; m_projectID = Integer . valueOf ( 1 ) ; return ( read ( ) ) ; } catch ( ClassNotFoundException ex ) { throw new MPXJException ( "Failed to load JDBC driver" , ex ) ; } catch ( SQLException ex ) { throw new MPXJException ( "Failed to create connection" , ex ) ; } finally { if ( m_connection != null ) { try { m_connection . close ( ) ; } catch ( SQLException ex ) { } } } }
This is a convenience method which reads the first project from the named MPD file using the JDBC - ODBC bridge driver .
20,542
public static ProjectWriter getProjectWriter ( String name ) throws InstantiationException , IllegalAccessException { int index = name . lastIndexOf ( '.' ) ; if ( index == - 1 ) { throw new IllegalArgumentException ( "Filename has no extension: " + name ) ; } String extension = name . substring ( index + 1 ) . toUpperCase ( ) ; Class < ? extends ProjectWriter > fileClass = WRITER_MAP . get ( extension ) ; if ( fileClass == null ) { throw new IllegalArgumentException ( "Cannot write files of type: " + name ) ; } ProjectWriter file = fileClass . newInstance ( ) ; return ( file ) ; }
Retrieves a ProjectWriter instance which can write a file of the type specified by the supplied file name .
20,543
private void processCustomFieldValues ( ) { byte [ ] data = m_projectProps . getByteArray ( Props . TASK_FIELD_ATTRIBUTES ) ; if ( data != null ) { int index = 0 ; int offset = 0 ; int length = MPPUtility . getInt ( data , offset ) ; offset += 4 ; int numberOfValueLists = MPPUtility . getInt ( data , offset ) ; offset += 4 ; FieldType field ; int valueListOffset = 0 ; while ( index < numberOfValueLists && offset < length ) { field = FieldTypeHelper . getInstance ( MPPUtility . getInt ( data , offset ) ) ; offset += 4 ; valueListOffset = MPPUtility . getInt ( data , offset ) ; offset += 4 ; if ( valueListOffset < data . length ) { int tempOffset = valueListOffset ; tempOffset += 8 ; int dataOffset = MPPUtility . getInt ( data , tempOffset ) + valueListOffset ; tempOffset += 4 ; int endDataOffset = MPPUtility . getInt ( data , tempOffset ) + valueListOffset ; tempOffset += 4 ; int endDescriptionOffset = MPPUtility . getInt ( data , tempOffset ) + valueListOffset ; int valuesLength = endDataOffset - dataOffset ; byte [ ] values = new byte [ valuesLength ] ; MPPUtility . getByteArray ( data , dataOffset , valuesLength , values , 0 ) ; int descriptionsLength = endDescriptionOffset - endDataOffset ; byte [ ] descriptions = new byte [ descriptionsLength ] ; MPPUtility . getByteArray ( data , endDataOffset , descriptionsLength , descriptions , 0 ) ; populateContainer ( field , values , descriptions ) ; } index ++ ; } } }
Reads non outline code custom field values and populates container .
20,544
private void processOutlineCodeValues ( ) throws IOException { DirectoryEntry outlineCodeDir = ( DirectoryEntry ) m_projectDir . getEntry ( "TBkndOutlCode" ) ; FixedMeta fm = new FixedMeta ( new DocumentInputStream ( ( ( DocumentEntry ) outlineCodeDir . getEntry ( "FixedMeta" ) ) ) , 10 ) ; FixedData fd = new FixedData ( fm , new DocumentInputStream ( ( ( DocumentEntry ) outlineCodeDir . getEntry ( "FixedData" ) ) ) ) ; Map < Integer , FieldType > map = new HashMap < Integer , FieldType > ( ) ; int items = fm . getItemCount ( ) ; for ( int loop = 0 ; loop < items ; loop ++ ) { byte [ ] data = fd . getByteArrayValue ( loop ) ; if ( data . length < 18 ) { continue ; } int index = MPPUtility . getShort ( data , 0 ) ; int fieldID = MPPUtility . getInt ( data , 12 ) ; FieldType fieldType = FieldTypeHelper . getInstance ( fieldID ) ; if ( fieldType . getFieldTypeClass ( ) != FieldTypeClass . UNKNOWN ) { map . put ( Integer . valueOf ( index ) , fieldType ) ; } } VarMeta outlineCodeVarMeta = new VarMeta9 ( new DocumentInputStream ( ( ( DocumentEntry ) outlineCodeDir . getEntry ( "VarMeta" ) ) ) ) ; Var2Data outlineCodeVarData = new Var2Data ( outlineCodeVarMeta , new DocumentInputStream ( ( ( DocumentEntry ) outlineCodeDir . getEntry ( "Var2Data" ) ) ) ) ; Map < FieldType , List < Pair < String , String > > > valueMap = new HashMap < FieldType , List < Pair < String , String > > > ( ) ; for ( Integer id : outlineCodeVarMeta . getUniqueIdentifierArray ( ) ) { FieldType fieldType = map . get ( id ) ; String value = outlineCodeVarData . getUnicodeString ( id , VALUE ) ; String description = outlineCodeVarData . getUnicodeString ( id , DESCRIPTION ) ; List < Pair < String , String > > list = valueMap . get ( fieldType ) ; if ( list == null ) { list = new ArrayList < Pair < String , String > > ( ) ; valueMap . put ( fieldType , list ) ; } list . add ( new Pair < String , String > ( value , description ) ) ; } for ( Entry < FieldType , List < Pair < String , String > > > entry : valueMap . entrySet ( ) ) { populateContainer ( entry . getKey ( ) , entry . getValue ( ) ) ; } }
Reads outline code custom field values and populates container .
20,545
private void populateContainer ( FieldType field , byte [ ] values , byte [ ] descriptions ) { CustomField config = m_container . getCustomField ( field ) ; CustomFieldLookupTable table = config . getLookupTable ( ) ; List < Object > descriptionList = convertType ( DataType . STRING , descriptions ) ; List < Object > valueList = convertType ( field . getDataType ( ) , values ) ; for ( int index = 0 ; index < descriptionList . size ( ) ; index ++ ) { CustomFieldValueItem item = new CustomFieldValueItem ( Integer . valueOf ( 0 ) ) ; item . setDescription ( ( String ) descriptionList . get ( index ) ) ; if ( index < valueList . size ( ) ) { item . setValue ( valueList . get ( index ) ) ; } table . add ( item ) ; } }
Populate the container converting raw data into Java types .
20,546
private void populateContainer ( FieldType field , List < Pair < String , String > > items ) { CustomField config = m_container . getCustomField ( field ) ; CustomFieldLookupTable table = config . getLookupTable ( ) ; for ( Pair < String , String > pair : items ) { CustomFieldValueItem item = new CustomFieldValueItem ( Integer . valueOf ( 0 ) ) ; item . setValue ( pair . getFirst ( ) ) ; item . setDescription ( pair . getSecond ( ) ) ; table . add ( item ) ; } }
Populate the container from outline code data .
20,547
private List < Object > convertType ( DataType type , byte [ ] data ) { List < Object > result = new ArrayList < Object > ( ) ; int index = 0 ; while ( index < data . length ) { switch ( type ) { case STRING : { String value = MPPUtility . getUnicodeString ( data , index ) ; result . add ( value ) ; index += ( ( value . length ( ) + 1 ) * 2 ) ; break ; } case CURRENCY : { Double value = Double . valueOf ( MPPUtility . getDouble ( data , index ) / 100 ) ; result . add ( value ) ; index += 8 ; break ; } case NUMERIC : { Double value = Double . valueOf ( MPPUtility . getDouble ( data , index ) ) ; result . add ( value ) ; index += 8 ; break ; } case DATE : { Date value = MPPUtility . getTimestamp ( data , index ) ; result . add ( value ) ; index += 4 ; break ; } case DURATION : { TimeUnit units = MPPUtility . getDurationTimeUnits ( MPPUtility . getShort ( data , index + 4 ) , m_properties . getDefaultDurationUnits ( ) ) ; Duration value = MPPUtility . getAdjustedDuration ( m_properties , MPPUtility . getInt ( data , index ) , units ) ; result . add ( value ) ; index += 6 ; break ; } case BOOLEAN : { Boolean value = Boolean . valueOf ( MPPUtility . getShort ( data , index ) == 1 ) ; result . add ( value ) ; index += 2 ; break ; } default : { index = data . length ; break ; } } } return result ; }
Convert raw data into Java types .
20,548
public boolean getBoolean ( FastTrackField type ) { boolean result = false ; Object value = getObject ( type ) ; if ( value != null ) { result = BooleanHelper . getBoolean ( ( Boolean ) value ) ; } return result ; }
Retrieve a boolean field .
20,549
public Date getTimestamp ( FastTrackField dateName , FastTrackField timeName ) { Date result = null ; Date date = getDate ( dateName ) ; if ( date != null ) { Calendar dateCal = DateHelper . popCalendar ( date ) ; Date time = getDate ( timeName ) ; if ( time != null ) { Calendar timeCal = DateHelper . popCalendar ( time ) ; dateCal . set ( Calendar . HOUR_OF_DAY , timeCal . get ( Calendar . HOUR_OF_DAY ) ) ; dateCal . set ( Calendar . MINUTE , timeCal . get ( Calendar . MINUTE ) ) ; dateCal . set ( Calendar . SECOND , timeCal . get ( Calendar . SECOND ) ) ; dateCal . set ( Calendar . MILLISECOND , timeCal . get ( Calendar . MILLISECOND ) ) ; DateHelper . pushCalendar ( timeCal ) ; } result = dateCal . getTime ( ) ; DateHelper . pushCalendar ( dateCal ) ; } return result ; }
Retrieve a timestamp field .
20,550
public Duration getDuration ( FastTrackField type ) { Double value = ( Double ) getObject ( type ) ; return value == null ? null : Duration . getInstance ( value . doubleValue ( ) , m_table . getDurationTimeUnit ( ) ) ; }
Retrieve a duration field .
20,551
public Duration getWork ( FastTrackField type ) { Double value = ( Double ) getObject ( type ) ; return value == null ? null : Duration . getInstance ( value . doubleValue ( ) , m_table . getWorkTimeUnit ( ) ) ; }
Retrieve a work field .
20,552
public UUID getUUID ( FastTrackField type ) { String value = getString ( type ) ; UUID result = null ; if ( value != null && ! value . isEmpty ( ) && value . length ( ) >= 36 ) { if ( value . startsWith ( "{" ) ) { value = value . substring ( 1 , value . length ( ) - 1 ) ; } if ( value . length ( ) > 16 ) { value = value . substring ( 0 , 36 ) ; } result = UUID . fromString ( value ) ; } return result ; }
Retrieve a UUID field .
20,553
public static CurrencySymbolPosition getSymbolPosition ( int value ) { CurrencySymbolPosition result ; switch ( value ) { case 1 : { result = CurrencySymbolPosition . AFTER ; break ; } case 2 : { result = CurrencySymbolPosition . BEFORE_WITH_SPACE ; break ; } case 3 : { result = CurrencySymbolPosition . AFTER_WITH_SPACE ; break ; } case 0 : default : { result = CurrencySymbolPosition . BEFORE ; break ; } } return ( result ) ; }
This method maps the currency symbol position from the representation used in the MPP file to the representation used by MPX .
20,554
public static final Duration getDuration ( double value , TimeUnit type ) { double duration ; switch ( type ) { case MINUTES : case ELAPSED_MINUTES : { duration = value / 10 ; break ; } case HOURS : case ELAPSED_HOURS : { duration = value / 600 ; break ; } case DAYS : { duration = value / 4800 ; break ; } case ELAPSED_DAYS : { duration = value / 14400 ; break ; } case WEEKS : { duration = value / 24000 ; break ; } case ELAPSED_WEEKS : { duration = value / 100800 ; break ; } case MONTHS : { duration = value / 96000 ; break ; } case ELAPSED_MONTHS : { duration = value / 432000 ; break ; } default : { duration = value ; break ; } } return ( Duration . getInstance ( duration , type ) ) ; }
Reads a duration value . This method relies on the fact that the units of the duration have been specified elsewhere .
20,555
public static void dumpRow ( Map < String , Object > row ) { for ( Entry < String , Object > entry : row . entrySet ( ) ) { Object value = entry . getValue ( ) ; System . out . println ( entry . getKey ( ) + " = " + value + " ( " + ( value == null ? "" : value . getClass ( ) . getName ( ) ) + ")" ) ; } }
Dump the contents of a row from an MPD file .
20,556
public void generateMapFile ( File jarFile , String mapFileName , boolean mapClassMethods ) throws XMLStreamException , IOException , ClassNotFoundException , IntrospectionException { m_responseList = new LinkedList < String > ( ) ; writeMapFile ( mapFileName , jarFile , mapClassMethods ) ; }
Generate a map file from a jar file .
20,557
private void writeMapFile ( String mapFileName , File jarFile , boolean mapClassMethods ) throws IOException , XMLStreamException , ClassNotFoundException , IntrospectionException { FileWriter fw = new FileWriter ( mapFileName ) ; XMLOutputFactory xof = XMLOutputFactory . newInstance ( ) ; XMLStreamWriter writer = xof . createXMLStreamWriter ( fw ) ; writer . writeStartDocument ( ) ; writer . writeStartElement ( "root" ) ; writer . writeStartElement ( "assembly" ) ; addClasses ( writer , jarFile , mapClassMethods ) ; writer . writeEndElement ( ) ; writer . writeEndElement ( ) ; writer . writeEndDocument ( ) ; writer . flush ( ) ; writer . close ( ) ; fw . flush ( ) ; fw . close ( ) ; }
Generate an IKVM map file .
20,558
private void addClasses ( XMLStreamWriter writer , File jarFile , boolean mapClassMethods ) throws IOException , ClassNotFoundException , XMLStreamException , IntrospectionException { ClassLoader currentThreadClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; URLClassLoader loader = new URLClassLoader ( new URL [ ] { jarFile . toURI ( ) . toURL ( ) } , currentThreadClassLoader ) ; JarFile jar = new JarFile ( jarFile ) ; Enumeration < JarEntry > enumeration = jar . entries ( ) ; while ( enumeration . hasMoreElements ( ) ) { JarEntry jarEntry = enumeration . nextElement ( ) ; if ( ! jarEntry . isDirectory ( ) && jarEntry . getName ( ) . endsWith ( ".class" ) ) { addClass ( loader , jarEntry , writer , mapClassMethods ) ; } } jar . close ( ) ; }
Add classes to the map file .
20,559
private void addClass ( URLClassLoader loader , JarEntry jarEntry , XMLStreamWriter writer , boolean mapClassMethods ) throws ClassNotFoundException , XMLStreamException , IntrospectionException { String className = jarEntry . getName ( ) . replaceAll ( "\\.class" , "" ) . replaceAll ( "/" , "." ) ; writer . writeStartElement ( "class" ) ; writer . writeAttribute ( "name" , className ) ; Set < Method > methodSet = new HashSet < Method > ( ) ; Class < ? > aClass = loader . loadClass ( className ) ; processProperties ( writer , methodSet , aClass ) ; if ( mapClassMethods && ! Modifier . isInterface ( aClass . getModifiers ( ) ) ) { processClassMethods ( writer , aClass , methodSet ) ; } writer . writeEndElement ( ) ; }
Add an individual class to the map file .
20,560
private void processProperties ( XMLStreamWriter writer , Set < Method > methodSet , Class < ? > aClass ) throws IntrospectionException , XMLStreamException { BeanInfo beanInfo = Introspector . getBeanInfo ( aClass , aClass . getSuperclass ( ) ) ; PropertyDescriptor [ ] propertyDescriptors = beanInfo . getPropertyDescriptors ( ) ; for ( int i = 0 ; i < propertyDescriptors . length ; i ++ ) { PropertyDescriptor propertyDescriptor = propertyDescriptors [ i ] ; if ( propertyDescriptor . getPropertyType ( ) != null ) { String name = propertyDescriptor . getName ( ) ; Method readMethod = propertyDescriptor . getReadMethod ( ) ; Method writeMethod = propertyDescriptor . getWriteMethod ( ) ; String readMethodName = readMethod == null ? null : readMethod . getName ( ) ; String writeMethodName = writeMethod == null ? null : writeMethod . getName ( ) ; addProperty ( writer , name , propertyDescriptor . getPropertyType ( ) , readMethodName , writeMethodName ) ; if ( readMethod != null ) { methodSet . add ( readMethod ) ; } if ( writeMethod != null ) { methodSet . add ( writeMethod ) ; } } else { processAmbiguousProperty ( writer , methodSet , aClass , propertyDescriptor ) ; } } }
Process class properties .
20,561
private void addProperty ( XMLStreamWriter writer , String name , Class < ? > propertyType , String readMethod , String writeMethod ) throws XMLStreamException { if ( name . length ( ) != 0 ) { writer . writeStartElement ( "property" ) ; String propertyName = name . substring ( 0 , 1 ) . toUpperCase ( ) + name . substring ( 1 ) ; writer . writeAttribute ( "name" , propertyName ) ; String type = getTypeString ( propertyType ) ; writer . writeAttribute ( "sig" , "()" + type ) ; if ( readMethod != null ) { writer . writeStartElement ( "getter" ) ; writer . writeAttribute ( "name" , readMethod ) ; writer . writeAttribute ( "sig" , "()" + type ) ; writer . writeEndElement ( ) ; } if ( writeMethod != null ) { writer . writeStartElement ( "setter" ) ; writer . writeAttribute ( "name" , writeMethod ) ; writer . writeAttribute ( "sig" , "(" + type + ")V" ) ; writer . writeEndElement ( ) ; } writer . writeEndElement ( ) ; } }
Add a simple property to the map file .
20,562
private String getTypeString ( Class < ? > c ) { String result = TYPE_MAP . get ( c ) ; if ( result == null ) { result = c . getName ( ) ; if ( ! result . endsWith ( ";" ) && ! result . startsWith ( "[" ) ) { result = "L" + result + ";" ; } } return result ; }
Converts a class into a signature token .
20,563
private void processClassMethods ( XMLStreamWriter writer , Class < ? > aClass , Set < Method > methodSet ) throws XMLStreamException { Method [ ] methods = aClass . getDeclaredMethods ( ) ; for ( Method method : methods ) { if ( ! methodSet . contains ( method ) && Modifier . isPublic ( method . getModifiers ( ) ) && ! Modifier . isInterface ( method . getModifiers ( ) ) ) { if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { } else { String name = method . getName ( ) ; String methodSignature = createMethodSignature ( method ) ; String fullJavaName = aClass . getCanonicalName ( ) + "." + name + methodSignature ; if ( ! ignoreMethod ( fullJavaName ) ) { writer . writeStartElement ( "method" ) ; writer . writeAttribute ( "name" , name ) ; writer . writeAttribute ( "sig" , methodSignature ) ; writer . writeStartElement ( "attribute" ) ; writer . writeAttribute ( "type" , "System.ComponentModel.EditorBrowsableAttribute" ) ; writer . writeAttribute ( "sig" , "(Lcli.System.ComponentModel.EditorBrowsableState;)V" ) ; writer . writeStartElement ( "parameter" ) ; writer . writeCharacters ( "Never" ) ; writer . writeEndElement ( ) ; writer . writeEndElement ( ) ; writer . writeEndElement ( ) ; name = name . toUpperCase ( ) . charAt ( 0 ) + name . substring ( 1 ) ; writer . writeStartElement ( "method" ) ; writer . writeAttribute ( "name" , name ) ; writer . writeAttribute ( "sig" , methodSignature ) ; writer . writeAttribute ( "modifiers" , "public" ) ; writer . writeStartElement ( "body" ) ; for ( int index = 0 ; index <= method . getParameterTypes ( ) . length ; index ++ ) { if ( index < 4 ) { writer . writeEmptyElement ( "ldarg_" + index ) ; } else { writer . writeStartElement ( "ldarg_s" ) ; writer . writeAttribute ( "argNum" , Integer . toString ( index ) ) ; writer . writeEndElement ( ) ; } } writer . writeStartElement ( "callvirt" ) ; writer . writeAttribute ( "class" , aClass . getName ( ) ) ; writer . writeAttribute ( "name" , method . getName ( ) ) ; writer . writeAttribute ( "sig" , methodSignature ) ; writer . writeEndElement ( ) ; if ( ! method . getReturnType ( ) . getName ( ) . equals ( "void" ) ) { writer . writeEmptyElement ( "ldnull" ) ; writer . writeEmptyElement ( "pop" ) ; } writer . writeEmptyElement ( "ret" ) ; writer . writeEndElement ( ) ; writer . writeEndElement ( ) ; m_responseList . add ( fullJavaName ) ; } } } } }
Hides the original Java - style method name using an attribute which should be respected by Visual Studio the creates a new wrapper method using a . Net style method name .
20,564
private boolean ignoreMethod ( String name ) { boolean result = false ; for ( String ignoredName : IGNORED_METHODS ) { if ( name . matches ( ignoredName ) ) { result = true ; break ; } } return result ; }
Used to determine if the current method should be ignored .
20,565
private String createMethodSignature ( Method method ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "(" ) ; for ( Class < ? > type : method . getParameterTypes ( ) ) { sb . append ( getTypeString ( type ) ) ; } sb . append ( ")" ) ; Class < ? > type = method . getReturnType ( ) ; if ( type . getName ( ) . equals ( "void" ) ) { sb . append ( "V" ) ; } else { sb . append ( getTypeString ( type ) ) ; } return sb . toString ( ) ; }
Creates a method signature .
20,566
public boolean contains ( Date date ) { boolean result = false ; if ( date != null ) { result = ( DateHelper . compare ( getFromDate ( ) , getToDate ( ) , date ) == 0 ) ; } return ( result ) ; }
This method determines whether the given date falls in the range of dates covered by this exception . Note that this method assumes that both the start and end date of this exception have been set .
20,567
public void setModel ( TableModel model ) { super . setModel ( model ) ; int columns = model . getColumnCount ( ) ; TableColumnModel tableColumnModel = getColumnModel ( ) ; for ( int index = 0 ; index < columns ; index ++ ) { tableColumnModel . getColumn ( index ) . setPreferredWidth ( m_columnWidth ) ; } }
Updates the model . Ensures that we reset the columns widths .
20,568
public void process ( MPPReader reader , ProjectFile file , DirectoryEntry root ) throws MPXJException , IOException { try { populateMemberData ( reader , file , root ) ; processProjectProperties ( ) ; if ( ! reader . getReadPropertiesOnly ( ) ) { processSubProjectData ( ) ; processGraphicalIndicators ( ) ; processCustomValueLists ( ) ; processCalendarData ( ) ; processResourceData ( ) ; processTaskData ( ) ; processConstraintData ( ) ; processAssignmentData ( ) ; postProcessTasks ( ) ; if ( reader . getReadPresentationData ( ) ) { processViewPropertyData ( ) ; processTableData ( ) ; processViewData ( ) ; processFilterData ( ) ; processGroupData ( ) ; processSavedViewState ( ) ; } } } finally { clearMemberData ( ) ; } }
This method is used to process an MPP14 file . This is the file format used by Project 14 .
20,569
private void processGraphicalIndicators ( ) { GraphicalIndicatorReader graphicalIndicatorReader = new GraphicalIndicatorReader ( ) ; graphicalIndicatorReader . process ( m_file . getCustomFields ( ) , m_file . getProjectProperties ( ) , m_projectProps ) ; }
Process the graphical indicator data .
20,570
private void readSubProjects ( byte [ ] data , int uniqueIDOffset , int filePathOffset , int fileNameOffset , int subprojectIndex ) { while ( uniqueIDOffset < filePathOffset ) { readSubProject ( data , uniqueIDOffset , filePathOffset , fileNameOffset , subprojectIndex ++ ) ; uniqueIDOffset += 4 ; } }
Read a list of sub projects .
20,571
private void processBaseFonts ( byte [ ] data ) { int offset = 0 ; int blockCount = MPPUtility . getShort ( data , 0 ) ; offset += 2 ; int size ; String name ; for ( int loop = 0 ; loop < blockCount ; loop ++ ) { offset += 2 ; size = MPPUtility . getShort ( data , offset ) ; offset += 2 ; name = MPPUtility . getUnicodeString ( data , offset ) ; offset += 64 ; if ( name . length ( ) != 0 ) { FontBase fontBase = new FontBase ( Integer . valueOf ( loop ) , name , size ) ; m_fontBases . put ( fontBase . getIndex ( ) , fontBase ) ; } } }
Create an index of base font numbers and their associated base font instances .
20,572
private TreeMap < Integer , Integer > createTaskMap ( FieldMap fieldMap , FixedMeta taskFixedMeta , FixedData taskFixedData , Var2Data taskVarData ) { TreeMap < Integer , Integer > taskMap = new TreeMap < Integer , Integer > ( ) ; int uniqueIdOffset = fieldMap . getFixedDataOffset ( TaskField . UNIQUE_ID ) ; Integer taskNameKey = fieldMap . getVarDataKey ( TaskField . NAME ) ; int itemCount = taskFixedMeta . getAdjustedItemCount ( ) ; int uniqueID ; Integer key ; for ( int loop = 3 ; loop < itemCount ; loop ++ ) { byte [ ] data = taskFixedData . getByteArrayValue ( loop ) ; if ( data != null ) { byte [ ] metaData = taskFixedMeta . getByteArrayValue ( loop ) ; int flags = MPPUtility . getInt ( metaData , 0 ) ; if ( ( flags & 0x02 ) != 0 ) { uniqueID = MPPUtility . getShort ( data , TASK_UNIQUE_ID_FIXED_OFFSET ) ; key = Integer . valueOf ( uniqueID ) ; if ( taskMap . containsKey ( key ) == false ) { taskMap . put ( key , null ) ; } } else { if ( data . length == NULL_TASK_BLOCK_SIZE ) { uniqueID = MPPUtility . getInt ( data , TASK_UNIQUE_ID_FIXED_OFFSET ) ; key = Integer . valueOf ( uniqueID ) ; if ( taskMap . containsKey ( key ) == false ) { taskMap . put ( key , Integer . valueOf ( loop ) ) ; } } else { int maxSize = fieldMap . getMaxFixedDataSize ( 0 ) ; if ( maxSize == 0 || ( ( data . length * 100 ) / maxSize ) > 75 ) { uniqueID = MPPUtility . getInt ( data , uniqueIdOffset ) ; key = Integer . valueOf ( uniqueID ) ; if ( ! taskMap . containsKey ( key ) || taskVarData . getUnicodeString ( key , taskNameKey ) != null ) { taskMap . put ( key , Integer . valueOf ( loop ) ) ; } } } } } } return ( taskMap ) ; }
This method maps the task unique identifiers to their index number within the FixedData block .
20,573
private void postProcessTasks ( ) throws MPXJException { TreeMap < Integer , Integer > taskMap = new TreeMap < Integer , Integer > ( ) ; int nextIDIncrement = 102000 ; int nextID = ( m_file . getTaskByUniqueID ( Integer . valueOf ( 0 ) ) == null ? nextIDIncrement : 0 ) ; for ( Map . Entry < Long , Integer > entry : m_taskOrder . entrySet ( ) ) { taskMap . put ( Integer . valueOf ( nextID ) , entry . getValue ( ) ) ; nextID += nextIDIncrement ; } int insertionCount = 0 ; Map < Integer , Integer > offsetMap = new HashMap < Integer , Integer > ( ) ; for ( Map . Entry < Integer , Integer > entry : m_nullTaskOrder . entrySet ( ) ) { int idValue = entry . getKey ( ) . intValue ( ) ; int baseTargetIdValue = ( idValue - insertionCount ) * nextIDIncrement ; int targetIDValue = baseTargetIdValue ; Integer previousOffsetKey = Integer . valueOf ( baseTargetIdValue ) ; Integer previousOffset = offsetMap . get ( previousOffsetKey ) ; int offset = previousOffset == null ? 0 : previousOffset . intValue ( ) + 1 ; ++ insertionCount ; while ( taskMap . containsKey ( Integer . valueOf ( targetIDValue ) ) ) { ++ offset ; if ( offset == nextIDIncrement ) { throw new MPXJException ( "Unable to fix task order" ) ; } targetIDValue = baseTargetIdValue - ( nextIDIncrement - offset ) ; } offsetMap . put ( previousOffsetKey , Integer . valueOf ( offset ) ) ; taskMap . put ( Integer . valueOf ( targetIDValue ) , entry . getValue ( ) ) ; } nextID = ( m_file . getTaskByUniqueID ( Integer . valueOf ( 0 ) ) == null ? 1 : 0 ) ; for ( Map . Entry < Integer , Integer > entry : taskMap . entrySet ( ) ) { Task task = m_file . getTaskByUniqueID ( entry . getValue ( ) ) ; if ( task != null ) { task . setID ( Integer . valueOf ( nextID ) ) ; } nextID ++ ; } }
MPP14 files seem to exhibit some occasional weirdness with duplicate ID values which leads to the task structure being reported incorrectly . The following method attempts to correct this . The method uses ordering data embedded in the file to reconstruct the correct ID order of the tasks .
20,574
private void processHyperlinkData ( Resource resource , byte [ ] data ) { if ( data != null ) { int offset = 12 ; String hyperlink ; String address ; String subaddress ; offset += 12 ; hyperlink = MPPUtility . getUnicodeString ( data , offset ) ; offset += ( ( hyperlink . length ( ) + 1 ) * 2 ) ; offset += 12 ; address = MPPUtility . getUnicodeString ( data , offset ) ; offset += ( ( address . length ( ) + 1 ) * 2 ) ; offset += 12 ; subaddress = MPPUtility . getUnicodeString ( data , offset ) ; resource . setHyperlink ( hyperlink ) ; resource . setHyperlinkAddress ( address ) ; resource . setHyperlinkSubAddress ( subaddress ) ; } }
This method is used to extract the resource hyperlink attributes from a block of data and call the appropriate modifier methods to configure the specified task object .
20,575
private void readBitFields ( MppBitFlag [ ] flags , FieldContainer container , byte [ ] data ) { for ( MppBitFlag flag : flags ) { flag . setValue ( container , data ) ; } }
Iterate through a set of bit field flags and set the value for each one in the supplied container .
20,576
public void read ( InputStream is ) throws IOException { byte [ ] headerBlock = new byte [ 20 ] ; is . read ( headerBlock ) ; int headerLength = PEPUtility . getShort ( headerBlock , 8 ) ; int recordCount = PEPUtility . getInt ( headerBlock , 10 ) ; int recordLength = PEPUtility . getInt ( headerBlock , 16 ) ; StreamHelper . skip ( is , headerLength - headerBlock . length ) ; byte [ ] record = new byte [ recordLength ] ; for ( int recordIndex = 1 ; recordIndex <= recordCount ; recordIndex ++ ) { is . read ( record ) ; readRow ( recordIndex , record ) ; } }
Reads the table data from an input stream and breaks it down into rows .
20,577
protected void addRow ( int uniqueID , Map < String , Object > map ) { m_rows . put ( Integer . valueOf ( uniqueID ) , new MapRow ( map ) ) ; }
Adds a row to the internal storage indexed by primary key .
20,578
public List < TimephasedWork > getCompleteWork ( ProjectCalendar calendar , ResourceAssignment resourceAssignment , byte [ ] data ) { LinkedList < TimephasedWork > list = new LinkedList < TimephasedWork > ( ) ; if ( calendar != null && data != null && data . length > 2 && MPPUtility . getShort ( data , 0 ) > 0 ) { Date startDate = resourceAssignment . getStart ( ) ; double finishTime = MPPUtility . getInt ( data , 24 ) ; int blockCount = MPPUtility . getShort ( data , 0 ) ; double previousCumulativeWork = 0 ; TimephasedWork previousAssignment = null ; int index = 32 ; int currentBlock = 0 ; while ( currentBlock < blockCount && index + 20 <= data . length ) { double time = MPPUtility . getInt ( data , index + 0 ) ; if ( time < 0 || time > finishTime ) { time = 0 ; } else { time /= 80 ; } Duration startWork = Duration . getInstance ( time , TimeUnit . MINUTES ) ; double currentCumulativeWork = ( long ) MPPUtility . getDouble ( data , index + 4 ) ; double assignmentDuration = currentCumulativeWork - previousCumulativeWork ; previousCumulativeWork = currentCumulativeWork ; assignmentDuration /= 1000 ; Duration totalWork = Duration . getInstance ( assignmentDuration , TimeUnit . MINUTES ) ; time = ( long ) MPPUtility . getDouble ( data , index + 12 ) ; time /= 125 ; time *= 6 ; Duration workPerDay = Duration . getInstance ( time , TimeUnit . MINUTES ) ; Date start ; if ( startWork . getDuration ( ) == 0 ) { start = startDate ; } else { start = calendar . getDate ( startDate , startWork , true ) ; } TimephasedWork assignment = new TimephasedWork ( ) ; assignment . setStart ( start ) ; assignment . setAmountPerDay ( workPerDay ) ; assignment . setTotalAmount ( totalWork ) ; if ( previousAssignment != null ) { Date finish = calendar . getDate ( startDate , startWork , false ) ; previousAssignment . setFinish ( finish ) ; if ( previousAssignment . getStart ( ) . getTime ( ) == previousAssignment . getFinish ( ) . getTime ( ) ) { list . removeLast ( ) ; } } list . add ( assignment ) ; previousAssignment = assignment ; index += 20 ; ++ currentBlock ; } if ( previousAssignment != null ) { Duration finishWork = Duration . getInstance ( finishTime / 80 , TimeUnit . MINUTES ) ; Date finish = calendar . getDate ( startDate , finishWork , false ) ; previousAssignment . setFinish ( finish ) ; if ( previousAssignment . getStart ( ) . getTime ( ) == previousAssignment . getFinish ( ) . getTime ( ) ) { list . removeLast ( ) ; } } } return list ; }
Given a block of data representing completed work this method will retrieve a set of TimephasedWork instances which represent the day by day work carried out for a specific resource assignment .
20,579
public boolean getWorkModified ( List < TimephasedWork > list ) { boolean result = false ; for ( TimephasedWork assignment : list ) { result = assignment . getModified ( ) ; if ( result ) { break ; } } return result ; }
Test the list of TimephasedWork instances to see if any of them have been modified .
20,580
public TimephasedWorkContainer getBaselineWork ( ResourceAssignment assignment , ProjectCalendar calendar , TimephasedWorkNormaliser normaliser , byte [ ] data , boolean raw ) { TimephasedWorkContainer result = null ; if ( data != null && data . length > 0 ) { LinkedList < TimephasedWork > list = null ; int index = 8 ; int blockSize = 40 ; double previousCumulativeWorkPerformedInMinutes = 0 ; Date blockStartDate = MPPUtility . getTimestampFromTenths ( data , index + 36 ) ; index += blockSize ; TimephasedWork work = null ; while ( index + blockSize <= data . length ) { double cumulativeWorkInMinutes = ( double ) ( ( long ) MPPUtility . getDouble ( data , index + 20 ) ) / 1000 ; if ( ! Duration . durationValueEquals ( cumulativeWorkInMinutes , previousCumulativeWorkPerformedInMinutes ) ) { double normalActualWorkThisPeriodInMinutes = ( ( double ) MPPUtility . getInt ( data , index + 8 ) ) / 10 ; double normalRemainingWorkThisPeriodInMinutes = ( ( double ) MPPUtility . getInt ( data , index + 28 ) ) / 10 ; double workThisPeriodInMinutes = cumulativeWorkInMinutes - previousCumulativeWorkPerformedInMinutes ; double overtimeWorkThisPeriodInMinutes = workThisPeriodInMinutes - ( normalActualWorkThisPeriodInMinutes + normalRemainingWorkThisPeriodInMinutes ) ; double overtimeFactor = overtimeWorkThisPeriodInMinutes / ( normalActualWorkThisPeriodInMinutes + normalRemainingWorkThisPeriodInMinutes ) ; double normalWorkPerDayInMinutes = 480 ; double overtimeWorkPerDayInMinutes = normalWorkPerDayInMinutes * overtimeFactor ; work = new TimephasedWork ( ) ; work . setFinish ( MPPUtility . getTimestampFromTenths ( data , index + 16 ) ) ; work . setStart ( blockStartDate ) ; work . setTotalAmount ( Duration . getInstance ( workThisPeriodInMinutes , TimeUnit . MINUTES ) ) ; work . setAmountPerDay ( Duration . getInstance ( normalWorkPerDayInMinutes + overtimeWorkPerDayInMinutes , TimeUnit . MINUTES ) ) ; previousCumulativeWorkPerformedInMinutes = cumulativeWorkInMinutes ; if ( list == null ) { list = new LinkedList < TimephasedWork > ( ) ; } list . add ( work ) ; } blockStartDate = MPPUtility . getTimestampFromTenths ( data , index + 36 ) ; index += blockSize ; } if ( list != null ) { if ( work != null ) { work . setFinish ( assignment . getFinish ( ) ) ; } result = new DefaultTimephasedWorkContainer ( calendar , normaliser , list , raw ) ; } } return result ; }
Extracts baseline work from the MPP file for a specific baseline . Returns null if no baseline work is present otherwise returns a list of timephased work items .
20,581
public TimephasedCostContainer getBaselineCost ( ProjectCalendar calendar , TimephasedCostNormaliser normaliser , byte [ ] data , boolean raw ) { TimephasedCostContainer result = null ; if ( data != null && data . length > 0 ) { LinkedList < TimephasedCost > list = null ; int index = 16 ; int blockSize = 20 ; double previousTotalCost = 0 ; Date blockStartDate = MPPUtility . getTimestampFromTenths ( data , index + 16 ) ; index += blockSize ; while ( index + blockSize <= data . length ) { Date blockEndDate = MPPUtility . getTimestampFromTenths ( data , index + 16 ) ; double currentTotalCost = ( double ) ( ( long ) MPPUtility . getDouble ( data , index + 8 ) ) / 100 ; if ( ! costEquals ( previousTotalCost , currentTotalCost ) ) { TimephasedCost cost = new TimephasedCost ( ) ; cost . setStart ( blockStartDate ) ; cost . setFinish ( blockEndDate ) ; cost . setTotalAmount ( Double . valueOf ( currentTotalCost - previousTotalCost ) ) ; if ( list == null ) { list = new LinkedList < TimephasedCost > ( ) ; } list . add ( cost ) ; previousTotalCost = currentTotalCost ; } blockStartDate = blockEndDate ; index += blockSize ; } if ( list != null ) { result = new DefaultTimephasedCostContainer ( calendar , normaliser , list , raw ) ; } } return result ; }
Extracts baseline cost from the MPP file for a specific baseline . Returns null if no baseline cost is present otherwise returns a list of timephased work items .
20,582
public void processSplitData ( Task task , List < TimephasedWork > timephasedComplete , List < TimephasedWork > timephasedPlanned ) { Date splitsComplete = null ; TimephasedWork lastComplete = null ; TimephasedWork firstPlanned = null ; if ( ! timephasedComplete . isEmpty ( ) ) { lastComplete = timephasedComplete . get ( timephasedComplete . size ( ) - 1 ) ; splitsComplete = lastComplete . getFinish ( ) ; } if ( ! timephasedPlanned . isEmpty ( ) ) { firstPlanned = timephasedPlanned . get ( 0 ) ; } LinkedList < DateRange > splits = new LinkedList < DateRange > ( ) ; TimephasedWork lastAssignment = null ; DateRange lastRange = null ; for ( TimephasedWork assignment : timephasedComplete ) { if ( lastAssignment != null && lastRange != null && lastAssignment . getTotalAmount ( ) . getDuration ( ) != 0 && assignment . getTotalAmount ( ) . getDuration ( ) != 0 ) { splits . removeLast ( ) ; lastRange = new DateRange ( lastRange . getStart ( ) , assignment . getFinish ( ) ) ; } else { lastRange = new DateRange ( assignment . getStart ( ) , assignment . getFinish ( ) ) ; } splits . add ( lastRange ) ; lastAssignment = assignment ; } Date splitStart = null ; if ( lastComplete != null && firstPlanned != null && lastComplete . getTotalAmount ( ) . getDuration ( ) != 0 && firstPlanned . getTotalAmount ( ) . getDuration ( ) != 0 ) { lastRange = splits . removeLast ( ) ; splitStart = lastRange . getStart ( ) ; } lastAssignment = null ; lastRange = null ; for ( TimephasedWork assignment : timephasedPlanned ) { if ( splitStart == null ) { if ( lastAssignment != null && lastRange != null && lastAssignment . getTotalAmount ( ) . getDuration ( ) != 0 && assignment . getTotalAmount ( ) . getDuration ( ) != 0 ) { splits . removeLast ( ) ; lastRange = new DateRange ( lastRange . getStart ( ) , assignment . getFinish ( ) ) ; } else { lastRange = new DateRange ( assignment . getStart ( ) , assignment . getFinish ( ) ) ; } } else { lastRange = new DateRange ( splitStart , assignment . getFinish ( ) ) ; } splits . add ( lastRange ) ; splitStart = null ; lastAssignment = assignment ; } if ( splits . size ( ) > 2 ) { task . getSplits ( ) . addAll ( splits ) ; task . setSplitCompleteDuration ( splitsComplete ) ; } else { task . setSplits ( null ) ; task . setSplitCompleteDuration ( null ) ; } }
Process the timephased resource assignment data to work out the split structure of the task .
20,583
private void updateScheduleSource ( ProjectProperties properties ) { if ( properties . getCompany ( ) != null && properties . getCompany ( ) . equals ( "Synchro Software Ltd" ) ) { properties . setFileApplication ( "Synchro" ) ; } else { if ( properties . getAuthor ( ) != null && properties . getAuthor ( ) . equals ( "SG Project" ) ) { properties . setFileApplication ( "Simple Genius" ) ; } else { properties . setFileApplication ( "Microsoft" ) ; } } properties . setFileType ( "MSPDI" ) ; }
Populate the properties indicating the source of this schedule .
20,584
private void readCalendars ( Project project , HashMap < BigInteger , ProjectCalendar > map ) { Project . Calendars calendars = project . getCalendars ( ) ; if ( calendars != null ) { LinkedList < Pair < ProjectCalendar , BigInteger > > baseCalendars = new LinkedList < Pair < ProjectCalendar , BigInteger > > ( ) ; for ( Project . Calendars . Calendar cal : calendars . getCalendar ( ) ) { readCalendar ( cal , map , baseCalendars ) ; } updateBaseCalendarNames ( baseCalendars , map ) ; } try { ProjectProperties properties = m_projectFile . getProjectProperties ( ) ; BigInteger calendarID = new BigInteger ( properties . getDefaultCalendarName ( ) ) ; ProjectCalendar calendar = map . get ( calendarID ) ; m_projectFile . setDefaultCalendar ( calendar ) ; } catch ( Exception ex ) { } }
This method extracts calendar data from an MSPDI file .
20,585
private static void updateBaseCalendarNames ( List < Pair < ProjectCalendar , BigInteger > > baseCalendars , HashMap < BigInteger , ProjectCalendar > map ) { for ( Pair < ProjectCalendar , BigInteger > pair : baseCalendars ) { ProjectCalendar cal = pair . getFirst ( ) ; BigInteger baseCalendarID = pair . getSecond ( ) ; ProjectCalendar baseCal = map . get ( baseCalendarID ) ; if ( baseCal != null ) { cal . setParent ( baseCal ) ; } } }
The way calendars are stored in an MSPDI file means that there can be forward references between the base calendar unique ID for a derived calendar and the base calendar itself . To get around this we initially populate the base calendar name attribute with the base calendar unique ID and now in this method we can convert those ID values into the correct names .
20,586
private void readCalendar ( Project . Calendars . Calendar calendar , HashMap < BigInteger , ProjectCalendar > map , List < Pair < ProjectCalendar , BigInteger > > baseCalendars ) { ProjectCalendar bc = m_projectFile . addCalendar ( ) ; bc . setUniqueID ( NumberHelper . getInteger ( calendar . getUID ( ) ) ) ; bc . setName ( calendar . getName ( ) ) ; BigInteger baseCalendarID = calendar . getBaseCalendarUID ( ) ; if ( baseCalendarID != null ) { baseCalendars . add ( new Pair < ProjectCalendar , BigInteger > ( bc , baseCalendarID ) ) ; } readExceptions ( calendar , bc ) ; boolean readExceptionsFromDays = bc . getCalendarExceptions ( ) . isEmpty ( ) ; Project . Calendars . Calendar . WeekDays days = calendar . getWeekDays ( ) ; if ( days != null ) { for ( Project . Calendars . Calendar . WeekDays . WeekDay weekDay : days . getWeekDay ( ) ) { readDay ( bc , weekDay , readExceptionsFromDays ) ; } } else { bc . setWorkingDay ( Day . SUNDAY , DayType . DEFAULT ) ; bc . setWorkingDay ( Day . MONDAY , DayType . DEFAULT ) ; bc . setWorkingDay ( Day . TUESDAY , DayType . DEFAULT ) ; bc . setWorkingDay ( Day . WEDNESDAY , DayType . DEFAULT ) ; bc . setWorkingDay ( Day . THURSDAY , DayType . DEFAULT ) ; bc . setWorkingDay ( Day . FRIDAY , DayType . DEFAULT ) ; bc . setWorkingDay ( Day . SATURDAY , DayType . DEFAULT ) ; } readWorkWeeks ( calendar , bc ) ; map . put ( calendar . getUID ( ) , bc ) ; m_eventManager . fireCalendarReadEvent ( bc ) ; }
This method extracts data for a single calendar from an MSPDI file .
20,587
private void readDay ( ProjectCalendar calendar , Project . Calendars . Calendar . WeekDays . WeekDay day , boolean readExceptionsFromDays ) { BigInteger dayType = day . getDayType ( ) ; if ( dayType != null ) { if ( dayType . intValue ( ) == 0 ) { if ( readExceptionsFromDays ) { readExceptionDay ( calendar , day ) ; } } else { readNormalDay ( calendar , day ) ; } } }
This method extracts data for a single day from an MSPDI file .
20,588
private void readNormalDay ( ProjectCalendar calendar , Project . Calendars . Calendar . WeekDays . WeekDay weekDay ) { int dayNumber = weekDay . getDayType ( ) . intValue ( ) ; Day day = Day . getInstance ( dayNumber ) ; calendar . setWorkingDay ( day , BooleanHelper . getBoolean ( weekDay . isDayWorking ( ) ) ) ; ProjectCalendarHours hours = calendar . addCalendarHours ( day ) ; Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes times = weekDay . getWorkingTimes ( ) ; if ( times != null ) { for ( Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes . WorkingTime period : times . getWorkingTime ( ) ) { Date startTime = period . getFromTime ( ) ; Date endTime = period . getToTime ( ) ; if ( startTime != null && endTime != null ) { if ( startTime . getTime ( ) >= endTime . getTime ( ) ) { endTime = DateHelper . addDays ( endTime , 1 ) ; } hours . addRange ( new DateRange ( startTime , endTime ) ) ; } } } }
This method extracts data for a normal working day from an MSPDI file .
20,589
private void readExceptionDay ( ProjectCalendar calendar , Project . Calendars . Calendar . WeekDays . WeekDay day ) { Project . Calendars . Calendar . WeekDays . WeekDay . TimePeriod timePeriod = day . getTimePeriod ( ) ; Date fromDate = timePeriod . getFromDate ( ) ; Date toDate = timePeriod . getToDate ( ) ; Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes times = day . getWorkingTimes ( ) ; ProjectCalendarException exception = calendar . addCalendarException ( fromDate , toDate ) ; if ( times != null ) { List < Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes . WorkingTime > time = times . getWorkingTime ( ) ; for ( Project . Calendars . Calendar . WeekDays . WeekDay . WorkingTimes . WorkingTime period : time ) { Date startTime = period . getFromTime ( ) ; Date endTime = period . getToTime ( ) ; if ( startTime != null && endTime != null ) { if ( startTime . getTime ( ) >= endTime . getTime ( ) ) { endTime = DateHelper . addDays ( endTime , 1 ) ; } exception . addRange ( new DateRange ( startTime , endTime ) ) ; } } } }
This method extracts data for an exception day from an MSPDI file .
20,590
private void readExceptions ( Project . Calendars . Calendar calendar , ProjectCalendar bc ) { Project . Calendars . Calendar . Exceptions exceptions = calendar . getExceptions ( ) ; if ( exceptions != null ) { for ( Project . Calendars . Calendar . Exceptions . Exception exception : exceptions . getException ( ) ) { readException ( bc , exception ) ; } } }
Reads any exceptions present in the file . This is only used in MSPDI file versions saved by Project 2007 and later .
20,591
private void readException ( ProjectCalendar bc , Project . Calendars . Calendar . Exceptions . Exception exception ) { Date fromDate = exception . getTimePeriod ( ) . getFromDate ( ) ; Date toDate = exception . getTimePeriod ( ) . getToDate ( ) ; if ( fromDate != null && toDate != null ) { ProjectCalendarException bce = bc . addCalendarException ( fromDate , toDate ) ; bce . setName ( exception . getName ( ) ) ; readRecurringData ( bce , exception ) ; Project . Calendars . Calendar . Exceptions . Exception . WorkingTimes times = exception . getWorkingTimes ( ) ; if ( times != null ) { List < Project . Calendars . Calendar . Exceptions . Exception . WorkingTimes . WorkingTime > time = times . getWorkingTime ( ) ; for ( Project . Calendars . Calendar . Exceptions . Exception . WorkingTimes . WorkingTime period : time ) { Date startTime = period . getFromTime ( ) ; Date endTime = period . getToTime ( ) ; if ( startTime != null && endTime != null ) { if ( startTime . getTime ( ) >= endTime . getTime ( ) ) { endTime = DateHelper . addDays ( endTime , 1 ) ; } bce . addRange ( new DateRange ( startTime , endTime ) ) ; } } } } }
Read a single calendar exception .
20,592
private void readRecurringData ( ProjectCalendarException bce , Project . Calendars . Calendar . Exceptions . Exception exception ) { RecurrenceType rt = getRecurrenceType ( NumberHelper . getInt ( exception . getType ( ) ) ) ; if ( rt != null ) { RecurringData rd = new RecurringData ( ) ; rd . setStartDate ( bce . getFromDate ( ) ) ; rd . setFinishDate ( bce . getToDate ( ) ) ; rd . setRecurrenceType ( rt ) ; rd . setRelative ( getRelative ( NumberHelper . getInt ( exception . getType ( ) ) ) ) ; rd . setOccurrences ( NumberHelper . getInteger ( exception . getOccurrences ( ) ) ) ; switch ( rd . getRecurrenceType ( ) ) { case DAILY : { rd . setFrequency ( getFrequency ( exception ) ) ; break ; } case WEEKLY : { rd . setWeeklyDaysFromBitmap ( NumberHelper . getInteger ( exception . getDaysOfWeek ( ) ) , DAY_MASKS ) ; rd . setFrequency ( getFrequency ( exception ) ) ; break ; } case MONTHLY : { if ( rd . getRelative ( ) ) { rd . setDayOfWeek ( Day . getInstance ( NumberHelper . getInt ( exception . getMonthItem ( ) ) - 2 ) ) ; rd . setDayNumber ( Integer . valueOf ( NumberHelper . getInt ( exception . getMonthPosition ( ) ) + 1 ) ) ; } else { rd . setDayNumber ( NumberHelper . getInteger ( exception . getMonthDay ( ) ) ) ; } rd . setFrequency ( getFrequency ( exception ) ) ; break ; } case YEARLY : { if ( rd . getRelative ( ) ) { rd . setDayOfWeek ( Day . getInstance ( NumberHelper . getInt ( exception . getMonthItem ( ) ) - 2 ) ) ; rd . setDayNumber ( Integer . valueOf ( NumberHelper . getInt ( exception . getMonthPosition ( ) ) + 1 ) ) ; } else { rd . setDayNumber ( NumberHelper . getInteger ( exception . getMonthDay ( ) ) ) ; } rd . setMonthNumber ( Integer . valueOf ( NumberHelper . getInt ( exception . getMonth ( ) ) + 1 ) ) ; break ; } } if ( rd . getRecurrenceType ( ) != RecurrenceType . DAILY || rd . getDates ( ) . length > 1 ) { bce . setRecurring ( rd ) ; } } }
Read recurring data for a calendar exception .
20,593
private Integer getFrequency ( Project . Calendars . Calendar . Exceptions . Exception exception ) { Integer period = NumberHelper . getInteger ( exception . getPeriod ( ) ) ; if ( period == null ) { period = Integer . valueOf ( 1 ) ; } return period ; }
Retrieve the frequency of an exception .
20,594
private void readWorkWeeks ( Project . Calendars . Calendar xmlCalendar , ProjectCalendar mpxjCalendar ) { WorkWeeks ww = xmlCalendar . getWorkWeeks ( ) ; if ( ww != null ) { for ( WorkWeek xmlWeek : ww . getWorkWeek ( ) ) { ProjectCalendarWeek week = mpxjCalendar . addWorkWeek ( ) ; week . setName ( xmlWeek . getName ( ) ) ; Date startTime = xmlWeek . getTimePeriod ( ) . getFromDate ( ) ; Date endTime = xmlWeek . getTimePeriod ( ) . getToDate ( ) ; week . setDateRange ( new DateRange ( startTime , endTime ) ) ; WeekDays xmlWeekDays = xmlWeek . getWeekDays ( ) ; if ( xmlWeekDays != null ) { for ( WeekDay xmlWeekDay : xmlWeekDays . getWeekDay ( ) ) { int dayNumber = xmlWeekDay . getDayType ( ) . intValue ( ) ; Day day = Day . getInstance ( dayNumber ) ; week . setWorkingDay ( day , BooleanHelper . getBoolean ( xmlWeekDay . isDayWorking ( ) ) ) ; ProjectCalendarHours hours = week . addCalendarHours ( day ) ; Project . Calendars . Calendar . WorkWeeks . WorkWeek . WeekDays . WeekDay . WorkingTimes times = xmlWeekDay . getWorkingTimes ( ) ; if ( times != null ) { for ( Project . Calendars . Calendar . WorkWeeks . WorkWeek . WeekDays . WeekDay . WorkingTimes . WorkingTime period : times . getWorkingTime ( ) ) { startTime = period . getFromTime ( ) ; endTime = period . getToTime ( ) ; if ( startTime != null && endTime != null ) { if ( startTime . getTime ( ) >= endTime . getTime ( ) ) { endTime = DateHelper . addDays ( endTime , 1 ) ; } hours . addRange ( new DateRange ( startTime , endTime ) ) ; } } } } } } } }
Read the work weeks associated with this calendar .
20,595
private void readProjectExtendedAttributes ( Project project ) { Project . ExtendedAttributes attributes = project . getExtendedAttributes ( ) ; if ( attributes != null ) { for ( Project . ExtendedAttributes . ExtendedAttribute ea : attributes . getExtendedAttribute ( ) ) { readFieldAlias ( ea ) ; } } }
This method extracts project extended attribute data from an MSPDI file .
20,596
private void readFieldAlias ( Project . ExtendedAttributes . ExtendedAttribute attribute ) { String alias = attribute . getAlias ( ) ; if ( alias != null && alias . length ( ) != 0 ) { FieldType field = FieldTypeHelper . getInstance ( Integer . parseInt ( attribute . getFieldID ( ) ) ) ; m_projectFile . getCustomFields ( ) . getCustomField ( field ) . setAlias ( attribute . getAlias ( ) ) ; } }
Read a single field alias from an extended attribute .
20,597
private void readResources ( Project project , HashMap < BigInteger , ProjectCalendar > calendarMap ) { Project . Resources resources = project . getResources ( ) ; if ( resources != null ) { for ( Project . Resources . Resource resource : resources . getResource ( ) ) { readResource ( resource , calendarMap ) ; } } }
This method extracts resource data from an MSPDI file .
20,598
private void readResourceBaselines ( Project . Resources . Resource xmlResource , Resource mpxjResource ) { for ( Project . Resources . Resource . Baseline baseline : xmlResource . getBaseline ( ) ) { int number = NumberHelper . getInt ( baseline . getNumber ( ) ) ; Double cost = DatatypeConverter . parseCurrency ( baseline . getCost ( ) ) ; Duration work = DatatypeConverter . parseDuration ( m_projectFile , TimeUnit . HOURS , baseline . getWork ( ) ) ; if ( number == 0 ) { mpxjResource . setBaselineCost ( cost ) ; mpxjResource . setBaselineWork ( work ) ; } else { mpxjResource . setBaselineCost ( number , cost ) ; mpxjResource . setBaselineWork ( number , work ) ; } } }
Reads baseline values for the current resource .
20,599
private void readResourceExtendedAttributes ( Project . Resources . Resource xml , Resource mpx ) { for ( Project . Resources . Resource . ExtendedAttribute attrib : xml . getExtendedAttribute ( ) ) { int xmlFieldID = Integer . parseInt ( attrib . getFieldID ( ) ) & 0x0000FFFF ; ResourceField mpxFieldID = MPPResourceField . getInstance ( xmlFieldID ) ; TimeUnit durationFormat = DatatypeConverter . parseDurationTimeUnits ( attrib . getDurationFormat ( ) , null ) ; DatatypeConverter . parseExtendedAttribute ( m_projectFile , mpx , attrib . getValue ( ) , mpxFieldID , durationFormat ) ; } }
This method processes any extended attributes associated with a resource .