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;
}
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;
}
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);
}
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
}
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);
}
}
}
Aggregations