code: public void synchronizeTaskIDToHierarchy()
     {
        clear();
  
        int currentID = (getByID(Integer.valueOf(0)) == null ? 1 : 0);
        for (Task task : m_projectFile.getChildTasks())
        {
           task.setID(Integer.valueOf(currentID++));
           add(task);
           currentID = synchroizeTaskIDToHierarchy(task, currentID);
        }
     }
docs: Microsoft Project bases the order of tasks displayed on their ID
  value. This method takes the hierarchical structure of tasks
  represented in MPXJ and renumbers the ID values to ensure that
  this structure is displayed as expected in Microsoft Project. This
  is typically used to deal with the case where a hierarchical task
  structure has been created programmatically in MPXJ.