@RequestMapping(value={"/",""},method=RequestMethod.POST) @ResponseBody public RestWrapper update(@ModelAttribute("processtemplate") @Valid ProcessTemplate processTemplate,BindingResult bindingResult,Principal principal){
  RestWrapper restWrapper=null;
  if (bindingResult.hasErrors()) {
    BindingResultError bindingResultError=new BindingResultError();
    return bindingResultError.errorMessage(bindingResult);
  }
  try {
    processTemplate.setAddTS(DateConverter.stringToDate(processTemplate.getTableAddTS()));
    com.wipro.ats.bdre.md.dao.jpa.ProcessTemplate jpaProcessTemplate=new com.wipro.ats.bdre.md.dao.jpa.ProcessTemplate();
    jpaProcessTemplate.setProcessTemplateId(processTemplate.getProcessTemplateId());
    jpaProcessTemplate.setDescription(processTemplate.getDescription());
    jpaProcessTemplate.setProcessName(processTemplate.getProcessName());
    jpaProcessTemplate.setBatchCutPattern(processTemplate.getBatchPattern());
    jpaProcessTemplate.setAddTs(processTemplate.getAddTS());
    if (processTemplate.getCanRecover() == null)     jpaProcessTemplate.setCanRecover(true);
 else     jpaProcessTemplate.setCanRecover(processTemplate.getCanRecover());
    if (processTemplate.getDeleteFlag() == null)     jpaProcessTemplate.setDeleteFlag(false);
 else     jpaProcessTemplate.setDeleteFlag(processTemplate.getDeleteFlag());
    jpaProcessTemplate.setNextProcessTemplateId(processTemplate.getNextProcessTemplateId());
    ProcessType processType=processTypeDAO.get(processTemplate.getProcessTypeId());
    jpaProcessTemplate.setProcessType(processType);
    if (processTemplate.getParentProcessId() != null) {
      com.wipro.ats.bdre.md.dao.jpa.ProcessTemplate pt=processTemplateDAO.get(processTemplate.getParentProcessId());
      jpaProcessTemplate.setProcessTemplate(pt);
    }
 else {
      jpaProcessTemplate.setProcessTemplate(null);
    }
    WorkflowType workflowType=workflowTypeDAO.get(processTemplate.getWorkflowId());
    jpaProcessTemplate.setWorkflowType(workflowType);
    BusDomain busDomain=busDomainDAO.get(processTemplate.getBusDomainId());
    jpaProcessTemplate.setBusDomain(busDomain);
    processTemplateDAO.update(jpaProcessTemplate);
    restWrapper=new RestWrapper(processTemplate,RestWrapper.OK);
    LOGGER.info("Record with ID:" + processTemplate.getProcessTemplateId() + " updated in BatchStatus by User:"+ principal.getName()+ processTemplate);
  }
 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 ( "processtemplate" ) @ Valid ProcessTemplate processTemplate , BindingResult bindingResult , Principal principal ) { RestWrapper restWrapper = null ; if ( bindingResult . hasErrors ( ) ) { BindingResultError bindingResultError = new BindingResultError ( ) ; return bindingResultError . errorMessage ( bindingResult ) ; } try { processTemplate . setAddTS ( DateConverter . stringToDate ( processTemplate . getTableAddTS ( ) ) ) ; com . wipro . ats . bdre . md . dao . jpa . ProcessTemplate jpaProcessTemplate = new com . wipro . ats . bdre . md . dao . jpa . ProcessTemplate ( ) ; jpaProcessTemplate . setProcessTemplateId ( processTemplate . getProcessTemplateId ( ) ) ; jpaProcessTemplate . setDescription ( processTemplate . getDescription ( ) ) ; jpaProcessTemplate . setProcessName ( processTemplate . getProcessName ( ) ) ; jpaProcessTemplate . setBatchCutPattern ( processTemplate . getBatchPattern ( ) ) ; jpaProcessTemplate . setAddTs ( processTemplate . getAddTS ( ) ) ; if ( processTemplate . getCanRecover ( ) == null ) jpaProcessTemplate . setCanRecover ( true ) ; else jpaProcessTemplate . setCanRecover ( processTemplate . getCanRecover ( ) ) ; if ( processTemplate . getDeleteFlag ( ) == null ) jpaProcessTemplate . setDeleteFlag ( false ) ; else jpaProcessTemplate . setDeleteFlag ( processTemplate . getDeleteFlag ( ) ) ; jpaProcessTemplate . setNextProcessTemplateId ( processTemplate . getNextProcessTemplateId ( ) ) ; ProcessType processType = processTypeDAO . get ( processTemplate . getProcessTypeId ( ) ) ; jpaProcessTemplate . setProcessType ( processType ) ; if ( processTemplate . getParentProcessId ( ) != null ) { com . wipro . ats . bdre . md . dao . jpa . ProcessTemplate pt = processTemplateDAO . get ( processTemplate . getParentProcessId ( ) ) ; jpaProcessTemplate . setProcessTemplate ( pt ) ; } else { jpaProcessTemplate . setProcessTemplate ( null ) ; } WorkflowType workflowType = workflowTypeDAO . get ( processTemplate . getWorkflowId ( ) ) ; jpaProcessTemplate . setWorkflowType ( workflowType ) ; BusDomain busDomain = busDomainDAO . get ( processTemplate . getBusDomainId ( ) ) ; jpaProcessTemplate . setBusDomain ( busDomain ) ; processTemplateDAO . update ( jpaProcessTemplate ) ; restWrapper = new RestWrapper ( processTemplate , RestWrapper . OK ) ; LOGGER . info ( "Record with ID:" + processTemplate . getProcessTemplateId ( ) + " updated in BatchStatus by User:" + principal . getName ( ) + processTemplate ) ; } catch ( MetadataException e ) { LOGGER . error ( e ) ; restWrapper = new RestWrapper ( e . getMessage ( ) , RestWrapper . ERROR ) ; } return restWrapper ; }
this method calls proc updateprocess and updates the values . it also validates the values passed .
