use of com.b2international.snowowl.core.merge.Merge.Builder in project snow-owl by b2ihealthcare.
the class SearchMergeRequest method createMergefromJobEntry.
public static Merge createMergefromJobEntry(RemoteJobEntry job, ObjectMapper mapper) {
// the final state will be available as job result value
if (job.isSuccessful()) {
return job.getResultAs(mapper, Merge.class);
}
// any other state should be computed from the ongoing remote job
final Map<String, Object> params = job.getParameters(mapper);
final String source = (String) params.get(SOURCE_FIELD);
final String target = (String) params.get(TARGET_FIELD);
final Builder merge = Merge.builder().id(job.getId()).source(source).target(target).startDate(job.getStartDate()).scheduledDate(job.getScheduleDate()).endDate(job.getFinishDate());
switch(job.getState()) {
case FINISHED:
return merge.status(Status.COMPLETED).build();
case CANCEL_REQUESTED:
return merge.status(Status.CANCEL_REQUESTED).build();
case CANCELED:
return merge.status(Status.FAILED).build();
case FAILED:
return merge.status(Status.FAILED).apiError(job.getResultAs(mapper, ApiError.class)).build();
case RUNNING:
return merge.status(Status.IN_PROGRESS).build();
case SCHEDULED:
return merge.status(Status.SCHEDULED).build();
default:
throw new NotImplementedException("Not implemented case for " + job.getState());
}
}
Aggregations