Search in sources :

Example 1 with MappingJobExecution

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;
}
Also used : MappingJobExecution(org.molgenis.semanticmapper.job.MappingJobExecution)

Example 2 with 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);
}
Also used : MetaUtils.isSystemPackage(org.molgenis.data.meta.MetaUtils.isSystemPackage) Package(org.molgenis.data.meta.model.Package) URI(java.net.URI) URI(org.molgenis.semanticmapper.controller.MappingServiceController.URI) MappingJobExecution(org.molgenis.semanticmapper.job.MappingJobExecution)

Aggregations

MappingJobExecution (org.molgenis.semanticmapper.job.MappingJobExecution)2 URI (java.net.URI)1 MetaUtils.isSystemPackage (org.molgenis.data.meta.MetaUtils.isSystemPackage)1 Package (org.molgenis.data.meta.model.Package)1 URI (org.molgenis.semanticmapper.controller.MappingServiceController.URI)1