use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class ItemSearchLoader method loadData.
/**
* {@inheritDoc}
*/
@Override
public List<SearchIndex<Item, Item>> loadData(final SearchChunk<Item> searchChunk) {
Assertion.checkNotNull(itemDataBase, "itemDataBase not bound");
// -----
final SearchIndexDefinition indexDefinition = searchManager.findFirstIndexDefinitionByKeyConcept(Item.class);
final List<SearchIndex<Item, Item>> itemIndexes = new ArrayList<>();
final Map<Long, Item> itemPerId = new HashMap<>();
for (final Item item : itemDataBase.getAllItems()) {
itemPerId.put(item.getId(), item);
}
for (final URI<Item> uri : searchChunk.getAllURIs()) {
final Item item = itemPerId.get(uri.getId());
itemIndexes.add(SearchIndex.createIndex(indexDefinition, uri, item));
}
return itemIndexes;
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class SearchManagerMultiIndexTest method testClean.
/**
* Test de création nettoyage de l'index.
* La création s'effectue dans une seule transaction.
*/
@Test
public void testClean() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final SearchIndexDefinition itemIndexDefinition = definitionSpace.resolve(IDX_ITEM, SearchIndexDefinition.class);
final SearchIndexDefinition itemDynIndexDefinition = definitionSpace.resolve(IDX_DYNA_ITEM, SearchIndexDefinition.class);
final ListFilter removeQuery = ListFilter.of("*:*");
searchManager.removeAll(itemIndexDefinition, removeQuery);
searchManager.removeAll(itemDynIndexDefinition, removeQuery);
waitIndexation();
final long size = query("*:*", itemIndexDefinition);
Assert.assertEquals(0, size);
final long sizeDyn = query("*:*", itemDynIndexDefinition);
Assert.assertEquals(0, sizeDyn);
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class ItemSearchLoader method loadData.
/**
* {@inheritDoc}
*/
@Override
public List<SearchIndex<Item, Item>> loadData(final SearchChunk<Item> searchChunk) {
final SearchIndexDefinition indexDefinition = searchManager.findFirstIndexDefinitionByKeyConcept(Item.class);
try (final VTransactionWritable tx = getTransactionManager().createCurrentTransaction()) {
final List<SearchIndex<Item, Item>> result = new ArrayList<>();
final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(Item.class);
for (final Item item : loadItems(searchChunk)) {
final URI<Item> uri = new URI<>(dtDefinition, item.getId());
result.add(SearchIndex.createIndex(indexDefinition, uri, item));
}
return result;
}
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class SearchDynamicRegistry method createIndexDefinition.
private static SearchIndexDefinition createIndexDefinition(final DefinitionSpace definitionSpace, final DslDefinition xsearchObjet) {
final DtDefinition keyConceptDtDefinition = definitionSpace.resolve(xsearchObjet.getDefinitionLinkName("keyConcept"), DtDefinition.class);
final DtDefinition indexDtDefinition = definitionSpace.resolve(xsearchObjet.getDefinitionLinkName("dtIndex"), DtDefinition.class);
final String definitionName = xsearchObjet.getName();
// Déclaration des copyField
final Map<DtField, List<DtField>> copyFields = populateCopyFields(xsearchObjet, indexDtDefinition);
final String searchLoaderId = (String) xsearchObjet.getPropertyValue(SearchGrammar.SEARCH_LOADER_PROPERTY);
return new SearchIndexDefinition(definitionName, keyConceptDtDefinition, indexDtDefinition, copyFields, searchLoaderId);
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition 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