Search in sources :

Example 1 with Builder

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());
    }
}
Also used : ExpressionBuilder(com.b2international.index.query.Expressions.ExpressionBuilder) Builder(com.b2international.snowowl.core.merge.Merge.Builder) NotImplementedException(com.b2international.commons.exceptions.NotImplementedException)

Aggregations

NotImplementedException (com.b2international.commons.exceptions.NotImplementedException)1 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)1 Builder (com.b2international.snowowl.core.merge.Merge.Builder)1