Search in sources :

Example 31 with URI

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;
}
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 32 with URI

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;
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URI(io.vertigo.dynamo.domain.model.URI) DtListURI(io.vertigo.dynamo.domain.model.DtListURI)

Example 33 with URI

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
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URI(io.vertigo.dynamo.domain.model.URI) DtListURI(io.vertigo.dynamo.domain.model.DtListURI)

Example 34 with URI

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);
}
Also used : SearchChunk(io.vertigo.dynamo.search.metamodel.SearchChunk) KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) ArrayList(java.util.ArrayList) URI(io.vertigo.dynamo.domain.model.URI)

Example 35 with URI

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);
        }
    }
}
Also used : KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URI(io.vertigo.dynamo.domain.model.URI)

Aggregations

URI (io.vertigo.dynamo.domain.model.URI)38 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)21 DtField (io.vertigo.dynamo.domain.metamodel.DtField)11 Entity (io.vertigo.dynamo.domain.model.Entity)10 ArrayList (java.util.ArrayList)10 DtObject (io.vertigo.dynamo.domain.model.DtObject)9 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)8 DtListURI (io.vertigo.dynamo.domain.model.DtListURI)7 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)6 DtList (io.vertigo.dynamo.domain.model.DtList)5 Account (io.vertigo.account.account.Account)4 AccountGroup (io.vertigo.account.account.AccountGroup)4 Home (io.vertigo.app.Home)4 AssociationNNDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)4 FileInfoURI (io.vertigo.dynamo.domain.model.FileInfoURI)4 KeyConcept (io.vertigo.dynamo.domain.model.KeyConcept)4 VFile (io.vertigo.dynamo.file.model.VFile)4 SearchIndex (io.vertigo.dynamo.search.model.SearchIndex)4 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)4 Task (io.vertigo.dynamo.task.model.Task)4