Search in sources :

Example 1 with DtObject

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;
}
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 DtObject

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();
}
Also used : SearchQuery(io.vertigo.dynamo.search.model.SearchQuery) DtObject(io.vertigo.dynamo.domain.model.DtObject)

Example 3 with DtObject

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);
}
Also used : Entity(io.vertigo.dynamo.domain.model.Entity) DtObject(io.vertigo.dynamo.domain.model.DtObject) DtObject(io.vertigo.dynamo.domain.model.DtObject) URI(io.vertigo.dynamo.domain.model.URI) FileInfoURI(io.vertigo.dynamo.domain.model.FileInfoURI)

Example 4 with DtObject

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);
}
Also used : Entity(io.vertigo.dynamo.domain.model.Entity) DtObject(io.vertigo.dynamo.domain.model.DtObject)

Example 5 with DtObject

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)");
        }
    }
}
Also used : SearchIndex(io.vertigo.dynamo.search.model.SearchIndex) DtObject(io.vertigo.dynamo.domain.model.DtObject) VSystemException(io.vertigo.lang.VSystemException) KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) VSystemException(io.vertigo.lang.VSystemException)

Aggregations

DtObject (io.vertigo.dynamo.domain.model.DtObject)32 DtField (io.vertigo.dynamo.domain.metamodel.DtField)14 Entity (io.vertigo.dynamo.domain.model.Entity)9 URI (io.vertigo.dynamo.domain.model.URI)8 Type (java.lang.reflect.Type)8 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)5 DtList (io.vertigo.dynamo.domain.model.DtList)5 ParameterizedType (java.lang.reflect.ParameterizedType)5 VFile (io.vertigo.dynamo.file.model.VFile)4 UiContext (io.vertigo.vega.engines.webservice.json.UiContext)4 UiListDelta (io.vertigo.vega.engines.webservice.json.UiListDelta)4 FileInfoURI (io.vertigo.dynamo.domain.model.FileInfoURI)3 Instant (java.time.Instant)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Optional (java.util.Optional)3 JsonObject (com.google.gson.JsonObject)2 CollectionsManager (io.vertigo.dynamo.collections.CollectionsManager)2