/** * Constructor. * * @param description Description for the job status */ DefaultJobStatus(String description) { this.description = description; this.name = name().toLowerCase(Locale.ENGLISH); }
/** * Builds a JobRow with values for every field defined in {@link DefaultJobField}. * * @param request The request that is triggering this job * @param requestContext The context of the request triggering this job * * @return A JobRow with all the metadata for the job under construction */ @Override public JobRow buildJobRow(UriInfo request, ContainerRequestContext requestContext) { Map<JobField, String> jobMetadata = new LinkedHashMap<>(DefaultJobField.values().length); String userId = userIdExtractor.apply(requestContext.getSecurityContext()); jobMetadata.put(DefaultJobField.QUERY, request.getRequestUri().toString()); jobMetadata.put(DefaultJobField.STATUS, DefaultJobStatus.PENDING.getName()); String isoDateCreated = new DateTime(timestampGenerator.instant().toEpochMilli()).toDateTimeISO().toString(); jobMetadata.put(DefaultJobField.DATE_CREATED, isoDateCreated); jobMetadata.put(DefaultJobField.DATE_UPDATED, isoDateCreated); jobMetadata.put(DefaultJobField.USER_ID, userId); jobMetadata.put(DefaultJobField.JOB_TICKET, idGenerator.apply(jobMetadata)); return new JobRow(DefaultJobField.JOB_TICKET, jobMetadata); } }