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