joniles / mpxj

Primary repository for MPXJ library
http://www.mpxj.org/
GNU Lesser General Public License v2.1
240 stars 101 forks source link

Tasks from MPP have one unexpected ResourceAssignment. Why? #692

Closed JanecekPetr closed 2 months ago

JanecekPetr commented 2 months ago

This is a question, not a bug nor a feature request.

In MPP files (and only them as far as I know) task.getResourceAssignments().isEmpty() is never true (except null and summary tasks I think?). They all contain a single ResourceAssignment with Resource == null.

MS Project XML files do not do this. P6 files do not do this. I do not see anything assigned to the Task in MS Project. Still, the surrounding code seems to explicitly support them. Therefore, my question is - What are those, why are they there and can I safely just always ignore them?

joniles commented 2 months ago

My understanding is that resource assignments are an intrinsic part of the way Microsoft Project manages schedule data, so where a task does not have at least one explicit resource assignment, Microsoft Project implicitly creates an assignment for a "null" resource so that (I guess) it can manage all tasks in a consistent way.

MS Project XML files do not do this

These assignments are present in MSPDI files written by Microsoft Project.

If you are creating an MSPDI file and you have a task which is not progressed (i.e. is 0% complete, no actual work) you can get away with not including an implicit assignment in the MSPDI file and the task will appear as expected when read by Microsoft Project. However, if you have actual work recorded against a task, you must have an implicit assignment and must update the attributes it contains in order for the actual work and percent complete to be shown correctly in Project.

can I safely just always ignore them?

If you are just reading a project, then the answer is probably: Project will have rolled up the data you need to the task, so you can get details like actual work, percent complete and so on from the task. If you are writing an MSPDI file then you need them. The MSPDI writer will create them for you for tasks which don't have any explicit resource assignments.

Hope that makes sense!

JanecekPetr commented 2 months ago

These assignments are present in MSPDI files written by Microsoft Project

Hehe. I assume the ones I've seen are coming from Primavera then. I'll report it.

The rest makes complete sense, thank you, will test more and with files actually coming from MSP. This is gold! More incoming in the next days... <3