69. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 2/7/2017 12:14:08 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.

69.1 Files compared

# Location File Last Modified
1 cpss.zip\cpss\src\main\java\gov\va\cpss\service BatchService.java Wed Feb 1 21:07:26 2017 UTC
2 cpss.zip\cpss\src\main\java\gov\va\cpss\service BatchService.java Mon Feb 6 15:14:10 2017 UTC

69.2 Comparison summary

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

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

69.4 Active regular expressions

No regular expressions were active.

69.5 Comparison detail

  1   package go v.va.cpss. service;
  2  
  3   import sta tic gov.va .cpss.ESAP I.EsapiVal idationTyp e.LOG_FORG ING;
  4   import sta tic gov.va .cpss.ESAP I.EsapiVal idator.val idateStrin gInput;
  5  
  6   import jav a.sql.Time stamp;
  7   import jav a.util.Arr ayList;
  8   import jav a.util.Cal endar;
  9   import jav a.util.Lis t;
  10  
  11   import org .apache.lo g4j.Logger ;
  12   import org .springfra mework.ste reotype.Se rvice;
  13  
  14   import gov .va.cpss.d ao.BatchJo bDAO;
  15   import gov .va.cpss.d ao.BatchRu nDAO;
  16   import gov .va.cpss.d ao.BatchSt atusDAO;
  17   import gov .va.cpss.d ao.BatchTy peDAO;
  18   import gov .va.cpss.m odel.Batch Item;
  19   import gov .va.cpss.m odel.Batch Job;
  20   import gov .va.cpss.m odel.Batch Run;
  21   import gov .va.cpss.m odel.Batch Status;
  22   import gov .va.cpss.m odel.Batch Type;
  23  
  24   /**
  25    * Service  class for  handling  activities  relating  to running  batch job s.
  26    * 
  27    * @author   DN S      D N S
  28    */
  29   @Service
  30   public cla ss BatchSe rvice {
  31  
  32           pr ivate Logg er logger  = Logger.g etLogger(B atchServic e.class.ge tCanonical Name());
  33  
  34           pr ivate Batc hTypeDAO b atchTypeDA O;
  35           pr ivate Batc hJobDAO ba tchJobDAO;
  36           pr ivate Batc hRunDAO ba tchRunDAO;
  37           pr ivate Batc hStatusDAO  batchStat usDAO;
  38  
  39           pu blic Batch Service()  {
  40           }
  41  
  42           pu blic Batch JobDAO get BatchJobDA O() {
  43                    retu rn batchJo bDAO;
  44           }
  45  
  46           pu blic void  setBatchJo bDAO(Batch JobDAO bat chJobDAO)  {
  47                    this .batchJobD AO = batch JobDAO;
  48           }
  49  
  50           pu blic Batch RunDAO get BatchRunDA O() {
  51                    retu rn batchRu nDAO;
  52           }
  53  
  54           pu blic void  setBatchRu nDAO(Batch RunDAO bat chRunDAO)  {
  55                    this .batchRunD AO = batch RunDAO;
  56           }
  57  
  58           pu blic Batch TypeDAO ge tBatchType DAO() {
  59                    retu rn batchTy peDAO;
  60           }
  61  
  62           pu blic void  setBatchTy peDAO(Batc hTypeDAO b atchTypeDA O) {
  63                    this .batchType DAO = batc hTypeDAO;
  64           }
  65  
  66           pu blic Batch StatusDAO  getBatchSt atusDAO()  {
  67                    retu rn batchSt atusDAO;
  68           }
  69  
  70           pu blic void  setBatchSt atusDAO(Ba tchStatusD AO batchSt atusDAO) {
  71                    this .batchStat usDAO = ba tchStatusD AO;
  72           }
  73  
  74           pu blic List< BatchType>  getBatchT ypeList()  {
  75  
  76                    retu rn batchTy peDAO.batc hTypeList( );
  77           }
  78  
  79           pu blic Batch Item getLa testBatchI temById(in t id) {
  80  
  81                    Batc hJob bj =  batchJobDA O.getBatch Job(id);
  82  
  83                    retu rn getBatc hItemForJo b(bj);
  84           }
  85  
  86           pu blic Batch Item getBa tchItemFor Job(BatchJ ob bj) {
  87  
  88                    if ( bj != null ) {
  89                             // Set  the job t ype from t he db.
  90                             bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() ));
  91                    }
  92  
  93                    Batc hRun run =  batchRunD AO.getLast RunByBatch JobId(bj.g etId());
  94  
  95                    if ( run != nul l) {
  96                             run.se tBatchStat us(batchSt atusDAO.ge tStatusTyp e(run.getS tatusId()) );
  97                    }
  98  
  99                    retu rn new Bat chItem(bj,  run);
  100           }
  101  
  102           pu blic List< BatchJob>  getBatchJo bList() {
  103  
  104                    List <BatchJob>  bjL = bat chJobDAO.b atchList() ;
  105  
  106                    for  (BatchJob  bj : bjL)  {
  107                             // Set  the job t ype from t he db.
  108                             bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() ));
  109                    }
  110  
  111                    retu rn bjL;
  112           }
  113  
  114           pu blic List< BatchItem>  getLatest BatchItems List() {
  115  
  116                    List <BatchItem > batchIte mL = new A rrayList<> ();
  117  
  118                    List <BatchJob>  jobL = ba tchJobDAO. batchList( );
  119  
  120                    // G et all of  the jobs.
  121                    for  (BatchJob  bj : jobL)  {
  122                             batchI temL.add(g etBatchIte mForJob(bj ));
  123                    }
  124  
  125                    retu rn batchIt emL;
  126           }
  127  
  128           pu blic Batch Job getBat chJobByNam e(String n ame) {
  129  
  130                    // G et the job  from the  db.
  131                    Batc hJob bj =  batchJobDA O.getBatch JobByName( name);
  132  
  133                    if ( bj != null ) {
  134  
  135                             // Set  the job t ype from t he db.
  136                             bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() ));
  137                    }
  138  
  139                    retu rn bj;
  140           }
  141  
  142           pu blic Batch Job getBat chJobById( int id) {
  143  
  144                    // G et the job  from the  db.
  145                    Batc hJob bj =  batchJobDA O.getBatch Job(id);
  146  
  147                    if ( bj != null ) {
  148  
  149                             // Set  the job t ype from t he db.
  150                             bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() ));
  151                    }
  152                    retu rn bj;
  153           }
  154  
  155           pu blic Batch Run startR un(int id)  {
  156  
  157                    Batc hRun bR =  null;
  158  
  159                    Inte ger startS tatus = ba tchStatusD AO.getStat usFromEnum (BatchStat us.JobStat us.RUNNING );
  160  
  161                    if ( startStatu s != null)  {
  162                             Timest amp startD ate = new  Timestamp( Calendar.g etInstance ().getTime ().getTime ());
  163                             bR = n ew BatchRu n(id, star tDate, sta rtStatus);
  164                             int ru nId = batc hRunDAO.sa ve(bR);
  165                             bR.set Id(runId);
  166                    } el se {
  167                             logger .error("Un able to ob tain statu s mapping  for: " + B atchStatus .JobStatus .RUNNING);
  168                    }
  169  
  170                    retu rn bR;
  171           }
  172  
  173           pu blic boole an complet eRun(Batch Run bR) {
  174  
  175                    bool ean succes s = false;
  176  
  177                    Inte ger endSta tus = batc hStatusDAO .getStatus FromEnum(B atchStatus .JobStatus .COMPLETE) ;
  178  
  179                    if ( endStatus  != null) {
  180                             Timest amp endDat e = new Ti mestamp(Ca lendar.get Instance() .getTime() .getTime() );
  181  
  182                             bR.set EndDate(en dDate);
  183                             bR.set StatusId(e ndStatus);
  184                             bR.set BatchStatu s(batchSta tusDAO.get StatusType (endStatus ));
  185  
  186                             batchR unDAO.upda te(bR);
  187  
  188                             succes s = true;
  189  
  190                    } el se {
  191                             logger .error("Un able to ob tain statu s mapping  for: " + B atchStatus .JobStatus .COMPLETE) ;
  192                    }
  193  
  194                    retu rn success ;
  195           }
  196  
  197           pu blic boole an errorRu n(BatchRun  bR) {
  198  
  199                    bool ean succes s = false;
  200  
  201                    Inte ger endSta tus = batc hStatusDAO .getStatus FromEnum(B atchStatus .JobStatus .ERROR);
  202  
  203                    if ( endStatus  != null) {
  204                             Timest amp endDat e = new Ti mestamp(Ca lendar.get Instance() .getTime() .getTime() );
  205  
  206                             bR.set EndDate(en dDate);
  207                             bR.set StatusId(e ndStatus);
  208                             bR.set BatchStatu s(batchSta tusDAO.get StatusType (endStatus ));
  209  
  210                             batchR unDAO.upda te(bR);
  211  
  212                             succes s = true;
  213  
  214                    } el se {
  215                             logger .error("Un able to ob tain statu s mapping  for: " + B atchStatus .JobStatus .ERROR);
  216                    }
  217  
  218                    retu rn success ;
  219           }
  220  
  221           pu blic boole an setNotR unningById (BatchJob  batchJob)  {
  222  
  223                    bool ean reset  = false;
  224  
  225                    Inte ger runnin gStatus =  batchStatu sDAO.getSt atusFromEn um(BatchSt atus.JobSt atus.RUNNI NG);
  226                    Inte ger notRun ningStatus  = batchSt atusDAO.ge tStatusFro mEnum(Batc hStatus.Jo bStatus.NO T_RUNNING) ;
  227  
  228                    if ( (runningSt atus != nu ll) && (no tRunningSt atus != nu ll)) {
  229  
  230                             // Upd ate existi ng status  from Runni ng to NotR unning.
  231                             BatchR un run = b atchRunDAO .getLastRu nByBatchJo bId(batchJ ob.getId() );
  232  
  233                             if ((r un != null ) && (run. getStatusI d() == run ningStatus )) {
  234                                      run.setS tatusId(no tRunningSt atus);
  235                                      batchRun DAO.update (run);
  236                                      reset =  true;
  237                             }
  238  
  239                    } el se {
  240                             logger .error("Un able to ob tain statu s mapping  for: " + B atchStatus .JobStatus .RUNNING +  " or "
  241                                               + BatchSta tus.JobSta tus.NOT_RU NNING + "  when attem pting to c heck for r unning job  ("
  242                                               + validate StringInpu t(batchJob .getName() , LOG_FORG ING) + ")" );
  243                    }
  244  
  245                    retu rn reset;
  246           }
  247  
  248           pu blic Batch Type getBa tchTypeFor Job(BatchJ ob batchJo b) {
  249                    retu rn batchTy peDAO.getB atchType(b atchJob.ge tTypeId()) ;
  250           }
  251  
  252           pu blic void  updateBatc hJob(Batch Job batchJ ob) {
  253                    batc hJobDAO.up date(batch Job);
  254           }
  255   }