Search in sources :

Example 1 with INDEX_ACTION

use of org.molgenis.data.index.meta.IndexActionMetaData.INDEX_ACTION in project molgenis by molgenis.

the class IndexActionRegisterServiceImpl method storeIndexActions.

@Override
@RunAsSystem
public void storeIndexActions(String transactionId) {
    Set<Impact> changes = getChangesForCurrentTransaction();
    if (changes.isEmpty()) {
        return;
    }
    if (changes.stream().allMatch(impact -> excludedEntities.contains(impact.getEntityTypeId()))) {
        return;
    }
    IndexActionGroup indexActionGroup = indexActionGroupFactory.create(transactionId);
    IndexDependencyModel dependencyModel = createIndexDependencyModel(changes);
    Stream<Impact> impactStream = indexingStrategy.determineImpact(changes, dependencyModel).stream().filter(key -> !excludedEntities.contains(key.getEntityTypeId()));
    List<IndexAction> indexActions = mapWithIndex(impactStream, (key, actionOrder) -> createIndexAction(indexActionGroup, key, (int) actionOrder)).collect(toList());
    if (indexActions.isEmpty()) {
        return;
    }
    LOG.debug("Store index actions for transaction {}", transactionId);
    dataService.add(INDEX_ACTION_GROUP, indexActionGroupFactory.create(transactionId).setCount(indexActions.size()));
    dataService.add(INDEX_ACTION, indexActions.stream());
}
Also used : Impact.createSingleEntityImpact(org.molgenis.data.index.Impact.createSingleEntityImpact) PENDING(org.molgenis.data.index.meta.IndexActionMetaData.IndexStatus.PENDING) LoggerFactory(org.slf4j.LoggerFactory) Fetch(org.molgenis.data.Fetch) QueryImpl(org.molgenis.data.support.QueryImpl) IndexActionFactory(org.molgenis.data.index.meta.IndexActionFactory) RunAsSystem(org.molgenis.security.core.runas.RunAsSystem) TransactionSynchronizationManager(org.springframework.transaction.support.TransactionSynchronizationManager) TRANSACTION_ID_RESOURCE_NAME(org.molgenis.data.transaction.TransactionManager.TRANSACTION_ID_RESOURCE_NAME) ENTITY_TYPE_META_DATA(org.molgenis.data.meta.model.EntityTypeMetadata.ENTITY_TYPE_META_DATA) HashMultimap(com.google.common.collect.HashMultimap) EntityKey(org.molgenis.data.EntityKey) Impact.createSingleEntityImpact(org.molgenis.data.index.Impact.createSingleEntityImpact) Objects.requireNonNull(java.util.Objects.requireNonNull) ATTRIBUTE_META_DATA(org.molgenis.data.meta.model.AttributeMetadata.ATTRIBUTE_META_DATA) REF_ENTITY_TYPE(org.molgenis.data.meta.model.AttributeMetadata.REF_ENTITY_TYPE) Multimaps.synchronizedSetMultimap(com.google.common.collect.Multimaps.synchronizedSetMultimap) Collectors.toSet(java.util.stream.Collectors.toSet) INDEX_ACTION(org.molgenis.data.index.meta.IndexActionMetaData.INDEX_ACTION) Streams.mapWithIndex(com.google.common.collect.Streams.mapWithIndex) IndexActionGroup(org.molgenis.data.index.meta.IndexActionGroup) Logger(org.slf4j.Logger) Collections.emptySet(java.util.Collections.emptySet) Collections.emptyList(java.util.Collections.emptyList) INDEX_ACTION_GROUP(org.molgenis.data.index.meta.IndexActionGroupMetaData.INDEX_ACTION_GROUP) IndexAction(org.molgenis.data.index.meta.IndexAction) Set(java.util.Set) TransactionInformation(org.molgenis.data.transaction.TransactionInformation) EntityType(org.molgenis.data.meta.model.EntityType) SetMultimap(com.google.common.collect.SetMultimap) Sets(com.google.common.collect.Sets) Component(org.springframework.stereotype.Component) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) IndexActionGroupFactory(org.molgenis.data.index.meta.IndexActionGroupFactory) DataService(org.molgenis.data.DataService) Optional(java.util.Optional) ENTITY_TYPE_FETCH(org.molgenis.data.index.IndexDependencyModel.ENTITY_TYPE_FETCH) Transactional(org.springframework.transaction.annotation.Transactional) IndexActionGroup(org.molgenis.data.index.meta.IndexActionGroup) IndexAction(org.molgenis.data.index.meta.IndexAction) RunAsSystem(org.molgenis.security.core.runas.RunAsSystem)

Aggregations

HashMultimap (com.google.common.collect.HashMultimap)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Multimaps.synchronizedSetMultimap (com.google.common.collect.Multimaps.synchronizedSetMultimap)1 SetMultimap (com.google.common.collect.SetMultimap)1 Sets (com.google.common.collect.Sets)1 Streams.mapWithIndex (com.google.common.collect.Streams.mapWithIndex)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.emptySet (java.util.Collections.emptySet)1 List (java.util.List)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 DataService (org.molgenis.data.DataService)1 EntityKey (org.molgenis.data.EntityKey)1 Fetch (org.molgenis.data.Fetch)1 Impact.createSingleEntityImpact (org.molgenis.data.index.Impact.createSingleEntityImpact)1 ENTITY_TYPE_FETCH (org.molgenis.data.index.IndexDependencyModel.ENTITY_TYPE_FETCH)1