use of org.molgenis.data.annotation.web.CrudRepositoryAnnotator 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));
}
Aggregations