use of org.molgenis.semanticmapper.job.MappingJobExecution in project molgenis by molgenis.
the class MappingServiceController method scheduleMappingJobInternal.
/**
* 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}
*/
private MappingJobExecution scheduleMappingJobInternal(String mappingProjectId, String targetEntityTypeId, Boolean addSourceAttribute, String packageId, String label) {
MappingJobExecution mappingJobExecution = mappingJobExecutionFactory.create();
mappingJobExecution.setUser(userAccountService.getCurrentUser());
mappingJobExecution.setMappingProjectId(mappingProjectId);
mappingJobExecution.setTargetEntityTypeId(targetEntityTypeId);
mappingJobExecution.setAddSourceAttribute(addSourceAttribute);
mappingJobExecution.setPackageId(packageId);
mappingJobExecution.setLabel(label);
jobExecutor.submit(mappingJobExecution);
return mappingJobExecution;
}
use of org.molgenis.semanticmapper.job.MappingJobExecution in project molgenis by molgenis.
the class MappingServiceController method scheduleMappingJob.
/**
* Schedules a {@link MappingJobExecution}.
*
* @param mappingProjectId ID of the mapping project
* @param targetEntityTypeId ID of the target entity to create or update
* @param label label of the target entity to create
* @param packageId ID of the package to put the newly created entity in
* @return the href of the created MappingJobExecution
*/
@PostMapping(value = "/map", produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> scheduleMappingJob(@RequestParam String mappingProjectId, @RequestParam String targetEntityTypeId, @RequestParam(required = false) String label, @RequestParam(required = false, name = "package") String packageId, @RequestParam(required = false) Boolean addSourceAttribute) throws URISyntaxException {
mappingProjectId = mappingProjectId.trim();
targetEntityTypeId = targetEntityTypeId.trim();
label = trim(label);
packageId = trim(packageId);
try {
validateEntityName(targetEntityTypeId);
if (mappingService.getMappingProject(mappingProjectId) == null) {
throw new MolgenisDataException("No mapping project found with ID " + mappingProjectId);
}
if (packageId != null) {
Package package_ = dataService.getMeta().getPackage(packageId);
if (package_ == null) {
throw new MolgenisDataException("No package found with ID " + packageId);
}
if (isSystemPackage(package_)) {
throw new MolgenisDataException(format("Package [{0}] is a system package.", packageId));
}
}
} catch (MolgenisDataException mde) {
return ResponseEntity.badRequest().contentType(TEXT_PLAIN).body(mde.getMessage());
}
MappingJobExecution mappingJobExecution = scheduleMappingJobInternal(mappingProjectId, targetEntityTypeId, addSourceAttribute, packageId, label);
String jobHref = concatEntityHref(mappingJobExecution);
return created(new URI(jobHref)).contentType(TEXT_PLAIN).body(jobHref);
}
Aggregations