use of org.molgenis.data.index.meta.IndexActionGroupMetaData.INDEX_ACTION_GROUP in project molgenis by molgenis.
the class IndexJobSchedulerImpl method scheduleIndexJob.
@Override
@RunAsSystem
public void scheduleIndexJob(String transactionId) {
LOG.trace("Index transaction with id {}...", transactionId);
IndexActionGroup indexActionGroup = dataService.findOneById(INDEX_ACTION_GROUP, transactionId, IndexActionGroup.class);
if (indexActionGroup != null) {
Stream<Entity> indexActions = dataService.findAll(INDEX_ACTION, new QueryImpl<>().eq(INDEX_ACTION_GROUP_ATTR, indexActionGroup));
Map<String, Long> numberOfActionsPerEntity = indexActions.collect(groupingBy(indexAction -> indexAction.getString(ENTITY_TYPE_ID), counting()));
indexStatus.addActionCounts(numberOfActionsPerEntity);
IndexJobExecution indexJobExecution = indexJobExecutionFactory.create();
indexJobExecution.setUser("admin");
indexJobExecution.setIndexActionJobID(transactionId);
jobExecutor.submit(indexJobExecution, executorService).whenComplete((a, b) -> indexStatus.removeActionCounts(numberOfActionsPerEntity));
} else {
LOG.debug("No index job found for id [{}].", transactionId);
}
}
use of org.molgenis.data.index.meta.IndexActionGroupMetaData.INDEX_ACTION_GROUP 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