/** * Saves execution in the current thread, then creates a Job and submits that for asynchronous * execution. * * @param jobExecution the {@link JobExecution} to save and submit. */ public CompletableFuture<Void> submit(JobExecution jobExecution) { return submit(jobExecution, executorService); }
@Override public JobExecution downloadResources(List<ResourceIdentifier> resources) { if (resources.isEmpty()) { throw new IllegalArgumentException(MESSAGE_EMPTY_RESOURCES); } ResourceDownloadJobExecution jobExecution = downloadJobExecutionFactory.create(); jobExecution.setResources(resources); jobExecutor.submit(jobExecution); return jobExecution; }
@Transactional @Override public JobExecution deleteResources(List<ResourceIdentifier> resources) { if (resources.isEmpty()) { throw new IllegalArgumentException(MESSAGE_EMPTY_RESOURCES); } ResourceDeleteJobExecution jobExecution = resourceDeleteJobExecutionFactory.create(); jobExecution.setResources(resources); jobExecutor.submit(jobExecution); return jobExecution; }
@ResponseBody @PostMapping(value = "/upload", produces = MediaType.TEXT_HTML_VALUE) public String importFile(@RequestParam(value = "file") MultipartFile multipartFile) throws IOException { String filename = multipartFile.getOriginalFilename(); try (InputStream inputStream = multipartFile.getInputStream()) { fileStore.store(inputStream, filename); } OneClickImportJobExecution jobExecution = oneClickImportJobExecutionFactory.create(); jobExecution.setFile(filename); jobExecutor.submit(jobExecution); return concatEntityHref(jobExecution); }
@Override public JobExecution copyResources( List<ResourceIdentifier> resources, @Nullable String targetFolderId) { if (resources.isEmpty()) { throw new IllegalArgumentException(MESSAGE_EMPTY_RESOURCES); } Package aPackage = getPackage(targetFolderId); ResourceCopyJobExecution jobExecution = copyJobExecutionFactory.create(); jobExecution.setResources(resources); jobExecution.setTargetPackage(aPackage != null ? aPackage.getId() : null); jobExecutor.submit(jobExecution); return jobExecution; }
/** * Schedules a mappingJob for the current user. * * @param mappingProjectId ID for the mapping project to run * @param targetEntityTypeId ID for the integrated dataset * @param addSourceAttribute indication if a source attribute should be added to the target {@link * EntityType} * @return the HREF for the scheduled {@link MappingJobExecution} */ @PostMapping(value = "/submit", produces = TEXT_PLAIN_VALUE) public ResponseEntity<String> submitMappingJob( @RequestParam String mappingProjectId, @RequestParam String targetEntityTypeId, @RequestParam(required = false) Boolean addSourceAttribute, @RequestParam(required = false, name = "package") String packageId, @RequestParam(required = false) String label) { MappingJobExecution mappingJobExecution = mappingJobExecutionFactory.create(); User currentUser = userAccountService.getCurrentUser(); mappingJobExecution.setMappingProjectId(mappingProjectId); mappingJobExecution.setTargetEntityTypeId(targetEntityTypeId); mappingJobExecution.setAddSourceAttribute(addSourceAttribute); mappingJobExecution.setPackageId(packageId); mappingJobExecution.setLabel(label); jobExecutor.submit(mappingJobExecution); return ok(concatEntityHref(mappingJobExecution)); }
@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.setIndexActionJobID(transactionId); jobExecutor .submit(indexJobExecution, executorService) .whenComplete((a, b) -> indexStatus.removeActionCounts(numberOfActionsPerEntity)); } else { LOG.debug("No index job found for id [{}].", transactionId); } }
jobExecutor.submit(sortaJobExecution);