joniles / mpxj

Primary repository for MPXJ library

Home Page:http://www.mpxj.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

P6: Possibility to delete UserDefinedField

alex-matatov opened this issue · comments

Hi Jon,

Is there a way to delete UserDefinedField properly?

I see that during "read p6 file" step UserDefinedFields are placed to UserDefinedFieldContainer and CustomFieldContainer containers.

UserDefinedFieldContainer has remove method, however I don't see any remove/delete method in CustomFieldContainer. So, even we delete a UserDefinedField from UserDefinedFieldContainer, PrimaveraPMProjectWriter writes it because it is still in CustomFieldContainer.

Would it be possible to add remove method to CustomFieldContainer or maybe to introduce add/remove methods in ProjectFile ?

ProjectFile:

public boolean addUserDefinedField(UserDefinedField udf) {
  m_projectFile.getUserDefinedFields().add(udf);
  m_projectFile.getCustomFields().add(udfType).setAlias(udfType.getName()).setUniqueID(udfType.getUniqueID());
} 

public boolean removeUserDefinedField(UserDefinedField udf) {
  m_projectFile.getUserDefinedFields().remove(udf);
  m_projectFile.getCustomFields().remove(udf); // remove from m_configMap and m_aliasMap
} 

Hi @alex-matatov thanks for the notes. I've added the CustomFieldContainer.remove method, and have also updated UserDefinedField.remove so that it should automatically remove an entry from the CustomFieldContainer for the user defined field you are removing.

@alex-matatov and apologies for the delay in responding!

Thank you for the fix!

Hi Jon,

Just asking.. When are you going to release a new MPXJ version ?

Ideally by the end of this week (15th December), but it may be early next week by the time I wrap up my current changes.