MPPReader12/14: Incorrect processing of hierarchical ResourceOutlineCodes
Multi platform library to read and write schedule data
Brought to you by:
joniles
Hi Jon!
If reading the values of hierarchical ResourceOutlineCodes, we get the value of the leaf node only.
Example: CodeValue is 'A.AA', but the method Resource#getOutlineCodeX return 'AA' only.
(For TaskOutlineCodes it works as expected.)
Code to reproduce the issue (File Projekt2.mpp is attached):
net.sf.mpxj.mpp.MPPReader mppReader = new net.sf.mpxj.mpp.MPPReader();
net.sf.mpxj.ProjectFile projectFile = mppReader.read(new java.io.File("Projekt2.mpp"));
net.sf.mpxj.Resource r2 = projectFile.getResources().stream().filter(i -> "Resource 2".equals(i.getName())).findFirst().get();
assertEquals("A.AA", r2.getOutlineCode2());
Possible solution:
Process ResourceOutlineCodeValues the same way as TaskOutlineCodeValues:
This is done in method MPPReader14#processResourceData, starting with line 1684 (master branch from 28.05.2021 16:41:40):
Replace
resource.setOutlineCode1(m_outlineCodeVarData.getUnicodeString(Integer.valueOf(rscVarData.getInt(id, 2, fieldMap.getVarDataKey(ResourceField.OUTLINE_CODE1_INDEX))), OUTLINECODE_DATA));
by
resource.setOutlineCode1(getCustomFieldOutlineCodeValue(rscVarData, m_outlineCodeVarData, id, fieldMap.getVarDataKey(ResourceField.OUTLINE_CODE1_INDEX)));
and the same for the following 9 lines, of course.
It works fine in our tests so far, but i'm not sure if there are any unwanted side-effect, by doing so...
Testfile to reproduce the issue
Thanks for that! I've implemented the suggested change, the code is in Git and will be in the next release.
Great :)
Thanks for fast reply!