use of io.vertigo.dynamo.domain.model.DtObject 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.DtObject in project vertigo by KleeGroup.
the class SearchManagerMultiIndexTest method query.
private long query(final String query, final SearchIndexDefinition indexDefinition) {
// recherche
final SearchQuery searchQuery = SearchQuery.builder(ListFilter.of(query)).build();
final FacetedQueryResult<DtObject, SearchQuery> result = searchManager.loadList(indexDefinition, searchQuery, null);
return result.getCount();
}
use of io.vertigo.dynamo.domain.model.DtObject in project vertigo by KleeGroup.
the class TwoTablesDbFileStorePlugin method delete.
/**
* {@inheritDoc}
*/
@Override
public void delete(final FileInfoURI fileInfoUri) {
checkReadonly();
checkDefinitionStoreBinding(fileInfoUri.getDefinition());
// -----
final URI<Entity> dtoMetaDataUri = new URI<>(storeMetaDataDtDefinition, fileInfoUri.getKey());
final DtObject fileMetadataDtoOld = getStoreManager().getDataStore().readOne(dtoMetaDataUri);
final Object fdtId = getValue(fileMetadataDtoOld, DtoFields.FDT_ID, Object.class);
final URI<Entity> dtoDataUri = new URI<>(storeFileDtDefinition, fdtId);
getStoreManager().getDataStore().delete(dtoMetaDataUri);
getStoreManager().getDataStore().delete(dtoDataUri);
}
use of io.vertigo.dynamo.domain.model.DtObject in project vertigo by KleeGroup.
the class FsFileStorePlugin method delete.
/**
* {@inheritDoc}
*/
@Override
public void delete(final FileInfoURI uri) {
Assertion.checkArgument(!readOnly, STORE_READ_ONLY);
final URI<Entity> dtoUri = createDtObjectURI(uri);
// -----suppression du fichier
final DtObject fileInfoDto = getStoreManager().getDataStore().readOne(dtoUri);
final String path = getValue(fileInfoDto, DtoFields.FILE_PATH, String.class);
getCurrentTransaction().addAfterCompletion(new FileActionDelete(documentRoot + path));
// -----suppression en base
getStoreManager().getDataStore().delete(dtoUri);
}
use of io.vertigo.dynamo.domain.model.DtObject in project vertigo by KleeGroup.
the class ReindexAllTask method run.
/**
* {@inheritDoc}
*/
@Override
public void run() {
if (isReindexInProgress()) {
final String warnMessage = "Reindexation of " + searchIndexDefinition.getName() + " is already in progess (" + getReindexCount() + " elements done)";
LOGGER.warn(warnMessage);
reindexFuture.fail(new VSystemException(warnMessage));
} else {
// -----
startReindex();
long reindexCount = 0;
final long startTime = System.currentTimeMillis();
try {
final Class<S> keyConceptClass = (Class<S>) ClassUtil.classForName(searchIndexDefinition.getKeyConceptDtDefinition().getClassCanonicalName(), KeyConcept.class);
final SearchLoader<S, DtObject> searchLoader = Home.getApp().getComponentSpace().resolve(searchIndexDefinition.getSearchLoaderId(), SearchLoader.class);
String lastUri = null;
LOGGER.info("Reindexation of " + searchIndexDefinition.getName() + " started");
for (final SearchChunk<S> searchChunk : searchLoader.chunk(keyConceptClass)) {
final Collection<SearchIndex<S, DtObject>> searchIndexes = searchLoader.loadData(searchChunk);
final String maxUri = String.valueOf(searchChunk.getLastURI().toString());
Assertion.checkState(!maxUri.equals(lastUri), "SearchLoader ({0}) error : return the same uri list", searchIndexDefinition.getSearchLoaderId());
searchManager.removeAll(searchIndexDefinition, urisRangeToListFilter(lastUri, maxUri));
if (!searchIndexes.isEmpty()) {
searchManager.putAll(searchIndexDefinition, searchIndexes);
}
lastUri = maxUri;
reindexCount += searchChunk.getAllURIs().size();
updateReindexCount(reindexCount);
}
// On ne retire pas la fin, il y a un risque de retirer les données ajoutées depuis le démarrage de l'indexation
reindexFuture.success(reindexCount);
} catch (final Exception e) {
LOGGER.error("Reindexation error", e);
reindexFuture.fail(e);
} finally {
stopReindex();
LOGGER.info("Reindexation of " + searchIndexDefinition.getName() + " finished in " + (System.currentTimeMillis() - startTime) + "ms (" + reindexCount + " elements done)");
}
}
}
Aggregations