@RequestMapping(value={"/",""},method=RequestMethod.POST) @ResponseBody public RestWrapper update(@ModelAttribute("batchstatus") @Valid BatchStatus batchStatus,BindingResult bindingResult,Principal principal){
  RestWrapper restWrapper=null;
  if (bindingResult.hasErrors()) {
    BindingResultError bindingResultError=new BindingResultError();
    return bindingResultError.errorMessage(bindingResult);
  }
  try {
    com.wipro.ats.bdre.md.dao.jpa.BatchStatus jpaBatchStatus=new com.wipro.ats.bdre.md.dao.jpa.BatchStatus();
    jpaBatchStatus.setBatchStateId(batchStatus.getBatchStateId());
    jpaBatchStatus.setDescription(batchStatus.getDescription());
    batchStatusDAO.update(jpaBatchStatus);
    LOGGER.debug("Updating Batch State Id" + jpaBatchStatus.getBatchStateId());
    restWrapper=new RestWrapper(batchStatus,RestWrapper.OK);
    LOGGER.info(RECORDWITHID + batchStatus.getBatchStateId() + " updated in BatchStatus by User:"+ principal.getName()+ batchStatus);
  }
 catch (  MetadataException e) {
    LOGGER.error(e);
    restWrapper=new RestWrapper(e.getMessage(),RestWrapper.ERROR);
  }
  return restWrapper;
}

@ RequestMapping ( value = { "/" , "" } , method = RequestMethod . POST ) @ ResponseBody public RestWrapper update ( @ ModelAttribute ( "batchstatus" ) @ Valid BatchStatus batchStatus , BindingResult bindingResult , Principal principal ) { RestWrapper restWrapper = null ; if ( bindingResult . hasErrors ( ) ) { BindingResultError bindingResultError = new BindingResultError ( ) ; return bindingResultError . errorMessage ( bindingResult ) ; } try { com . wipro . ats . bdre . md . dao . jpa . BatchStatus jpaBatchStatus = new com . wipro . ats . bdre . md . dao . jpa . BatchStatus ( ) ; jpaBatchStatus . setBatchStateId ( batchStatus . getBatchStateId ( ) ) ; jpaBatchStatus . setDescription ( batchStatus . getDescription ( ) ) ; batchStatusDAO . update ( jpaBatchStatus ) ; LOGGER . debug ( "Updating Batch State Id" + jpaBatchStatus . getBatchStateId ( ) ) ; restWrapper = new RestWrapper ( batchStatus , RestWrapper . OK ) ; LOGGER . info ( RECORDWITHID + batchStatus . getBatchStateId ( ) + " updated in BatchStatus by User:" + principal . getName ( ) + batchStatus ) ; } catch ( MetadataException e ) { LOGGER . error ( e ) ; restWrapper = new RestWrapper ( e . getMessage ( ) , RestWrapper . ERROR ) ; } return restWrapper ; }
this method calls updatebatchstatus and updates the record passed . it also validates the values of the record passed .
