private void writeProjectExtendedAttributes ( Project project ) { Project . ExtendedAttributes attributes = m_factory . createProjectExtendedAttributes ( ) ; project . setExtendedAttributes ( attributes ) ; List < Project . ExtendedAttributes . ExtendedAttribute > list = attributes . getExtendedAttribute ( ) ; Set < FieldType > customFields = new HashSet < FieldType > ( ) ; for ( CustomField customField : m_projectFile . getCustomFields ( ) ) { FieldType fieldType = customField . getFieldType ( ) ; if ( fieldType != null ) { customFields . add ( fieldType ) ; } } customFields . addAll ( m_extendedAttributesInUse ) ; List < FieldType > customFieldsList = new ArrayList < FieldType > ( ) ; customFieldsList . addAll ( customFields ) ; // Sort to ensure consistent order in file final CustomFieldContainer customFieldContainer = m_projectFile . getCustomFields ( ) ; Collections . sort ( customFieldsList , new Comparator < FieldType > ( ) { @ Override public int compare ( FieldType o1 , FieldType o2 ) { CustomField customField1 = customFieldContainer . getCustomField ( o1 ) ; CustomField customField2 = customFieldContainer . getCustomField ( o2 ) ; String name1 = o1 . getClass ( ) . getSimpleName ( ) + "." + o1 . getName ( ) + " " + customField1 . getAlias ( ) ; String name2 = o2 . getClass ( ) . getSimpleName ( ) + "." + o2 . getName ( ) + " " + customField2 . getAlias ( ) ; return name1 . compareTo ( name2 ) ; } } ) ; for ( FieldType fieldType : customFieldsList ) { Project . ExtendedAttributes . ExtendedAttribute attribute = m_factory . createProjectExtendedAttributesExtendedAttribute ( ) ; list . add ( attribute ) ; attribute . setFieldID ( String . valueOf ( FieldTypeHelper . getFieldID ( fieldType ) ) ) ; attribute . setFieldName ( fieldType . getName ( ) ) ; CustomField customField = customFieldContainer . getCustomField ( fieldType ) ; attribute . setAlias ( customField . getAlias ( ) ) ; } }
This method writes project extended attribute data into an MSPDI file .