use of io.vertigo.dynamo.domain.model.URI 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.URI in project vertigo by KleeGroup.
the class DataStoreImpl method create.
// --- Transactionnal Event
/**
* {@inheritDoc}
*/
@Override
public <E extends Entity> E create(final E entity) {
Assertion.checkNotNull(entity);
// -----
final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(entity);
final E createdEntity = getPhysicalStore(dtDefinition).create(dtDefinition, entity);
// -----
fireAfterCommit(StoreEvent.Type.CREATE, new URI(dtDefinition, DtObjectUtil.getId(createdEntity)));
// La mise à jour d'un seul élément suffit à rendre le cache obsolète
return createdEntity;
}
use of io.vertigo.dynamo.domain.model.URI in project vertigo by KleeGroup.
the class DataStoreImpl method update.
/**
* {@inheritDoc}
*/
@Override
public void update(final Entity entity) {
Assertion.checkNotNull(entity);
// -----
final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(entity);
getPhysicalStore(dtDefinition).update(dtDefinition, entity);
// -----
fireAfterCommit(StoreEvent.Type.UPDATE, new URI(dtDefinition, DtObjectUtil.getId(entity)));
// La mise à jour d'un seul élément suffit à rendre le cache obsolète
}
use of io.vertigo.dynamo.domain.model.URI in project vertigo by KleeGroup.
the class ReindexTask method run.
/**
* {@inheritDoc}
*/
@Override
public void run() {
long dirtyElementsCount = 0;
do {
final long startTime = System.currentTimeMillis();
final List<URI<? extends KeyConcept>> reindexUris = new ArrayList<>();
try {
synchronized (dirtyElements) {
if (!dirtyElements.isEmpty()) {
reindexUris.addAll(dirtyElements.subList(0, Math.min(dirtyElements.size(), DIRTY_ELEMENTS_CHUNK_SIZE)));
dirtyElements.removeAll(reindexUris);
}
}
dirtyElementsCount = reindexUris.size();
if (!reindexUris.isEmpty()) {
loadAndIndexAndRetry(new SearchChunk(reindexUris), 0);
}
} catch (final Exception e) {
LOGGER.error("Update index error, skip " + dirtyElementsCount + " elements (" + reindexUris + ")", e);
} finally {
LOGGER.log(dirtyElementsCount > 0 ? Level.INFO : Level.DEBUG, "Update index, " + dirtyElementsCount + " " + searchIndexDefinition.getName() + " finished in " + (System.currentTimeMillis() - startTime) + "ms");
}
} while (dirtyElementsCount > 0);
}
use of io.vertigo.dynamo.domain.model.URI in project vertigo by KleeGroup.
the class SearchManagerImpl method markAsDirty.
/**
* {@inheritDoc}
*/
@Override
public void markAsDirty(final List<URI<? extends KeyConcept>> keyConceptUris) {
Assertion.checkNotNull(keyConceptUris);
Assertion.checkArgument(!keyConceptUris.isEmpty(), "dirty keyConceptUris cant be empty");
// -----
final DtDefinition keyConceptDefinition = keyConceptUris.get(0).getDefinition();
final List<SearchIndexDefinition> searchIndexDefinitions = findIndexDefinitionByKeyConcept(keyConceptDefinition);
Assertion.checkNotNull(!searchIndexDefinitions.isEmpty(), "No SearchIndexDefinition was defined for this keyConcept : {0}", keyConceptDefinition.getName());
// -----
for (final SearchIndexDefinition searchIndexDefinition : searchIndexDefinitions) {
final List<URI<? extends KeyConcept>> dirtyElements = dirtyElementsPerIndexName.get(searchIndexDefinition.getName());
synchronized (dirtyElements) {
// TODO : doublons ?
dirtyElements.addAll(keyConceptUris);
}
}
}
Aggregations