30. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/21/2017 6:15:13 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.

30.1 Files compared

# Location File Last Modified
1 Genisis_2.0_v7_bld7.zip\TS\Service\bookmarking-service\src\main\java\gov\va\genisis2\bs\service\impl BusinessService.java Thu Dec 14 19:57:17 2017 UTC
2 Genisis_2.0_v7_bld7.zip\TS\Service\bookmarking-service\src\main\java\gov\va\genisis2\bs\service\impl BusinessService.java Thu Dec 21 21:19:50 2017 UTC

30.2 Comparison summary

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

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

30.4 Active regular expressions

No regular expressions were active.

30.5 Comparison detail

  1           pa ckage gov. va.genisis 2.bs.servi ce.impl;
  2  
  3   import jav a.util.Lis t;
  4   import jav a.util.str eam.Collec tors;
  5  
  6   import jav ax.transac tion.Trans actional;
  7  
  8   import org .apache.lo gging.log4 j.LogManag er;
  9   import org .apache.lo gging.log4 j.Logger;
  10   import org .springfra mework.bea ns.factory .annotatio n.Autowire d;
  11   import org .springfra mework.dao .DataInteg rityViolat ionExcepti on;
  12   import org .springfra mework.ste reotype.Se rvice;
  13  
  14   import gov .va.genisi s2.bs.conv erter.Book markConver ter;
  15   import gov .va.genisi s2.bs.conv erter.Labe lConverter ;
  16   import gov .va.genisi s2.bs.data .model.Boo kmark;
  17   import gov .va.genisi s2.bs.data .model.Lab el;
  18   import gov .va.genisi s2.bs.data .repositor y.Bookmark Repository ;
  19   import gov .va.genisi s2.bs.data .repositor y.LabelRep ository;
  20   import gov .va.genisi s2.bs.serv ice.IBusin essService ;
  21   import gov .va.genisi s2.ts.comm on.dto.Boo kmarkDTO;
  22   import gov .va.genisi s2.ts.comm on.dto.Lab elDTO;
  23   import gov .va.genisi s2.ts.comm on.enums.E rrorEnum;
  24   import gov .va.genisi s2.ts.comm on.excepti on.TSDupli cateDataEx ception;
  25   import gov .va.genisi s2.ts.comm on.excepti on.TSNoDat aFoundExce ption;
  26   import gov .va.genisi s2.ts.comm on.excepti on.TSRunti meExceptio n;
  27  
  28   /**
  29    * Impleme ntation fo r Bookmark  Service c alls
  30    * @author   PII
  31    */
  32   @Service
  33   public cla ss Busines sService i mplements  IBusinessS ervice {
  34           
  35           pr ivate stat ic final L ogger LOGG ER = LogMa nager.getL ogger(Busi nessServic e.class);
  36           
  37           @A utowired
  38           pr ivate Book markReposi tory bookm arkReposit ory;
  39           
  40           @A utowired
  41           pr ivate Labe lRepositor y labelRep ository;
  42           
  43           @A utowired
  44           pr ivate Book markConver ter bookma rkConverte r;
  45           
  46           @A utowired
  47           pr ivate Labe lConverter  labelConv erter;
  48           
  49           @O verride
  50           @T ransaction al
  51           pu blic List< BookmarkDT O> getBook marks() {
  52                    List <Bookmark>  list = bo okmarkRepo sitory.fin dAll();
  53                    
  54                    if(  list == nu ll )
  55                             throw  new TSRunt imeExcepti on("Error  getting bo okmark lis t");
  56                    
  57                    retu rn list.st ream()
  58                                      .map(boo kmark -> b ookmarkCon verter.con vert(bookm ark))
  59                                      .collect (Collector s.toList() );
  60           }
  61           
  62           @O verride
  63           @T ransaction al
  64           pu blic Bookm arkDTO cre ateBookmar k(Bookmark DTO bookma rkDto) {
  65                    Book mark saved Bookmark =  null;
  66                    
  67                    //Co nvert the  DTO to a m odel objec t
  68                    Book mark bookm ark = book markConver ter.conver t(bookmark Dto);
  69                    
  70                    try  {
  71                             //Save  the bookm ark model
  72                             savedB ookmark =  bookmarkRe pository.s ave(bookma rk);
  73                    } ca tch (DataI ntegrityVi olationExc eption ex)  {
  74                             LOGGER .error(Str ing.format (ErrorEnum .BOOKMARK_ DUPLICATE_ ERROR.getE rrorMessag e(), 
  75                                               bookmarkDt o.getConce ptUri(), b ookmarkDto .getUserna me()), ex) ;
  76                             throw  new TSDupl icateDataE xception(
  77                                               String.for mat(ErrorE num.BOOKMA RK_DUPLICA TE_ERROR.g etErrorMes sage(), 
  78                                                                book markDto.ge tConceptUr i(), bookm arkDto.get Username() ), ex);
  79                    } ca tch (Excep tion e) {
  80                             LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR, e);
  81                             throw  new TSRunt imeExcepti on(ErrorEn um.INTERNA L_SYS_ERRO R.toString ());
  82                    }
  83                    retu rn bookmar kConverter .convert(s avedBookma rk);
  84           }
  85           
  86           @O verride
  87           @T ransaction al
  88           pu blic void  deleteBook mark(Integ er id) {
  89                    Book mark bookm ark = null ;
  90                    try  {
  91                             bookma rk = bookm arkReposit ory.findOn e(id);
  92                             if (bo okmark !=  null) {
  93                                      if (book mark.getLa bels() !=  null) {
  94                                               // Delete  associated  labels
  95                                               for (Label  l : bookm ark.getLab els()) {
  96                                                       la belReposit ory.delete (l.getLabe lId());
  97                                               }
  98                                      }
  99                                      // Final ly delete  the bookma rk
  100                                      bookmark Repository .delete(bo okmark.get BookmarkId ());
  101                             }
  102                             else {
  103                                      //bookma rk does no t exist
  104                                      throw ne w TSNoData FoundExcep tion(
  105                                                       St ring.forma t(ErrorEnu m.BOOKMARK _DOESNT_EX IST.getErr orMessage( ), id ));
  106                             }
  107                    } ca tch (Illeg alArgument Exception  e) {
  108                             LOGGER .error("Id : " + id +  " passed  is null");
  109                             throw  new TSRunt imeExcepti on(ErrorEn um.INTERNA L_SYS_ERRO R.toString (), e);
  110                    }
  111           }
  112           
  113           @O verride
  114           pu blic Bookm arkDTO lab elBookmark (LabelDTO  labelDto)  {
  115                    
  116                    //ch eck if the  bookmark  exists
  117                    Book mark bookm ark = book markReposi tory.findO ne(labelDt o.getBookm arkId());
  118                    if(  bookmark = = null )
  119                             throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .BOOKMARK_ DOESNT_EXI ST.getErro rMessage() ,
  120                                               labelDto.g etBookmark Id()));
  121                    
  122                    Labe l label =  labelConve rter.conve rt(labelDt o);
  123                    
  124                    labe l.setBookm ark(bookma rk);
  125                    
  126                    //in stead of j ust return ing the la bel..retur n the book mark and a ssociated  labels
  127                    Labe l savedLab el = label Repository .save(labe l) ;
  128                    Book mark updat edBookmark  = bookmar kRepositor y.findOne( savedLabel .getBookma rkId());
  129                    
  130                    if(  updatedBoo kmark == n ull ) //re ally shoul dn't happe n
  131                             throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .NO_DATA_F OUND_ERROR .getErrorM essage(),
  132                                               savedLabel .getBookma rkId()));
  133                    
  134                    retu rn bookmar kConverter .convert(u pdatedBook mark);
  135           }
  136           
  137           @O verride
  138           pu blic Bookm arkDTO unl abelBookma rk(LabelDT O labelDto ) {
  139  
  140                    Book mark bookm ark = book markReposi tory.findO ne(labelDt o.getBookm arkId());
  141                    
  142                    //ch eck if the  bookmark  exists
  143                    if(  bookmark = = null )
  144                             throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .NO_DATA_F OUND_ERROR .getErrorM essage(), 
  145                                               labelDto.g etBookmark Id()));
  146                    
  147                    Labe l label =  bookmark.g etLabels()
  148                    .str eam()
  149                    .fil ter( l ->  l.getName( ).equalsIg noreCase(l abelDto.ge tName()))
  150                    .fin dFirst().o rElse(null );
  151                    
  152                    if(  label == n ull )
  153                             throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .NO_DATA_F OUND_ERROR .getErrorM essage(),
  154                                               labelDto.g etName()))
  155                    
  156                    labe lRepositor y.delete(l abel.getLa belId());
  157                    
  158                    //in stead of r eturning t he deleted  label ret urn the up dated book mark and s hould NOT 
  159                    //sh ow the del eted label
  160                    Book mark updat edBookmark  = bookmar kRepositor y.findOne( bookmark.g etBookmark Id());
  161                    
  162                    if(  updatedBoo kmark == n ull )
  163                             throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .NO_DATA_F OUND_ERROR .getErrorM essage(),
  164                                               bookmark.g etBookmark Id()));
  165                    
  166                    retu rn bookmar kConverter .convert(u pdatedBook mark);
  167           }
  168           
  169           @O verride
  170           pu blic List< BookmarkDT O> fetchAl lBookmarks ByUsername (String us ername) {
  171                    
  172                    List <Bookmark>  bookmarks  = bookmar kRepositor y.getAllBo okmarksAnd LabelsGive nUsername( username);
  173                    
  174                    if(  bookmarks  == null )
  175                             throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .NO_DATA_F OUND_ERROR .getErrorM essage(),  username)) ;
  176                    
  177                    retu rn bookmar ks.stream( )
  178                    .map (bookmark  -> bookmar kConverter .convert(b ookmark))
  179                    .col lect(Colle ctors.toLi st());
  180           }
  181           
  182           @O verride
  183           pu blic List< BookmarkDT O> fetchAl lBookmarks ByLabel(St ring label ) {
  184                    List <Bookmark>  bookmarks  = bookmar kRepositor y.getAllBo okmakrsGiv enLabel(la bel);
  185                    
  186                    if(  bookmarks  == null )
  187                             throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .NO_DATA_F OUND_ERROR .getErrorM essage(),  label));
  188                    
  189                    retu rn bookmar ks.stream( )
  190                                      .map(boo kmark -> b ookmarkCon verter.con vert(bookm ark))
  191                                      .collect (Collector s.toList() );
  192           }
  193           
  194           @O verride
  195           pu blic List< LabelDTO>  fetchAllLa belsByUser name(Strin g username ){
  196           
  197                    List <Label> la bels = lab elReposito ry.getAllL abelsGiven Username(u sername);
  198                    
  199                    if(  labels ==  null )
  200                             throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .NO_DATA_F OUND_ERROR .getErrorM essage(),  username)) ;
  201                    
  202                    retu rn labels. stream()
  203                                      .map(lab el -> labe lConverter .convert(l abel))
  204                                      .collect (Collector s.toList() );
  205           }
  206   //      @O verride
  207   //      pu blic Bookm arkDTO get Bookmark(I nteger id)  {
  208   //               Book mark bookm ark = book markReposi tory.findO ne(id);
  209   //               
  210   //               if(  bookmark = = null ) {
  211   //                        throw  new TSNoDa taFoundExc eption(Str ing.format (ErrorEnum .NO_DATA_F OUND_ERROR .getErrorM essage(),  id));
  212   //               }
  213   //               
  214   //               retu rn bookmar kConverter .convert(b ookmark);
  215   //      }
  216           pu blic void  setBookmar kConverter ( Bookmark Converter  bookmarkCo nverter) {
  217                    this .bookmarkC onverter =  bookmarkC onverter;
  218           }
  219           
  220           pu blic void  setLabelCo nverter( L abelConver ter labelC onverter)  {
  221                    this .labelConv erter = la belConvert er;
  222           }
  223  
  224   }