@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
 public ResponseEntity<Kriteria> deleteKriteria(@PathVariable Long id) {
   if (!kriteriaRepository.exists(id)) {
     return new ResponseEntity<Kriteria>(HttpStatus.NOT_FOUND);
   }
   kriteriaRepository.delete(id);
   return new ResponseEntity<Kriteria>(HttpStatus.OK);
 }
 @RequestMapping(method = RequestMethod.GET)
 public Page<Kriteria> listKriteria(
     @RequestParam(name = "search") String search, Pageable pageable) {
   if (search.equals("")) {
     return kriteriaRepository.findAll(pageable);
   }
   return kriteriaRepository.findBySearch(search, pageable);
 }
 @RequestMapping(value = "/{id}", method = RequestMethod.GET)
 public ResponseEntity<Kriteria> detailKriteria(@PathVariable Long id) {
   if (!kriteriaRepository.exists(id)) {
     return new ResponseEntity<Kriteria>(HttpStatus.NOT_FOUND);
   }
   Kriteria kriteria = kriteriaRepository.findOne(id);
   return new ResponseEntity<Kriteria>(kriteria, HttpStatus.OK);
 }
  @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
  public ResponseEntity<Kriteria> updateKriteria(
      @PathVariable Long id, @RequestBody Kriteria kriteria, BindingResult bindingResult) {
    if (bindingResult.hasErrors()) {
      return new ResponseEntity<Kriteria>(HttpStatus.BAD_REQUEST);
    }

    Kriteria currentKriteria = kriteriaRepository.findOne(id);
    if (currentKriteria == null) {
      return new ResponseEntity<Kriteria>(HttpStatus.NOT_FOUND);
    }

    currentKriteria.setNamaKriteria(kriteria.getNamaKriteria());

    kriteriaRepository.save(currentKriteria);
    return new ResponseEntity<Kriteria>(currentKriteria, HttpStatus.OK);
  }
  @RequestMapping(method = RequestMethod.POST)
  public ResponseEntity<Kriteria> addKriteria(
      @Validated @RequestBody Kriteria kriteria, BindingResult bindingResult) {
    if (bindingResult.hasErrors()) {
      return new ResponseEntity<Kriteria>(HttpStatus.BAD_REQUEST);
    }

    Kriteria newKriteria = kriteriaRepository.save(kriteria);
    return new ResponseEntity<Kriteria>(newKriteria, HttpStatus.OK);
  }
 @RequestMapping(value = "/all", method = RequestMethod.GET)
 public Iterable<Kriteria> listKriteria() {
   return kriteriaRepository.findAll();
 }