Produced by Araxis Merge on 6/9/2017 3:51:23 PM Eastern Daylight 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Jun 9 19:51:23 2017 UTC | ||
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-svc-facility\src\main\java\gov\va\nvap\svc\facility\jpa\impl | FacilityJpaController.java | Fri Apr 21 20:03:30 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 134 |
| Removed | 0 | 0 |
| 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 |
No regular expressions were active.
| 1 | /* | |||||
| 2 | * To chan ge this te mplate, ch oose Tools | Templat es | |||||
| 3 | * and ope n the temp late in th e editor. | |||||
| 4 | */ | |||||
| 5 | package go v.va.nvap. svc.facili ty.jpa.imp l; | |||||
| 6 | ||||||
| 7 | import gov .va.nvap.s vc.facilit y.data.Fac ility; | |||||
| 8 | import gov .va.nvap.s vc.facilit y.intf.Ent ityDoesNot ExistExcep tion; | |||||
| 9 | import gov .va.nvap.s vc.facilit y.intf.Pre existingEn tityExcept ion; | |||||
| 10 | import gov .va.nvap.s vc.facilit y.jpa.intf .FacilityC ontrollerI nterface; | |||||
| 11 | ||||||
| 12 | import jav a.util.Col lection; | |||||
| 13 | import jav a.util.Lis t; | |||||
| 14 | ||||||
| 15 | import jav ax.persist ence.Entit yManager; | |||||
| 16 | import jav ax.persist ence.Entit yNotFoundE xception; | |||||
| 17 | import jav ax.persist ence.Persi stenceCont ext; | |||||
| 18 | import jav ax.persist ence.Query ; | |||||
| 19 | ||||||
| 20 | /** | |||||
| 21 | * | |||||
| 22 | * @author vhaislegb erb | |||||
| 23 | */ | |||||
| 24 | public cla ss Facilit yJpaContro ller imple ments Faci lityContro llerInterf ace { | |||||
| 25 | ||||||
| 26 | @P ersistence Context(na me = "VapE ntityManag er") | |||||
| 27 | pr ivate Enti tyManager em; | |||||
| 28 | ||||||
| 29 | @O verride | |||||
| 30 | pu blic void create(fin al Facilit y facility ) | |||||
| 31 | throws Preexisti ngEntityEx ception, E xception { | |||||
| 32 | try { | |||||
| 33 | this.e m.persist( facility); | |||||
| 34 | } ca tch (final Exception ex) { | |||||
| 35 | if (th is.findFac ility(faci lity.getFa cilityId() ) != null) { | |||||
| 36 | throw ne w Preexist ingEntityE xception(" Facility " + facilit y | |||||
| 37 | + " already exists.", ex); | |||||
| 38 | } | |||||
| 39 | throw ex; | |||||
| 40 | } | |||||
| 41 | } | |||||
| 42 | ||||||
| 43 | pu blic void destroy(fi nal Long i d) throws EntityDoes NotExistEx ception { | |||||
| 44 | this .em.getTra nsaction() .begin(); | |||||
| 45 | Faci lity facil ity; | |||||
| 46 | try { | |||||
| 47 | facili ty = this. em.getRefe rence(Faci lity.class , id); | |||||
| 48 | facili ty.getFaci lityId(); | |||||
| 49 | } ca tch (final EntityNot FoundExcep tion enfe) { | |||||
| 50 | throw new Entity DoesNotExi stExceptio n("The fac ility with id " + id | |||||
| 51 | + " no lon ger exists .", enfe); | |||||
| 52 | } | |||||
| 53 | this .em.remove (facility) ; | |||||
| 54 | this .em.getTra nsaction() .commit(); | |||||
| 55 | } | |||||
| 56 | ||||||
| 57 | @O verride | |||||
| 58 | pu blic void edit(Facil ity facili ty) throws EntityDoe sNotExistE xception, | |||||
| 59 | Except ion { | |||||
| 60 | try { | |||||
| 61 | facili ty = this. em.merge(f acility); | |||||
| 62 | } ca tch (final Exception ex) { | |||||
| 63 | final String msg = ex.getL ocalizedMe ssage(); | |||||
| 64 | if ((m sg == null ) || (msg. length() = = 0)) { | |||||
| 65 | final Lo ng id = fa cility.get FacilityId (); | |||||
| 66 | if (this .findFacil ity(id) == null) { | |||||
| 67 | throw new EntityDoes NotExistEx ception( | |||||
| 68 | "The facility with id " + id + " n o longer e xists.", | |||||
| 69 | ex); | |||||
| 70 | } | |||||
| 71 | } | |||||
| 72 | throw ex; | |||||
| 73 | } | |||||
| 74 | } | |||||
| 75 | ||||||
| 76 | @O verride | |||||
| 77 | pu blic Colle ction<Faci lity> find AllowedFac ilities() { | |||||
| 78 | fina l Query q = this.em. createName dQuery("Fa cility.fin dByAllowed "); | |||||
| 79 | q.se tParameter ("allowed" , true); | |||||
| 80 | retu rn q.getRe sultList() ; | |||||
| 81 | } | |||||
| 82 | ||||||
| 83 | @O verride | |||||
| 84 | pu blic Facil ity findFa cility(fin al Long id ) { | |||||
| 85 | retu rn this.em .find(Faci lity.class , id); | |||||
| 86 | } | |||||
| 87 | ||||||
| 88 | @O verride | |||||
| 89 | pu blic Facil ity findFa cilityBySt ationNumbe r(final St ring stati onId) thro ws EntityD oesNotExis tException { | |||||
| 90 | try { | |||||
| 91 | final Query q = this.em | |||||
| 92 | .createNam edQuery("F acility.fi ndByFacili tyStation" ); | |||||
| 93 | q.setP arameter(" facilitySt ation", st ationId); | |||||
| 94 | return ((Facilit y) q.getSi ngleResult ()); | |||||
| 95 | } ca tch (final Exception e) { | |||||
| 96 | throw new Entity DoesNotExi stExceptio n( | |||||
| 97 | "Cannot fi nd facilit y for Stat ion Number [" + stat ionId + "] . ", | |||||
| 98 | e); | |||||
| 99 | } | |||||
| 100 | ||||||
| 101 | } | |||||
| 102 | ||||||
| 103 | @O verride | |||||
| 104 | pu blic List< Facility> findFacili tyEntities () { | |||||
| 105 | retu rn this.fi ndFacility Entities(t rue, -1, - 1); | |||||
| 106 | } | |||||
| 107 | ||||||
| 108 | pr ivate List <Facility> findFacil ityEntitie s(final bo olean all, | |||||
| 109 | final int maxRes ults, fina l int firs tResult) { | |||||
| 110 | fina l Query q = this.em | |||||
| 111 | .createQ uery("sele ct object( o) from Fa cility as o order by LOWER(fac ilityName) "); | |||||
| 112 | if ( !all) { | |||||
| 113 | q.setM axResults( maxResults ); | |||||
| 114 | q.setF irstResult (firstResu lt); | |||||
| 115 | } | |||||
| 116 | retu rn q.getRe sultList() ; | |||||
| 117 | } | |||||
| 118 | ||||||
| 119 | @O verride | |||||
| 120 | pu blic List< Facility> findFacili tyEntities (final int maxResult s, | |||||
| 121 | final int firstR esult) { | |||||
| 122 | retu rn this.fi ndFacility Entities(f alse, maxR esults, fi rstResult) ; | |||||
| 123 | } | |||||
| 124 | ||||||
| 125 | pu blic int g etFacility Count() { | |||||
| 126 | fina l Query q = this.em | |||||
| 127 | .createQ uery("sele ct count(o ) from Fac ility as o "); | |||||
| 128 | retu rn ((Long) q.getSing leResult() ).intValue (); | |||||
| 129 | } | |||||
| 130 | ||||||
| 131 | pu blic void setEntityM anager(fin al EntityM anager em) { | |||||
| 132 | this .em = em; | |||||
| 133 | } | |||||
| 134 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.