joniles / mpxj

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

Primavera P6 EPPM (Web version): PrimaveraPMFileWriter (xml) - Calendar/ActivityCodeType with type Project is exported to Global xml area instead of Project one #572

Closed alex-matatov closed 1 year ago

alex-matatov commented 1 year ago

P6 allows to create Calendar and ActivityCodeType with Project and Global (scopes). P6 EPPM expects that [Calendar | ActivityCodeType]/Global will be inside <APIBusinessObjects> tag and [Calendar | ActivityCodeType]/Project will be inside <APIBusinessObjects><Project> tag.

However, PrimaveraPMFileWriter exports both Global (correctly) and Project (incorrectly) Calendar/ActivityCodeType inside <APIBusinessObjects> tag. P6 EPPM reports it in import log like below and replaces project based calendar with a default one. (Seems, P6/Desktop does not have this behaviour and is resistant to xml tag location)

Calendar '621001 - 5 Day with H & W (Pave)' (13961) is not being imported as it is a Project calendar which does not belong to this Project.
.....
ActivityCodeType ActivityCodeType 'Specific Work Area - 621001' (6996) with Project scope has been changed to EPS scope under EPS 3667 since Project reference null cannot be resolved.
joniles commented 1 year ago

Fixed! The change is available in the version of MPXJ I've just released.

alex-matatov commented 1 year ago

So quick! Thank you!

alex-matatov commented 1 year ago

Hi Jon,

Unfortunately, the fix broke Primavera P6 EPPM import :( .

Unlike P6/Desktop, P6/EPPM (web version) is sensitive to xml elements order. Seems, if its xml parser expects tag "B" after tag "A" but sees tag "C" it stops to process rest of elements and project is not imported properly.

That is from P6 import log:

.....
ParentEPSObjectId = 3667
For Layout: Project 11968 from xml created Project 653
Project '621001-JV-PBI-1' (653) created according to 11968 from xml
WARNING: ScheduledFinishDate is skipped as this type of object is not recognized or invalid.
WARNING: StartDate is skipped as this type of object is not recognized or invalid.
....

Basically I found out (at least on my test files) that the problem is in <ScheduleOptions> tag position inside <Project>. After the fix it is placed before /APIBusinessObjects/Project/Calendar tag. So P6 EPPM ignores all Project data.

After some experiments I realised that the right <ScheduleOptions> position is after /APIBusinessObjects/Project/Relationship tag.

The fix is quite trivial:

src/main/java/net/sf/mpxj/primavera/schema/ProjectType.java:

@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "ProjectType", propOrder =
{
   "activityDefaultActivityType",
    ............
   "riskMatrixObjectId",
   "riskScore",
   // "scheduleOptions",   <= delete it
   "scheduleWBSHierarchyType",
   ................

   "relationship",
 // scheduleOptions tag position is somewhere between <relationship> and <riskResponseActionImpact>.  
 // in my files I have only <relationship> block so I can say only that the tag position is definitely after relationship
   "scheduleOptions",   <= add it here

   "activityPeriodActual",
   "projectIssue",
   "resourceAssignmentPeriodActual",
   "document",
   "projectDocument",
   "risk",
   "activityRisk",
   "riskImpact",
   "riskResponsePlan",
   "riskResponseAction",
   "riskResponseActionImpact"
}) public class ProjectType
joniles commented 1 year ago

Thanks for the detailed investigation for this one. I had a quick look at the sample files I have to hand and found that the schedule options tag actually appears after the projectDocument tag, so slightly further down in the file. (I don't have any sample files with any of the risk* tags so I'm not sure if it needs to be further down still...) The affected files are actually generated from an XSD schema, so I've corrected that and regenerated the relevant code. I also noticed that baseline projects in PMXML files written by P6 include a schedule options tag, but this was missing from the schema so I've also added that.

joniles commented 1 year ago

I've just published a new release which contains these changes.

alex-matatov commented 1 year ago

thank you!