@RequestMapping(value={"/",""},method=RequestMethod.PUT) @ResponseBody public RestWrapper insert(@ModelAttribute("acq") @Valid ArchiveConsumpQueue archiveConsumpQueue,BindingResult bindingResult,Principal principal){
  RestWrapper restWrapper=null;
  if (bindingResult.hasErrors()) {
    BindingResultError bindingResultError=new BindingResultError();
    return bindingResultError.errorMessage(bindingResult);
  }
  try {
    archiveConsumpQueue.setStartTs(DateConverter.stringToDate(archiveConsumpQueue.getTableStartTS()));
    archiveConsumpQueue.setEndTs(DateConverter.stringToDate(archiveConsumpQueue.getTableEndTS()));
    archiveConsumpQueue.setInsertTs(DateConverter.stringToDate(archiveConsumpQueue.getTableInsertTS()));
    com.wipro.ats.bdre.md.dao.jpa.ArchiveConsumpQueue jpaAcq=new com.wipro.ats.bdre.md.dao.jpa.ArchiveConsumpQueue();
    jpaAcq.setQueueId(archiveConsumpQueue.getQueueId());
    jpaAcq.setSourceProcessId(archiveConsumpQueue.getSourceProcessId());
    jpaAcq.setInsertTs(archiveConsumpQueue.getInsertTs());
    jpaAcq.setStartTs(archiveConsumpQueue.getStartTs());
    jpaAcq.setEndTs(archiveConsumpQueue.getEndTs());
    if (archiveConsumpQueue.getSourceBatchId() != null) {
      Batch sourceBatch=new Batch();
      sourceBatch.setBatchId(archiveConsumpQueue.getSourceBatchId());
      jpaAcq.setBatchBySourceBatchId(sourceBatch);
    }
    if (archiveConsumpQueue.getSourceBatchId() != null) {
      Batch targetBatch=new Batch();
      targetBatch.setBatchId(archiveConsumpQueue.getTargetBatchId());
      jpaAcq.setBatchByTargetBatchId(targetBatch);
    }
    com.wipro.ats.bdre.md.dao.jpa.Process process=new com.wipro.ats.bdre.md.dao.jpa.Process();
    process.setProcessId(archiveConsumpQueue.getProcessId());
    jpaAcq.setProcess(process);
    BatchStatus batchStatus=new BatchStatus();
    batchStatus.setBatchStateId(archiveConsumpQueue.getBatchState());
    jpaAcq.setBatchStatus(batchStatus);
    jpaAcq.setBatchMarking(archiveConsumpQueue.getBatchMarking());
    Long queueId=archiveConsumpQueueDAO.insert(jpaAcq);
    archiveConsumpQueue.setQueueId(queueId);
    archiveConsumpQueue.setTableStartTS(DateConverter.dateToString(archiveConsumpQueue.getStartTs()));
    archiveConsumpQueue.setTableEndTS(DateConverter.dateToString(archiveConsumpQueue.getEndTs()));
    archiveConsumpQueue.setTableInsertTS(DateConverter.dateToString(archiveConsumpQueue.getInsertTs()));
    restWrapper=new RestWrapper(archiveConsumpQueue,RestWrapper.OK);
    LOGGER.info(RECORDWITHID + archiveConsumpQueue.getQueueId() + " inserted into ArchiveConsumpQueue by User:"+ principal.getName()+ archiveConsumpQueue);
  }
 catch (  MetadataException e) {
    LOGGER.error(e);
    restWrapper=new RestWrapper(e.getMessage(),RestWrapper.ERROR);
  }
  return restWrapper;
}

@ RequestMapping ( value = { "/" , "" } , method = RequestMethod . PUT ) @ ResponseBody public RestWrapper insert ( @ ModelAttribute ( "acq" ) @ Valid ArchiveConsumpQueue archiveConsumpQueue , BindingResult bindingResult , Principal principal ) { RestWrapper restWrapper = null ; if ( bindingResult . hasErrors ( ) ) { BindingResultError bindingResultError = new BindingResultError ( ) ; return bindingResultError . errorMessage ( bindingResult ) ; } try { archiveConsumpQueue . setStartTs ( DateConverter . stringToDate ( archiveConsumpQueue . getTableStartTS ( ) ) ) ; archiveConsumpQueue . setEndTs ( DateConverter . stringToDate ( archiveConsumpQueue . getTableEndTS ( ) ) ) ; archiveConsumpQueue . setInsertTs ( DateConverter . stringToDate ( archiveConsumpQueue . getTableInsertTS ( ) ) ) ; com . wipro . ats . bdre . md . dao . jpa . ArchiveConsumpQueue jpaAcq = new com . wipro . ats . bdre . md . dao . jpa . ArchiveConsumpQueue ( ) ; jpaAcq . setQueueId ( archiveConsumpQueue . getQueueId ( ) ) ; jpaAcq . setSourceProcessId ( archiveConsumpQueue . getSourceProcessId ( ) ) ; jpaAcq . setInsertTs ( archiveConsumpQueue . getInsertTs ( ) ) ; jpaAcq . setStartTs ( archiveConsumpQueue . getStartTs ( ) ) ; jpaAcq . setEndTs ( archiveConsumpQueue . getEndTs ( ) ) ; if ( archiveConsumpQueue . getSourceBatchId ( ) != null ) { Batch sourceBatch = new Batch ( ) ; sourceBatch . setBatchId ( archiveConsumpQueue . getSourceBatchId ( ) ) ; jpaAcq . setBatchBySourceBatchId ( sourceBatch ) ; } if ( archiveConsumpQueue . getSourceBatchId ( ) != null ) { Batch targetBatch = new Batch ( ) ; targetBatch . setBatchId ( archiveConsumpQueue . getTargetBatchId ( ) ) ; jpaAcq . setBatchByTargetBatchId ( targetBatch ) ; } com . wipro . ats . bdre . md . dao . jpa . Process process = new com . wipro . ats . bdre . md . dao . jpa . Process ( ) ; process . setProcessId ( archiveConsumpQueue . getProcessId ( ) ) ; jpaAcq . setProcess ( process ) ; BatchStatus batchStatus = new BatchStatus ( ) ; batchStatus . setBatchStateId ( archiveConsumpQueue . getBatchState ( ) ) ; jpaAcq . setBatchStatus ( batchStatus ) ; jpaAcq . setBatchMarking ( archiveConsumpQueue . getBatchMarking ( ) ) ; Long queueId = archiveConsumpQueueDAO . insert ( jpaAcq ) ; archiveConsumpQueue . setQueueId ( queueId ) ; archiveConsumpQueue . setTableStartTS ( DateConverter . dateToString ( archiveConsumpQueue . getStartTs ( ) ) ) ; archiveConsumpQueue . setTableEndTS ( DateConverter . dateToString ( archiveConsumpQueue . getEndTs ( ) ) ) ; archiveConsumpQueue . setTableInsertTS ( DateConverter . dateToString ( archiveConsumpQueue . getInsertTs ( ) ) ) ; restWrapper = new RestWrapper ( archiveConsumpQueue , RestWrapper . OK ) ; LOGGER . info ( RECORDWITHID + archiveConsumpQueue . getQueueId ( ) + " inserted into ArchiveConsumpQueue by User:" + principal . getName ( ) + archiveConsumpQueue ) ; } catch ( MetadataException e ) { LOGGER . error ( e ) ; restWrapper = new RestWrapper ( e . getMessage ( ) , RestWrapper . ERROR ) ; } return restWrapper ; }
this method calls proc insertarchiveconsumpqueue and adds the record of the archiveconsumpqueue object passed . this method also validates the values passed .
