20. 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.

20.1 Files compared

# Location File Last Modified
1 cpss.zip\cpss\src\main\java\gov\va\cpss\job\cbs CbsPatientMapItemReader.java Wed Feb 1 21:07:30 2017 UTC
2 cpss.zip\cpss\src\main\java\gov\va\cpss\job\cbs CbsPatientMapItemReader.java Fri Feb 3 20:40:44 2017 UTC

20.2 Comparison summary

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

20.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

20.4 Active regular expressions

No regular expressions were active.

20.5 Comparison detail

  1   package go v.va.cpss. job.cbs;
  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.MEM ORY_OPEN_E RROR_STATU S;
  6   import sta tic gov.va .cpss.job. CbssJobPro cessingCon stants.REA D_FAILURE_ STATUS;
  7  
  8   import jav a.util.Lis t;
  9   import jav a.util.Map .Entry;
  10  
  11   import org .apache.lo g4j.Logger ;
  12   import org .springfra mework.bat ch.core.Ex itStatus;
  13   import org .springfra mework.bat ch.core.It emReadList ener;
  14   import org .springfra mework.bat ch.core.Jo bExecution ;
  15   import org .springfra mework.bat ch.core.St epExecutio n;
  16   import org .springfra mework.bat ch.core.St epExecutio nListener;
  17   import org .springfra mework.bat ch.item.Pa rseExcepti on;
  18   import org .springfra mework.bat ch.item.Un expectedIn putExcepti on;
  19   import org .springfra mework.bat ch.item.su pport.Abst ractItemCo untingItem StreamItem Reader;
  20   import org .springfra mework.uti l.ClassUti ls;
  21  
  22   import gov .va.cpss.m odel.fps.P SPatient;
  23  
  24   /**
  25    * Impleme ntation of  AbstractI temCountin gItemStrea mItemReade r used by  the Genera te CBS
  26    * batch j ob to read  data from  an in-mem ory map of  CBS Accou nt ID to l ist of PSP atient rec ords.
  27    * 
  28    * @author   DN S      P II
  29    */
  30   public cla ss CbsPati entMapItem Reader<T>  extends Ab stractItem CountingIt emStreamIt emReader<E ntry<Long,  List<PSPa tient>>>
  31                    impl ements Ite mReadListe ner<Entry< Long, List <PSPatient >>>, StepE xecutionLi stener {
  32  
  33           /*
  34            *  Flag to i ndicate th at the job  has been  forcefully  stopped a nd should  no
  35            *  longer at tempt read .
  36            * /
  37           pr ivate bool ean forceS top = fals e;
  38  
  39           /*
  40            *  Flag to i ndicate th e map has  been opene d.
  41            * /
  42           pr ivate bool ean opened  = false;
  43  
  44           pr ivate CbsR untimeStat e cbsRunti meState;
  45  
  46           pr ivate JobE xecution j obExecutio n;
  47  
  48           pr ivate fina l Logger r eaderLogge r;
  49  
  50           /*
  51            *  The count  of entrie s read.
  52            * /
  53           pr ivate int  lineCount  = 0;
  54  
  55           pu blic CbsPa tientMapIt emReader()  {
  56                    setN ame(ClassU tils.getSh ortName(Cb sPatientMa pItemReade r.class));
  57                    read erLogger =  Logger.ge tLogger(th is.getClas s().getCan onicalName ());
  58           }
  59  
  60           pu blic CbsRu ntimeState  getCbsRun timeState( ) {
  61                    retu rn cbsRunt imeState;
  62           }
  63  
  64           pu blic void  setCbsRunt imeState(C bsRuntimeS tate cbsRu ntimeState ) {
  65                    this .cbsRuntim eState = c bsRuntimeS tate;
  66           }
  67  
  68           @O verride
  69           pr otected vo id doOpen( ) throws E xception {
  70  
  71                    open ed = false ;
  72  
  73                    if ( cbsRuntime State.isEm pty()) {
  74  
  75                             stopJo b(MEMORY_O PEN_ERROR_ STATUS,
  76                                               "Unable to  open memo ry map for  reading b ecause the re was no  data detec ted");
  77  
  78                    } el se if (cbs RuntimeSta te.isDataE rror()) {
  79  
  80                             stopJo b(MEMORY_O PEN_ERROR_ STATUS,
  81                                               "Unable to  open memo ry map for  reading b ecause dat a error wa s encounte red");
  82                    } el se {
  83  
  84                             opened  = true;
  85                    }
  86           }
  87  
  88           @O verride
  89           pu blic Entry <Long, Lis t<PSPatien t>> read()  throws Ex ception, U nexpectedI nputExcept ion, Parse Exception  {
  90  
  91                    // D o not atte mpt to rea d if force d stop.
  92                    if ( forceStop)  {
  93                             reader Logger.err or("Unreco verable sy stem error  forcing r eader to s top proces sing");
  94                             return  null;
  95                    }
  96  
  97                    try  {
  98  
  99                             return  super.rea d();
  100  
  101                    } ca tch (Excep tion e) {
  102  
  103                             String Builder er ror = new  StringBuil der();
  104                             error. append("Un able to re ad item be cause of " );
  105                             error. append(e.g etClass(). getSimpleN ame());
  106                             error. append("\n Message: " );
  107                             error. append(e.g etMessage( ));
  108                             error. append("\n Cause: ");
  109                             error. append(e.g etCause(). getMessage ().trim()) ;
  110  
  111                             stopJo b(READ_FAI LURE_STATU S, error.t oString()) ;
  112                    }
  113  
  114                    // N ull respon se will ca use step t o end.
  115                    retu rn null;
  116           }
  117  
  118           @O verride
  119           pr otected En try<Long,  List<PSPat ient>> doR ead() thro ws Excepti on {
  120  
  121                    // I f not open ed then re turn null  which will  effective ly stop
  122                    // p rocessing.
  123                    if ( !opened) {
  124                             return  null;
  125                    }
  126  
  127                    // I f null is  read then  return nul l which wi ll effecti vely stop
  128                    // p rocessing.
  129                    retu rn readEnt ry();
  130           }
  131  
  132           /* *
  133            *  Read the  entry from  the map.
  134            *  
  135            *  @return T he next en try in the  map.
  136            * /
  137           pr ivate Entr y<Long, Li st<PSPatie nt>> readE ntry() {
  138  
  139                    Entr y<Long, Li st<PSPatie nt>> entry  = cbsRunt imeState.p ollCurrent PSPatientM ();
  140  
  141                    if ( entry == n ull) {
  142                             return  null;
  143                    }
  144  
  145                    line Count++;
  146  
  147                    retu rn entry;
  148           }
  149  
  150           @O verride
  151           pr otected vo id doClose () throws  Exception  {
  152  
  153                    // R eset the s top flag o n close.
  154                    forc eStop = fa lse;
  155  
  156                    // R eset the o pen flag o n close.
  157                    open ed = false ;
  158  
  159                    // B e sure to  reset the  line count .
  160                    line Count = 0;
  161           }
  162  
  163           @O verride
  164           pu blic void  beforeRead () {
  165                    forc eStop = fa lse;
  166                    if ( jobExecuti on.getExec utionConte xt().conta insKey(JOB _FAILURE_K EY)) {
  167                             reader Logger.err or("System  failure d etected.") ;
  168                             forceS top = true ;
  169                    }
  170           }
  171  
  172           @O verride
  173           pu blic void  onReadErro r(Exceptio n e) {
  174  
  175                    read erLogger.e rror("Read er encount ered syste m error an d forced s top");
  176  
  177                    Stri ngBuilder  error = ne w StringBu ilder();
  178                    erro r.append(" Unable to  read item  because of  ");
  179                    erro r.append(e .getClass( ).getSimpl eName());
  180                    erro r.append(" \nMessage:  ");
  181                    erro r.append(e .getMessag e());
  182                    erro r.append(" \nCause: " );
  183                    erro r.append(e .getCause( ).getMessa ge().trim( ));
  184  
  185                    // S et failure  and messa ge.
  186                    stop Job(READ_F AILURE_STA TUS, error .toString( ));
  187           }
  188  
  189           @O verride
  190           pu blic void  afterRead( Entry<Long , List<PSP atient>> i tem) {
  191                    // D o not need  to do any thing afte r read.
  192           }
  193  
  194           @O verride
  195           pu blic void  beforeStep (StepExecu tion stepE xecution)  {
  196                    read erLogger.i nfo("Befor e Step Exe cution");
  197                    // S ave the jo b executio n at the b eginning o f the step .
  198                    // T he executi on context  will be u sed to set  exit stat us if a fa ilure
  199                    // d uring read  processin g.
  200                    jobE xecution =  stepExecu tion.getJo bExecution ();
  201           }
  202  
  203           @O verride
  204           pu blic ExitS tatus afte rStep(Step Execution  stepExecut ion) {
  205                    // D o not do a nything sp ecial here .
  206                    retu rn null;
  207           }
  208  
  209           /* *
  210            *  Forcefull y stop the  job proce ssing beca use a fail ure was de tected.
  211            *  
  212            *  @param st atus
  213            *              The stat us for the  failure.
  214            *  @param me ssage
  215            *              The mess age associ ated with  the status  failure.
  216            * /
  217           pr ivate void  stopJob(f inal Strin g status,  final Stri ng message ) {
  218  
  219                    // S et the fla g to indic ate the jo b has been  forcefull y stopped.
  220                    forc eStop = tr ue;
  221  
  222                    // L og message .
  223                    read erLogger.e rror("Read er executi on encount ered unrec overable e rror and f orced stop ");
  224  
  225                    // S et failure  and messa ge.
  226                    setF ailureStat us(status) ;
  227  
  228                    // S et failure  message.
  229                    setF ailureMess age(messag e);
  230           }
  231  
  232           /* *
  233            *  Set the f ailure in  the job ex ecution co ntext.
  234            *  
  235            *  @param st atus
  236            *              The fail ure status .
  237            * /
  238           pr ivate void  setFailur eStatus(fi nal String  status) {
  239  
  240                    // L og job fai lure statu s.
  241                    read erLogger.e rror("Read  failed wi th status:  " + statu s);
  242  
  243                    // S et job fai lure.
  244                    jobE xecution.g etExecutio nContext() .putString (JOB_FAILU RE_KEY, st atus);
  245           }
  246  
  247           /* *
  248            *  Set the f ailure mes sage in th e job exec ution cont ext.
  249            *  
  250            *  @param me ssage
  251            *              The mess age to ass ociate wit h the erro r status.
  252            * /
  253           pr ivate void  setFailur eMessage(f inal Strin g message)  {
  254  
  255                    // L og job fai lure messa ge.
  256                    read erLogger.e rror("Read  failure m essage: "  + message) ;
  257  
  258                    // S et job fai lure messa ge.
  259                    jobE xecution.g etExecutio nContext() .putString (JOB_FAILU RE_MESSAGE _KEY, mess age);
  260           }
  261  
  262   }