Menu

#327 MSPDIWriter does not write Task GUID

v1.0_(example)
closed
Jon Iles
None
5
2018-10-24
2018-05-25
No

Hello,
I'm trying to preserve Task GUIDs between read and write, but the underlying JAXB model class does not have a field for GUID, so it is skipped when writing.

I tried to modify the class, but I think it has been generated somehow (29000 lines O.o) and it crashes my eclipse... :(

Please, can you add it?

Thank you

Discussion

  • Jon Iles

    Jon Iles - 2018-05-25

    Hi, unfortunately MS Project doesn't read or write the task GUID attribute to MSPDI files. The JAXB code has been generated from Microsoft's schema file for MSPDI. I could potentially add a field to support it, but it would be ignored when read by MS Project, and obviously not present when written by MS Project. Bearing this in mind, would the field still be useful to you?

     
  • Michele Mariotti

    Hi, I just "hotpatched" your code, and it's working :)
    I'm attaching the result to show XML and MS Project 2016 reading the GUID correctly.

    I don't know about formal MSPDI schema, but even MS Project 2016 exports this field (and many others) in XML.

    So, even if it is not formally compliant, I'll be very grateful if you can add the field :)

    To made it work I just added the field to Task:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "uid",
        "guid",     // <----- here
        "id",
        ...
    })
    public static class Task
    {
        @XmlElement(name = "UID", required = true, type = String.class)
        @XmlJavaTypeAdapter(Adapter15.class)
        @XmlSchemaType(name = "integer")
        protected Integer uid;
    
        @XmlElement(name = "GUID")    // <----- here
        protected UUID guid;          // <----- here
    
        @XmlElement(name = "ID")
        protected BigInteger id;
    
        ...
    

    to Resource:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "uid",
        "guid",    // <----- here
        "id",
        ...
    })
    public static class Resource
    {
        @XmlElement(name = "UID", required = true, type = String.class)
        @XmlJavaTypeAdapter(Adapter10.class)
        @XmlSchemaType(name = "integer")
        protected Integer uid;
    
        @XmlElement(name = "GUID")    // <----- here
        protected UUID guid;          // <----- here
    
        @XmlElement(name = "ID")
        protected BigInteger id;
    
        ...
    

    and modified MSPDIWriter for tasks:

    private Project.Tasks.Task writeTask(Task mpx)
    {
        Project.Tasks.Task xml = m_factory.createProjectTasksTask();
    
        xml.setActive(Boolean.valueOf(mpx.getActive()));
        xml.setActualCost(DatatypeConverter.printCurrency(mpx.getActualCost()));
        ...
        xml.setFreeSlack(DatatypeConverter.printDurationInIntegerTenthsOfMinutes(mpx.getFreeSlack()));
        xml.setGuid(mpx.getGUID());     // <----- here
        xml.setHideBar(Boolean.valueOf(mpx.getHideBar()));
        ...
    

    and for resources:

    private Project.Resources.Resource writeResource(Resource mpx)
    {
        Project.Resources.Resource xml = m_factory.createProjectResourcesResource();
        ProjectCalendar cal = mpx.getResourceCalendar();
        if(cal != null)
        {
            xml.setCalendarUID(NumberHelper.getBigInteger(cal.getUniqueID()));
        }
    
        xml.setAccrueAt(mpx.getAccrueAt());
        xml.setActiveDirectoryGUID(mpx.getActiveDirectoryGUID());
        ...
        xml.setFinish(DatatypeConverter.printDate(mpx.getFinish()));
        xml.setGroup(mpx.getGroup());
        xml.setGuid(mpx.getGUID());    // <----- here
        xml.setHyperlink(mpx.getHyperlink());
        ...
    
     
  • Michele Mariotti

    Since I just use the lifecycle:

    1. create a MPP file in MS Project
    2. load the MPP file in the application
    3. user modifies something
    4. write a modified XML file
    5. open the XML file with MS Project
    6. user modifies something
    7. save the modified file as MPP
    8. go to point #2

    I didn't note there's also the MSPDIReader class to modify accordingly.

    Thank you very very much

     
  • Jon Iles

    Jon Iles - 2018-05-25

    I've just tried this with MS Project 2016 and MS Project 2016 Pro. I'm not seeing GUIDs being written for tasks. I tried loading your sample file (Z004.mspdi-java.xml) into MS Project 2016 Pro, but the GUIDs in the file are ignored, MS Project generates new GUIDs for the task.

    Can you confirm the version of MS Project you are working with?

     
  • Michele Mariotti

    The file version: 16.0.9226.2156
    Inside Project: Microsoft Project MSO (16.0.9226.2114) 64 bit

     
  • Michele Mariotti

    I'm sorry, I think I made some mistake...

    If I open the XML with MS Project the GUIDs are loaded correctly, but as soon as I "save as" MPP, the GUID are re-assigned :(

     
  • Jon Iles

    Jon Iles - 2018-10-24
    • status: open --> closed
    • assigned_to: Jon Iles
     
  • Jon Iles

    Jon Iles - 2018-10-24

    I've closed this, as per my original comment the MSPDI file format does not include task GUIDs.

     

Log in to post a comment.

MongoDB Logo MongoDB