import java.util.List;
import org.everit.json.schema.Schema;
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONObject;
import java.util.List;
import org.everit.json.schema.Schema;
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONObject;
import org.oransc.enrichment.configuration.ApplicationConfig;
import org.oransc.enrichment.controllers.ErrorResponse;
import org.oransc.enrichment.controllers.VoidResponse;
import org.oransc.enrichment.configuration.ApplicationConfig;
import org.oransc.enrichment.controllers.ErrorResponse;
import org.oransc.enrichment.controllers.VoidResponse;
import org.oransc.enrichment.exceptions.ServiceException;
import org.oransc.enrichment.repository.EiJob;
import org.oransc.enrichment.repository.EiJobs;
import org.oransc.enrichment.exceptions.ServiceException;
import org.oransc.enrichment.repository.EiJob;
import org.oransc.enrichment.repository.EiJobs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@GetMapping(path = "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "EI type identifiers", notes = "")
@GetMapping(path = "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "EI type identifiers", notes = "")
- // TODO
- return new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED);
+ if (getProducers(job).isEmpty()) {
+ return new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.DISABLED);
+ } else {
+ return new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED);
+ }
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (Exception e) {
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (Exception e) {
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
final boolean isNewJob = this.eiJobs.get(eiJobId) == null;
return validatePutEiJob(eiJobId, eiJobObject) //
final boolean isNewJob = this.eiJobs.get(eiJobId) == null;
return validatePutEiJob(eiJobId, eiJobObject) //
.doOnNext(newEiJob -> this.eiJobs.put(newEiJob)) //
.flatMap(newEiJob -> Mono.just(new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK)))
.onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.NOT_FOUND)));
}
.doOnNext(newEiJob -> this.eiJobs.put(newEiJob)) //
.flatMap(newEiJob -> Mono.just(new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK)))
.onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.NOT_FOUND)));
}
- private Mono<EiJob> notifyProducersNewJob(EiJob newEiJob) {
- return this.producerCallbacks.notifyProducersJobStarted(newEiJob) //
+ private Mono<EiJob> startEiJob(EiJob newEiJob) {
+ return this.producerCallbacks.startEiJob(newEiJob, eiProducers) //
.flatMap(noOfAcceptingProducers -> {
if (noOfAcceptingProducers.intValue() > 0) {
return Mono.just(newEiJob);
.flatMap(noOfAcceptingProducers -> {
if (noOfAcceptingProducers.intValue() > 0) {
return Mono.just(newEiJob);
validateJsonObjectAgainstSchema(eiType.getJobDataSchema(), eiJobInfo.jobData);
EiJob existingEiJob = this.eiJobs.get(eiJobId);
validateJsonObjectAgainstSchema(eiType.getJobDataSchema(), eiJobInfo.jobData);
EiJob existingEiJob = this.eiJobs.get(eiJobId);
throw new ServiceException("Not allowed to change type for existing EI job", HttpStatus.CONFLICT);
}
return Mono.just(toEiJob(eiJobInfo, eiJobId, eiType));
throw new ServiceException("Not allowed to change type for existing EI job", HttpStatus.CONFLICT);
}
return Mono.just(toEiJob(eiJobInfo, eiJobId, eiType));
- return new ConsumerEiJobInfo(s.type().getId(), s.jobData(), s.owner(), s.targetUri());
+ return new ConsumerEiJobInfo(s.getTypeId(), s.getJobData(), s.getOwner(), s.getTargetUrl(),
+ s.getJobStatusUrl());