Hi I'm using 16.7.0 with Java 21. Disclaimer: I am trying to learn how to use mpxj and I'm using a example P6 .xer file I found online for testing purposes here https://www.onepager.com/solutions/construction/hospital-expansion-project.html
However, even all the .xer you use in your own tests like ProjectDefaultCalendar.xer lead to the same issue. For example the calendar test uses the default reader which is more lenient and doesn't check this price. So they do not detect this problem.
Anyway I encountered ClassCastException when reading the file with setIgnoreErrors(false).
In that .xer file I tested, the project def_cost_per_qty is 100.0000 so
import org.mpxj.primavera.PrimaveraXERFileReader;
public class Repro {
public static void main(String[] args) throws Exception {
var reader = new PrimaveraXERFileReader();
reader.setIgnoreErrors(false);
reader.readAll("Hospital Expansion Project.xer");
}
}
I would expect the file to load successfully and getActivityDefaultPricePerUnit() to return 100.0.
Instead reading fails with ClassCastException: java.lang.String cannot be cast to java.lang.Number in AbstractRow.getDouble, called from TableProjectReader.processProjectProperties.
In your library code, def_cost_per_qty appears to be missing from XerFile.FIELD_TYPE_MAP. So, it defaults to DataType.STRING, but the project reader subsequently requests it through row.getDouble("def_cost_per_qty").
The likely fix might be
FIELD_TYPE_MAP.put("def_cost_per_qty", DataType.NUMERIC);
With setIgnoreErrors(true), the read completes, but getActivityDefaultPricePerUnit() returns null and getIgnoredErrors() is empty so I don't know how I can detect that lost value.
Does that diagnosis look correct?
Hi I'm using 16.7.0 with Java 21. Disclaimer: I am trying to learn how to use mpxj and I'm using a example P6 .xer file I found online for testing purposes here https://www.onepager.com/solutions/construction/hospital-expansion-project.html
However, even all the .xer you use in your own tests like ProjectDefaultCalendar.xer lead to the same issue. For example the calendar test uses the default reader which is more lenient and doesn't check this price. So they do not detect this problem.
Anyway I encountered
ClassCastExceptionwhen reading the file withsetIgnoreErrors(false).In that .xer file I tested, the project def_cost_per_qty is
100.0000soI would expect the file to load successfully and
getActivityDefaultPricePerUnit()to return100.0.Instead reading fails with
ClassCastException: java.lang.String cannot be cast to java.lang.NumberinAbstractRow.getDouble, called fromTableProjectReader.processProjectProperties.In your library code,
def_cost_per_qtyappears to be missing fromXerFile.FIELD_TYPE_MAP. So, it defaults toDataType.STRING, but the project reader subsequently requests it throughrow.getDouble("def_cost_per_qty").The likely fix might be
With
setIgnoreErrors(true), the read completes, butgetActivityDefaultPricePerUnit()returnsnullandgetIgnoredErrors()is empty so I don't know how I can detect that lost value.Does that diagnosis look correct?