Search in sources :

Example 1 with ProgressImpl

use of org.molgenis.jobs.ProgressImpl in project molgenis by molgenis.

the class AnnotationJobFactory method createJob.

@RunAsSystem
public AnnotationJob createJob(AnnotationJobExecution metaData) {
    dataService.add(ANNOTATION_JOB_EXECUTION, metaData);
    String annotatorNames = metaData.getAnnotators();
    String targetName = metaData.getTargetName();
    String username = metaData.getUser();
    // create an authentication to run as the user that is listed as the owner of the job
    RunAsUserToken runAsAuthentication = new RunAsUserToken("Job Execution", username, null, userDetailsService.loadUserByUsername(username).getAuthorities(), null);
    Repository<Entity> repository = dataService.getRepository(targetName);
    List<RepositoryAnnotator> availableAnnotators = annotationService.getAllAnnotators().stream().filter(RepositoryAnnotator::annotationDataExists).collect(toList());
    List<RepositoryAnnotator> requestedAnnotators = Arrays.stream(annotatorNames.split(",")).map(annotationService::getAnnotatorByName).collect(toList());
    AnnotatorDependencyOrderResolver resolver = new AnnotatorDependencyOrderResolver();
    List<RepositoryAnnotator> annotators = Lists.newArrayList(resolver.getAnnotatorSelectionDependencyList(availableAnnotators, requestedAnnotators, repository, entityTypeFactory));
    return new AnnotationJob(crudRepositoryAnnotator, username, annotators, repository, new ProgressImpl(metaData, jobExecutionUpdater, mailSender), runAsAuthentication, new TransactionTemplate(transactionManager));
}
Also used : Entity(org.molgenis.data.Entity) ProgressImpl(org.molgenis.jobs.ProgressImpl) RunAsUserToken(org.springframework.security.access.intercept.RunAsUserToken) RepositoryAnnotator(org.molgenis.data.annotation.core.RepositoryAnnotator) CrudRepositoryAnnotator(org.molgenis.data.annotation.web.CrudRepositoryAnnotator) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) AnnotatorDependencyOrderResolver(org.molgenis.data.annotation.core.utils.AnnotatorDependencyOrderResolver) RunAsSystem(org.molgenis.security.core.runas.RunAsSystem)

Example 2 with ProgressImpl

use of org.molgenis.jobs.ProgressImpl in project molgenis by molgenis.

the class GavinJobFactory method createJob.

@RunAsSystem
public GavinJob createJob(GavinJobExecution gavinJobExecution) {
    dataService.add(gavinJobExecution.getEntityType().getId(), gavinJobExecution);
    String username = gavinJobExecution.getUser();
    // create an authentication to run as the user that is listed as the owner of the job
    RunAsUserToken runAsAuthentication = new RunAsUserToken("Job Execution", username, null, userDetailsService.loadUserByUsername(username).getAuthorities(), null);
    return new GavinJob(new ProgressImpl(gavinJobExecution, jobExecutionUpdater, mailSender), new TransactionTemplate(transactionManager), runAsAuthentication, gavinJobExecution.getIdentifier(), fileStore, menuReaderService, cadd, exac, snpEff, gavin, parser, annotatorRunner, gavinJobExecution);
}
Also used : ProgressImpl(org.molgenis.jobs.ProgressImpl) RunAsUserToken(org.springframework.security.access.intercept.RunAsUserToken) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) RunAsSystem(org.molgenis.security.core.runas.RunAsSystem)

Example 3 with ProgressImpl

use of org.molgenis.jobs.ProgressImpl in project molgenis by molgenis.

the class SortaJobFactory method create.

@RunAsSystem
public SortaJobImpl create(SortaJobExecution jobExecution) {
    TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
    ProgressImpl progress = new ProgressImpl(jobExecution, jobExecutionUpdater, mailSender);
    String username = jobExecution.getUser();
    RunAsUserToken runAsAuthentication = new RunAsUserToken("Job Execution", username, null, userDetailsService.loadUserByUsername(username).getAuthorities(), null);
    SortaJobProcessor matchInputTermBatchService = new SortaJobProcessor(jobExecution.getOntologyIri(), jobExecution.getSourceEntityName(), jobExecution.getResultEntityName(), progress, dataService, sortaService, idGenerator, menuReaderService);
    return new SortaJobImpl(matchInputTermBatchService, runAsAuthentication, progress, transactionTemplate);
}
Also used : ProgressImpl(org.molgenis.jobs.ProgressImpl) RunAsUserToken(org.springframework.security.access.intercept.RunAsUserToken) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) RunAsSystem(org.molgenis.security.core.runas.RunAsSystem)

Aggregations

ProgressImpl (org.molgenis.jobs.ProgressImpl)3 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)3 RunAsUserToken (org.springframework.security.access.intercept.RunAsUserToken)3 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)3 Entity (org.molgenis.data.Entity)1 RepositoryAnnotator (org.molgenis.data.annotation.core.RepositoryAnnotator)1 AnnotatorDependencyOrderResolver (org.molgenis.data.annotation.core.utils.AnnotatorDependencyOrderResolver)1 CrudRepositoryAnnotator (org.molgenis.data.annotation.web.CrudRepositoryAnnotator)1