private void readResourceCustomFields ( net . sf . mpxj . ganttproject . schema . Resource gpResource , Resource mpxjResource ) { // // Populate custom field default values // Map < FieldType , Object > customFields = new HashMap < FieldType , Object > ( ) ; for ( Pair < FieldType , String > definition : m_resourcePropertyDefinitions . values ( ) ) { customFields . put ( definition . getFirst ( ) , definition . getSecond ( ) ) ; } // // Update with custom field actual values // for ( CustomResourceProperty property : gpResource . getCustomProperty ( ) ) { Pair < FieldType , String > definition = m_resourcePropertyDefinitions . get ( property . getDefinitionId ( ) ) ; if ( definition != null ) { // // Retrieve the value. If it is empty, use the default. // String value = property . getValueAttribute ( ) ; if ( value . isEmpty ( ) ) { value = null ; } // // If we have a value,convert it to the correct type // if ( value != null ) { Object result ; switch ( definition . getFirst ( ) . getDataType ( ) ) { case NUMERIC : { if ( value . indexOf ( ' ' ) == - 1 ) { result = Integer . valueOf ( value ) ; } else { result = Double . valueOf ( value ) ; } break ; } case DATE : { try { result = m_localeDateFormat . parse ( value ) ; } catch ( ParseException ex ) { result = null ; } break ; } case BOOLEAN : { result = Boolean . valueOf ( value . equals ( "true" ) ) ; break ; } default : { result = value ; break ; } } if ( result != null ) { customFields . put ( definition . getFirst ( ) , result ) ; } } } } for ( Map . Entry < FieldType , Object > item : customFields . entrySet ( ) ) { if ( item . getValue ( ) != null ) { mpxjResource . set ( item . getKey ( ) , item . getValue ( ) ) ; } } }
Read custom fields for a GanttProject resource .