Search in sources :

Example 1 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)

Example 2 with Entity

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

the class DbFileStorePlugin method update.

/**
 * {@inheritDoc}
 */
@Override
public void update(final FileInfo fileInfo) {
    checkReadonly();
    Assertion.checkNotNull(fileInfo.getURI() != null, "Only file with an id can be updated.");
    checkDefinitionStoreBinding(fileInfo.getDefinition());
    // -----
    final Entity fileInfoDto = createFileInfoDto(fileInfo);
    // -----
    getStoreManager().getDataStore().update(fileInfoDto);
}
Also used : Entity(io.vertigo.dynamo.domain.model.Entity)

Example 3 with Entity

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

the class DbFileStorePlugin method createFileInfoDto.

private Entity createFileInfoDto(final FileInfo fileInfo) {
    // Il doit exister un DtObjet associé à storeDtDefinition avec la structure attendue.
    final Entity fileInfoDto = DtObjectUtil.createEntity(storeDtDefinition);
    // -----
    final VFile vFile = fileInfo.getVFile();
    setValue(fileInfoDto, DtoFields.FILE_NAME, vFile.getFileName());
    setValue(fileInfoDto, DtoFields.MIME_TYPE, vFile.getMimeType());
    setValue(fileInfoDto, DtoFields.LAST_MODIFIED, vFile.getLastModified());
    setValue(fileInfoDto, DtoFields.LENGTH, vFile.getLength());
    setValue(fileInfoDto, DtoFields.FILE_DATA, new VFileDataStream(vFile));
    if (fileInfo.getURI() != null) {
        setIdValue(fileInfoDto, fileInfo.getURI().getKey());
    }
    return fileInfoDto;
}
Also used : Entity(io.vertigo.dynamo.domain.model.Entity) VFile(io.vertigo.dynamo.file.model.VFile)

Example 4 with Entity

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

the class TwoTablesDbFileStorePlugin method create.

/**
 * {@inheritDoc}
 */
@Override
public FileInfo create(final FileInfo fileInfo) {
    checkReadonly();
    checkDefinitionStoreBinding(fileInfo.getDefinition());
    Assertion.checkArgument(fileInfo.getURI() == null, "Only file without any id can be created");
    // -----
    final Entity fileMetadataDto = createMetaDataEntity(fileInfo);
    final Entity fileEntity = createFileEntity(fileInfo);
    // -----
    getStoreManager().getDataStore().create(fileEntity);
    setValue(fileMetadataDto, DtoFields.FDT_ID, DtObjectUtil.getId(fileEntity));
    getStoreManager().getDataStore().create(fileMetadataDto);
    final FileInfoURI fileInfoUri = createURI(fileInfo.getDefinition(), DtObjectUtil.getId(fileMetadataDto));
    fileInfo.setURIStored(fileInfoUri);
    return fileInfo;
}
Also used : Entity(io.vertigo.dynamo.domain.model.Entity) FileInfoURI(io.vertigo.dynamo.domain.model.FileInfoURI)

Example 5 with Entity

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

the class TwoTablesDbFileStorePlugin method createFileEntity.

private Entity createFileEntity(final FileInfo fileInfo) {
    final Entity fileDataDto = DtObjectUtil.createEntity(storeFileDtDefinition);
    final VFile vFile = fileInfo.getVFile();
    setValue(fileDataDto, DtoFields.FILE_NAME, vFile.getFileName());
    setValue(fileDataDto, DtoFields.FILE_DATA, new VFileDataStream(vFile));
    return fileDataDto;
}
Also used : Entity(io.vertigo.dynamo.domain.model.Entity) VFile(io.vertigo.dynamo.file.model.VFile)

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