Search in sources :

Example 26 with Entity

use of io.vertigo.dynamo.domain.model.Entity in project vertigo by KleeGroup.

the class RamLuceneIndex method getStringValue.

private static String getStringValue(final DtObject dto, final DtField field) {
    final String stringValue;
    final Object value = field.getDataAccessor().getValue(dto);
    if (value != null) {
        if (field.getType() == DtField.FieldType.FOREIGN_KEY && getStoreManager().getMasterDataConfig().containsMasterData(field.getFkDtDefinition())) {
            // TODO voir pour mise en cache de cette navigation
            final DtListURIForMasterData mdlUri = getStoreManager().getMasterDataConfig().getDtListURIForMasterData(field.getFkDtDefinition());
            final DtField displayField = mdlUri.getDtDefinition().getDisplayField().get();
            final URI<Entity> uri = new URI<>(field.getFkDtDefinition(), value);
            final DtObject fkDto = getStoreManager().getDataStore().readOne(uri);
            final Object displayValue = displayField.getDataAccessor().getValue(fkDto);
            stringValue = displayField.getDomain().valueToString(displayValue);
        } else {
            stringValue = String.valueOf(field.getDataAccessor().getValue(dto));
        }
        return stringValue.trim();
    }
    return null;
}
Also used : Entity(io.vertigo.dynamo.domain.model.Entity) DtObject(io.vertigo.dynamo.domain.model.DtObject) DtObject(io.vertigo.dynamo.domain.model.DtObject) DtListURIForMasterData(io.vertigo.dynamo.domain.model.DtListURIForMasterData) URI(io.vertigo.dynamo.domain.model.URI) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Aggregations

Entity (io.vertigo.dynamo.domain.model.Entity)26 DtObject (io.vertigo.dynamo.domain.model.DtObject)10 URI (io.vertigo.dynamo.domain.model.URI)10 VFile (io.vertigo.dynamo.file.model.VFile)10 DtField (io.vertigo.dynamo.domain.metamodel.DtField)7 FileInfoURI (io.vertigo.dynamo.domain.model.FileInfoURI)7 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)5 DtList (io.vertigo.dynamo.domain.model.DtList)4 DtListURI (io.vertigo.dynamo.domain.model.DtListURI)4 Instant (java.time.Instant)4 Home (io.vertigo.app.Home)3 Criterions (io.vertigo.dynamo.criteria.Criterions)3 InputStreamBuilder (io.vertigo.dynamo.file.model.InputStreamBuilder)3 Assertion (io.vertigo.lang.Assertion)3 Optional (java.util.Optional)3 Set (java.util.Set)3 Inject (javax.inject.Inject)3 Account (io.vertigo.account.account.Account)2 AccountGroup (io.vertigo.account.account.AccountGroup)2 AccountMapperHelper (io.vertigo.account.impl.account.AccountMapperHelper)2