36. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 2/7/2017 12:14:06 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

36.1 Files compared

# Location File Last Modified
1 cpss.zip\cpss\src\main\java\gov\va\cpss\job\loadbill LoadBillDelegateMultiItemWriter.java Wed Feb 1 21:07:30 2017 UTC
2 cpss.zip\cpss\src\main\java\gov\va\cpss\job\loadbill LoadBillDelegateMultiItemWriter.java Fri Feb 3 20:45:53 2017 UTC

36.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 474
Changed 1 2
Inserted 0 0
Removed 0 0

36.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

36.4 Active regular expressions

No regular expressions were active.

36.5 Comparison detail

  1   package go v.va.cpss. job.loadbi ll;
  2  
  3   import sta tic gov.va .cpss.job. CbssJobPro cessingCon stants.JOB _FAILURE_K EY;
  4   import sta tic gov.va .cpss.job. CbssJobPro cessingCon stants.JOB _FAILURE_M ESSAGE_KEY ;
  5   import sta tic gov.va .cpss.job. CbssJobPro cessingCon stants.WRI TE_FAILURE _STATUS;
  6  
  7   import jav a.util.Arr ayList;
  8   import jav a.util.Lis t;
  9  
  10   import org .apache.lo g4j.Logger ;
  11   import org .springfra mework.bat ch.core.Ex itStatus;
  12   import org .springfra mework.bat ch.core.It emWriteLis tener;
  13   import org .springfra mework.bat ch.core.Jo bExecution ;
  14   import org .springfra mework.bat ch.core.St epExecutio n;
  15   import org .springfra mework.bat ch.core.St epExecutio nListener;
  16   import org .springfra mework.bat ch.item.Ex ecutionCon text;
  17   import org .springfra mework.bat ch.item.It emWriter;
  18  
  19   import gov .va.cpss.m odel.bal.S iteBalance ;
  20   import gov .va.cpss.s ervice.Loa dBillServi ce;
  21  
  22   /**
  23    * Impleme ntation of  ItemWrite r used to  handle wri ting of si te balance s when
  24    * process ing.
  25    * 
  26    * @author   DN S      P II
  27    */
  28   public cla ss LoadBil lDelegateM ultiItemWr iter
  29                    impl ements Ite mWriter<Li st<SiteBal ance>>, It emWriteLis tener<List <SiteBalan ce>>, Step ExecutionL istener {
  30  
  31           pr ivate fina l Logger w riterLogge r = Logger .getLogger (LoadBillD elegateMul tiItemWrit er.class.g etCanonica lName());
  32  
  33           /*
  34            *  Flag to i ndicate th at the job  has been  forcefully  stopped a nd should  no
  35            *  longer at tempt writ es.
  36            * /
  37           pr ivate bool ean forceS top = fals e;
  38  
  39           pr ivate JobE xecution j obExecutio n;
  40           
  41           pr ivate Load BillServic e loadBill Service;
  42  
  43           /*
  44            *  Delegate  writer use d to take  advantage  of batch w riting sit e transact ion
  45            *  records.  Only write s new Site  Balance r ecords.
  46            * /
  47           pr ivate Item Writer<Sit eBalance>  newSiteBal DatabaseIt emWriter;
  48           
  49           /*
  50            *  Delegate  writer use d to take  advantage  of batch w riting sit e transact ion
  51            *  records.  Only updat es existin g Site Bal ance recod s.
  52            * /
  53           pr ivate Item Writer<Sit eBalance>  existingSi teBalDatab aseItemWri ter;
  54  
  55           pu blic LoadB illService  getLoadBi llService( ) {
  56                    retu rn this.lo adBillServ ice;
  57           }
  58           
  59           pu blic void  setLoadBil lService(L oadBillSer vice loadB illService ) {
  60                    this .loadBillS ervice = l oadBillSer vice;
  61           }
  62           
  63           pu blic ItemW riter<Site Balance> g etNewSiteB alDatabase ItemWriter () {
  64                    retu rn newSite BalDatabas eItemWrite r;
  65           }
  66  
  67           pu blic void  setNewSite BalDatabas eItemWrite r(ItemWrit er<SiteBal ance> newS iteBalData baseItemWr iter) {
  68                    this .newSiteBa lDatabaseI temWriter  = newSiteB alDatabase ItemWriter ;
  69           }
  70           
  71           pu blic ItemW riter<Site Balance> g etExisting SiteBalDat abaseItemW riter() {
  72                    retu rn existin gSiteBalDa tabaseItem Writer;
  73           }
  74  
  75           pu blic void  setExistin gSiteBalDa tabaseItem Writer(Ite mWriter<Si teBalance>  existingS iteBalData baseItemWr iter) {
  76                    this .existingS iteBalData baseItemWr iter = exi stingSiteB alDatabase ItemWriter ;
  77           }
  78  
  79           @O verride
  80           pu blic void  write(List <? extends  List<Site Balance>>  items) thr ows Except ion {
  81  
  82                    writ erLogger.i nfo("Begin  Write");
  83  
  84                    // D o not atte mpt to wri te if forc ed stop.
  85                    if ( forceStop)  {
  86                             return ;
  87                    }
  88  
  89                    try  {
  90                             // Com bined list  of site b alance lis ts.
  91                             List<S iteBalance > newSiteB alL = new  ArrayList< >();
  92                             List<S iteBalance > existing SiteBalL =  new Array List<>();
  93                             // Loo p through  all of the  statement s to write .
  94                             
  95                             for (L ist<SiteBa lance> sbL  : items)  {
  96                                      for(Site Balance si teBal: sbL ) {
  97                                               // If a re cord with  the same s tation and  account n umbers is  present, u pdate that  record wi th new inf ormation.
  98                                               if(loadBil lService.g etSiteBala nceByAcntN umAndStati onNum(site Bal.getPat ientDfn(),  siteBal.g etStationN um()) == n ull) {
  99                                                       ne wSiteBalL. add(siteBa l);
  100                                               }
  101                                               else {
  102                                                       ex istingSite BalL.add(s iteBal);
  103                                               }
  104                                      }
  105                             }
  106  
  107                             // We  can use ba tch to sav e the comb ined list.
  108                             // Ens ure that a t least on e record i s being up dated or a dded.
  109                             if (!n ewSiteBalL .isEmpty()  || !exist ingSiteBal L.isEmpty( )) {
  110                                      writerLo gger.info( "Writing n ew Site Ba lances");
  111                                      newSiteB alDatabase ItemWriter .write(new SiteBalL);
  112                                      writerLo gger.info( "Updating  existing S ite Balanc es");
  113                                      existing SiteBalDat abaseItemW riter.writ e(existing SiteBalL);
  114                                      // Keep  a running  total of t he amount  of facilit ies and pa tients
  115                                      Executio nContext e xecContext  = jobExec ution.getE xecutionCo ntext();
  116                                      int prev iousPatien tTotal = 0 ;
  117                                      if(execC ontext.con tainsKey(L oadBillPro cessingCon stants.TOT AL_PATIENT _COUNT_KEY )) {
  118                                               previousPa tientTotal  = execCon text.getIn t(LoadBill Processing Constants. TOTAL_PATI ENT_COUNT_ KEY);
  119                                      }
  120                                      execCont ext.putInt (LoadBillP rocessingC onstants.T OTAL_PATIE NT_COUNT_K EY, 
  121                                                       ne wSiteBalL. size() + e xistingSit eBalL.size () + previ ousPatient Total);
  122                             }
  123                    } ca tch (Excep tion e) {
  124  
  125                             String Builder er ror = new  StringBuil der();
  126                             error. append("Er ror during  write bec ause of ") ;
  127                             error. append(e.g etClass(). getSimpleN ame());
  128                             error. append("\n Cause: ");
  129                             error. append(e.g etCause(). getMessage ().trim()) ;
  130  
  131                             // Unr ecoverable  error so  stop the j ob.
  132                             stopJo b(WRITE_FA ILURE_STAT US, error. toString() );
  133                    }
  134  
  135                    writ erLogger.i nfo("End W rite");
  136           }
  137  
  138           @O verride
  139           pu blic void  beforeWrit e(List<? e xtends Lis t<SiteBala nce>> item s) {
  140                    forc eStop = fa lse;
  141                    if ( jobExecuti on.getExec utionConte xt().conta insKey(JOB _FAILURE_K EY)) {
  142                             writer Logger.err or("System  failure d etected.") ;
  143                             forceS top = true ;
  144                    }
  145           }
  146  
  147           @O verride
  148           pu blic void  afterWrite (List<? ex tends List <SiteBalan ce>> items ) {
  149           }
  150  
  151           @O verride
  152           pu blic void  onWriteErr or(Excepti on e, List <? extends  List<Site Balance>>  items) {
  153  
  154                    writ erLogger.e rror("Writ er encount ered syste m error an d forced s top");
  155  
  156                    Stri ngBuilder  error = ne w StringBu ilder();
  157                    erro r.append(" Unable to  write item  because o f ");
  158                    erro r.append(e .getClass( ).getSimpl eName());
  159                    erro r.append(" \nMessage:  ");
  160                    erro r.append(e .getMessag e());
  161                    if ( (e.getCaus e() != nul l) && (e.g etCause(). getMessage () != null )) {
  162                             error. append("\n Cause: ");
  163                             error. append(e.g etCause(). getMessage ().trim()) ;
  164                    }
  165  
  166                    // S et failure  and messa ge.
  167                    stop Job(WRITE_ FAILURE_ST ATUS, "Unr ecoverable  writer er ror");
  168           }
  169  
  170           @O verride
  171           pu blic void  beforeStep (StepExecu tion stepE xecution)  {
  172                    writ erLogger.i nfo("Befor e Step Exe cution");
  173                    // S ave the jo b executio n at the b eginning o f the step .
  174                    // T he executi on context  will be u sed to set  key value s as data  is
  175                    // p rocessed.
  176                    jobE xecution =  stepExecu tion.getJo bExecution ();
  177           }
  178  
  179           @O verride
  180           pu blic ExitS tatus afte rStep(Step Execution  stepExecut ion) {
  181                    // D o not need  to do any thing afte r step.
  182                    retu rn null;
  183           }
  184  
  185           /* *
  186            *  Forcefull y stop the  job proce ssing beca use a fail ure was de tected.
  187            *  
  188            *  @param st atus
  189            *              The stat us for the  failure.
  190            *  @param me ssage
  191            *              The mess age associ ated with  the status  failure.
  192            * /
  193           pr ivate void  stopJob(f inal Strin g status,  final Stri ng message ) {
  194  
  195                    // S et the fla g to indic ate the jo b has been  forcefull y stopped.
  196                    forc eStop = tr ue;
  197  
  198                    // L og message .
  199                    writ erLogger.e rror("Writ er executi on encount ered unrec overable e rror and f orced stop ");
  200  
  201                    // S et failure  and messa ge.
  202                    setF ailureStat us(status) ;
  203  
  204                    // S et failure  message.
  205                    setF ailureMess age(messag e);
  206           }
  207  
  208           /* *
  209            *  Set the f ailure in  the job ex ecution co ntext.
  210            *  
  211            *  @param st atus
  212            *              The fail ure status .
  213            * /
  214           pr ivate void  setFailur eStatus(fi nal String  status) {
  215  
  216                    // L og job fai lure statu s.
  217                    writ erLogger.e rror("Job  failed wit h status:  " + status );
  218  
  219                    // S et job fai lure.
  220                    jobE xecution.g etExecutio nContext() .putString (JOB_FAILU RE_KEY, st atus);
  221           }
  222  
  223           /* *
  224            *  Set the f ailure mes sage in th e job exec ution cont ext.
  225            *  
  226            *  @param me ssage
  227            *              The mess age to ass ociate wit h the erro r status.
  228            * /
  229           pr ivate void  setFailur eMessage(f inal Strin g message)  {
  230  
  231                    // L og job fai lure messa ge.
  232                    writ erLogger.e rror("Job  failure me ssage: " +  message);
  233  
  234                    // S et job fai lure messa ge.
  235                    jobE xecution.g etExecutio nContext() .putString (JOB_FAILU RE_MESSAGE _KEY, mess age);
  236           }
  237  
  238   }