use of org.molgenis.data.index.meta.IndexActionGroup 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.IndexActionGroup 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());
}
use of org.molgenis.data.index.meta.IndexActionGroup in project molgenis by molgenis.
the class IndexJobService method executeJob.
public Void executeJob(Progress progress, String transactionId) {
requireNonNull(progress);
IndexActionGroup indexActionGroup = dataService.findOneById(INDEX_ACTION_GROUP, transactionId, IndexActionGroup.class);
if (indexActionGroup != null && indexActionGroup.getCount() > 0) {
progress.setProgressMax(indexActionGroup.getCount());
progress.status(format("Start indexing for transaction id: [{0}]", transactionId));
performIndexActions(progress, transactionId);
progress.status(format("Finished indexing for transaction id: [{0}]", transactionId));
} else {
progress.status(format("No index actions found for transaction id: [{0}]", transactionId));
}
return null;
}
Aggregations