MetaProperty

Подскажите, как получить значение у ссылочного атрибута строки collectionDs через MetaProperty?

Уточню вопрос:

private void requisiteBuild() {
//        primaryAdressDs.refresh();
        primaryAccountDs.refresh();
//        primaryPhoneDs.refresh();
        String requisite = getItem().getName();
        Collection<MetaProperty> propertys = primaryAccountDs.getMetaClass().getOwnProperties();
        int count = 1;
        StringBuilder sb = new StringBuilder();
        String str = "";
        String str1 = "";
        String msg = "";
        String cls;
        for (AccountBook item : primaryAccountDs.getItems()) {
                for (MetaProperty property : propertys) {
                        str = property.getName();
                        if (!(str.endsWith("companys") | str.endsWith("primary") | str.endsWith("description"))) {
                            if (property.getType() == MetaProperty.Type.DATATYPE) {
                                str1 = item.getValue(str);
                            } else {
                                str1 = item.getValue(str).toString(); <b>//ссылка, а нужно значение</b>
                            }
                            cls = property.getDeclaringClass().getName();
                            msg = messages.getMessage(cls, str, userSessionSource.getLocale());
                            sb.append("\n").append(msg).append(": ").append(str1);
                            count++;
                        }
            }
        }
        requisite += String.valueOf(sb);
        requisiteTextArea.setRows(count);
        requisiteTextArea.setValue(requisite);
    }

Не получается получить значение из ссылки (в коде выделено).
Также не работает получение сообщений messages.

Переписал метод:

private void requisiteBuild() {   
        primaryAdressDs.refresh();   
        primaryAccountDs.refresh();   
        primaryPhoneDs.refresh();   
        String requisite = getItem().getName();   
        int count = 1;   
        StringBuilder sb = new StringBuilder();   
        String str = "";   
        String strBuild = "";   
        String msg = "";   
        Class cls;   
        List<CollectionDatasource<? extends StandardEntity, UUID>> dsource = Arrays.asList(primaryAccountDs, primaryAdressDs, primaryPhoneDs);   
        for (CollectionDatasource<? extends StandardEntity, UUID> ds : dsource) {   
            Collection<MetaProperty> propertys = ds.getMetaClass().getOwnProperties();   
            for (Entity item : ds.getItems()) {   
                for (MetaProperty metaProperty : propertys) {   
                    str = metaProperty.getName();   
                    if (!(str.endsWith("companys") | str.endsWith("primary") | str.endsWith("description"))){   
                        if (metaProperty.getType() == MetaProperty.Type.DATATYPE) {   
                            strBuild = item.getValue(str);   
                        } else {   
                            strBuild = item.getValue(str).toString();   
                        }   
                        if (strBuild != null){   
                            cls = item.getClass();   
                            msg = messages.getMessage(cls, str, userSessionSource.getLocale());   
                            sb.append("\n").append(msg).append(": ").append(strBuild);   
                            count++;   
                        }   
                    }   
                }   
            }   
        }   
        requisite += String.valueOf(sb);   
        requisiteTextArea.setRows(count);   
        requisiteTextArea.setValue(requisite);   
    }   


Возник еще вопрос: как упорядочить коллекцию MetaProperty, чтобы получать значения полей по порядку, как в БД? Установка в Instance name атрибутов в нужном порядке не помогла.
P.S. Вопросы по сообщениям и по упорядочиванию сняты:


Collection<MetaProperty> propertys = metadata.getTools().getNamePatternProperties(ds.getMetaClass());
...
msg = messages.getTools().getPropertyCaption(metaProperty); 

Если вопрос по “ссылке” еще актуален, то, очевидно, вам нужно имя экземпляра:

Entity ref = (Entity) item.getValue(property);
String str = entity.getInstanceName();

Спасибо, заработало: String str = ref.getInstanceName();