/** * Retrieve the status of a execution. * * @param tid The tid of the execution * @return A structure containing the status and information related to the status */ @RequestMapping(method = RequestMethod.GET, value = "/programs/{tid}/status") public GetProgramStatusResponse getProgramStatus(@PathVariable Long tid) { Program p = programsRepository.findOne(tid); GetProgramStatusResponse response = new GetProgramStatusResponse(); response.status = p.getStatus(); response.compilationOutput = p.getCompilationOutput(); return response; }
/** * Execute a execution. * * @param tid The tid of the execution * @return the ID of the execution launched */ @RequestMapping(method = RequestMethod.POST, value = "/programs/{tid}/executions") public PostProgramExecutionResponse postProgramExecution(@PathVariable Long tid) { Program p = programsRepository.findOne(tid); PostProgramExecutionResponse response = new PostProgramExecutionResponse(); if (p.getStatus() == ProgramStatus.COMPILED) { Execution e = new Execution(); e.setProgram(p); e.setStatus(ExecutionStatus.NEW); executionsRepository.save(e); executionService.execute(e); response.executionId = e.getTid(); response.status = RequestStatus.OK; } else { response.status = RequestStatus.KO; } return response; }