@RequestMapping(value={"/",""},method=RequestMethod.PUT) @ResponseBody public RestWrapper insert(@ModelAttribute("processtype") @Valid WorkflowType workflowType,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.WorkflowType jpaWorkflowType=new com.wipro.ats.bdre.md.dao.jpa.WorkflowType();
    jpaWorkflowType.setWorkflowId(workflowType.getWorkflowId());
    jpaWorkflowType.setWorkflowTypeName(workflowType.getWorkflowTypeName());
    workflowTypeDAO.insert(jpaWorkflowType);
    restWrapper=new RestWrapper(workflowType,RestWrapper.OK);
    LOGGER.info("Record with ID:" + workflowType.getWorkflowId() + " inserted in BatchStatus by User:"+ principal.getName()+ workflowType);
  }
 catch (  Exception e) {
    LOGGER.error(e);
    restWrapper=new RestWrapper(e.getMessage(),RestWrapper.ERROR);
  }
  return restWrapper;
}

@ RequestMapping ( value = { "/" , "" } , method = RequestMethod . PUT ) @ ResponseBody public RestWrapper insert ( @ ModelAttribute ( "processtype" ) @ Valid WorkflowType workflowType , 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 . WorkflowType jpaWorkflowType = new com . wipro . ats . bdre . md . dao . jpa . WorkflowType ( ) ; jpaWorkflowType . setWorkflowId ( workflowType . getWorkflowId ( ) ) ; jpaWorkflowType . setWorkflowTypeName ( workflowType . getWorkflowTypeName ( ) ) ; workflowTypeDAO . insert ( jpaWorkflowType ) ; restWrapper = new RestWrapper ( workflowType , RestWrapper . OK ) ; LOGGER . info ( "Record with ID:" + workflowType . getWorkflowId ( ) + " inserted in BatchStatus by User:" + principal . getName ( ) + workflowType ) ; } catch ( Exception e ) { LOGGER . error ( e ) ; restWrapper = new RestWrapper ( e . getMessage ( ) , RestWrapper . ERROR ) ; } return restWrapper ; }
this method calls proc insertworkflowtype and adds in record in the database . it also validates the values of the record passed .
