Menu

#122 All Extended Attributes always added when using MSPDIWriter

closed-fixed
Jon Iles
None
5
2011-03-18
2010-07-12
Anonymous
No

I'm working on a project where we are exporting data from our system to MSPDI XML files using MPXJ and we've found that all of the Extended Attributes specified in the ExtendedAttributeTaskFields.FIELD_ARRAY are always included by the MSPDIWriter, even though we are using only a handful of the extended attributes. I've looked at several ways to change this behavior, but cannot do so without modifying the source to MPXJ and recompiling because all of the variables involved (e.g. FIELD_ARRAY) and classes (MSPDIWriter) are final and cannot be modified/extended to use new logic.

There are several possible ways to solve this issue, but the most obvious is to only include those extended attributes that have an alias in the TaskFieldAliasMap.

Discussion

  • Jon Iles

    Jon Iles - 2010-07-26
    • assigned_to: nobody --> joniles
     
  • Jonathan Besanceney

    I've got the same problem using MSPDIWriter. This writes big files ;)

    I've included a workarround code (tested with ms p....t). Thanks to Jon Iles for this great work.

    private void writeTaskExtendedAttributes(Project.Tasks.Task xml, Task mpx)
    {
    Project.Tasks.Task.ExtendedAttribute attrib;
    List<Project.Tasks.Task.ExtendedAttribute> extendedAttributes = xml.getExtendedAttribute();
    Object value;
    TaskField mpxFieldID;
    Integer xmlFieldID;

    for (int loop = 0; loop < ExtendedAttributeTaskFields.FIELD_ARRAY.length; loop++)
    {
    mpxFieldID = ExtendedAttributeTaskFields.FIELD_ARRAY[loop];
    value = mpx.getCachedValue(mpxFieldID);
    //Don't write attribute if there's no data
    if (value != null && !String.valueOf(value).isEmpty())
    {
    xmlFieldID = Integer.valueOf(MPPTaskField.getID(mpxFieldID) | MPPTaskField.TASK_FIELD_BASE);

    attrib = m_factory.createProjectTasksTaskExtendedAttribute();
    extendedAttributes.add(attrib);
    attrib.setFieldID(xmlFieldID.toString());
    attrib.setValue(DatatypeConverter.printExtendedAttribute(this, value, mpxFieldID.getDataType()));
    attrib.setDurationFormat(printExtendedAttributeDurationFormat(value));
    }
    }
    }

     
  • Jon Iles

    Jon Iles - 2011-03-18

    The code now in CVS fixes this issue.

     
  • Jon Iles

    Jon Iles - 2011-03-18
    • status: open --> closed
     
  • Jon Iles

    Jon Iles - 2011-03-18
    • status: closed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB