Search in sources :

Example 81 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition in project vertigo by KleeGroup.

the class DAO method getFragment.

/**
 * Récupération d'un fragment persistant par son URI. L'objet doit exister.
 *
 * @param uri URI de l'objet à récupérer
 * @param fragmentClass Fragment class
 * @return F Fragment recherché
 */
public final <F extends Fragment<E>> F getFragment(final URI<E> uri, final Class<F> fragmentClass) {
    final E dto = dataStore.readOne(uri);
    final DtDefinition fragmentDefinition = DtObjectUtil.findDtDefinition(fragmentClass);
    final F fragment = fragmentClass.cast(DtObjectUtil.createDtObject(fragmentDefinition));
    for (final DtField dtField : fragmentDefinition.getFields()) {
        final DataAccessor dataAccessor = dtField.getDataAccessor();
        dataAccessor.setValue(fragment, dataAccessor.getValue(dto));
    // etrange on utilise l'accessor du fragment sur l'entity
    }
    return fragment;
}
Also used : DataAccessor(io.vertigo.dynamo.domain.metamodel.DataAccessor) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 82 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition 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 83 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition in project vertigo by KleeGroup.

the class DataStoreImpl method delete.

/**
 * {@inheritDoc}
 */
@Override
public void delete(final URI<? extends Entity> uri) {
    Assertion.checkNotNull(uri);
    // -----
    final DtDefinition dtDefinition = uri.getDefinition();
    getPhysicalStore(dtDefinition).delete(dtDefinition, uri);
    // -----
    fireAfterCommit(StoreEvent.Type.DELETE, uri);
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition)

Example 84 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition 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 85 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition 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

DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)91 DtField (io.vertigo.dynamo.domain.metamodel.DtField)29 Test (org.junit.Test)21 URI (io.vertigo.dynamo.domain.model.URI)18 List (java.util.List)17 ArrayList (java.util.ArrayList)16 Assertion (io.vertigo.lang.Assertion)12 Collectors (java.util.stream.Collectors)11 Home (io.vertigo.app.Home)10 Optional (java.util.Optional)10 Domain (io.vertigo.dynamo.domain.metamodel.Domain)9 Collections (java.util.Collections)8 DefinitionUtil (io.vertigo.core.definition.DefinitionUtil)7 DtObjectUtil (io.vertigo.dynamo.domain.util.DtObjectUtil)7 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)7 Inject (javax.inject.Inject)7 Authorization (io.vertigo.account.authorization.metamodel.Authorization)6 SecuredEntity (io.vertigo.account.authorization.metamodel.SecuredEntity)6 Criterions (io.vertigo.dynamo.criteria.Criterions)6 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)5