public AdvancedModelWrapper loadReferencedModel ( Field field , ModelRegistry modelRegistry , EngineeringDatabaseService edbService , EDBConverter edbConverter ) { try { ModelDescription description = getModelDescriptionFromField ( field ) ; String modelKey = ( String ) FieldUtils . readField ( field , model , true ) ; if ( modelKey == null ) { return null ; } modelKey = appendContextId ( modelKey ) ; Class < ? > sourceClass = modelRegistry . loadModel ( description ) ; Object model = edbConverter . convertEDBObjectToModel ( sourceClass , edbService . getObject ( modelKey ) ) ; return new AdvancedModelWrapper ( ( OpenEngSBModel ) model ) ; } catch ( SecurityException e ) { throw new EKBException ( generateErrorMessage ( field ) , e ) ; } catch ( IllegalArgumentException e ) { throw new EKBException ( generateErrorMessage ( field ) , e ) ; } catch ( IllegalAccessException e ) { throw new EKBException ( generateErrorMessage ( field ) , e ) ; } catch ( ClassNotFoundException e ) { throw new EKBException ( generateErrorMessage ( field ) , e ) ; } }
Loads the model referenced by the given field for the given model instance . Returns null if the field has no value set .