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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations