Produced by Araxis Merge on 6/9/2017 3:51:17 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:17 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-consent-mgmt\src\main\java\gov\va\nvap\svc\consentmgmt\jpa | LocationJpaController.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 | 142 |
| 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.consen tmgmt.jpa; | |||||
| 6 | ||||||
| 7 | import gov .va.nvap.s vc.consent mgmt.Locat ionControl lerInterfa ce; | |||||
| 8 | import gov .va.nvap.s vc.consent mgmt.jpa.e xceptions. Nonexisten tEntityExc eption; | |||||
| 9 | import gov .va.nvap.s vc.consent mgmt.jpa.e xceptions. Preexistin gEntityExc eption; | |||||
| 10 | import gov .va.nvap.s vc.consent mgmt.stub. data.Facil ity; | |||||
| 11 | import gov .va.nvap.s vc.consent mgmt.stub. data.Locat ion; | |||||
| 12 | ||||||
| 13 | import jav a.util.Col lection; | |||||
| 14 | import jav a.util.Lis t; | |||||
| 15 | ||||||
| 16 | import jav ax.persist ence.Entit yManager; | |||||
| 17 | import jav ax.persist ence.Entit yNotFoundE xception; | |||||
| 18 | import jav ax.persist ence.Persi stenceCont ext; | |||||
| 19 | import jav ax.persist ence.Query ; | |||||
| 20 | ||||||
| 21 | /** | |||||
| 22 | * | |||||
| 23 | * @author Anand Sas try | |||||
| 24 | * | |||||
| 25 | * | |||||
| 26 | * | |||||
| 27 | * public Co llection<L ocation> ( ); | |||||
| 28 | * | |||||
| 29 | * Collectio n<Location > findByLo cation(Loc ation loca tion); | |||||
| 30 | */ | |||||
| 31 | public cla ss Locatio nJpaContro ller imple ments Loca tionContro llerInterf ace { | |||||
| 32 | ||||||
| 33 | @P ersistence Context(na me = "VapE ntityManag er") | |||||
| 34 | pr ivate Enti tyManager entityMana ger; | |||||
| 35 | ||||||
| 36 | @O verride | |||||
| 37 | pu blic void create(fin al Locatio n location ) | |||||
| 38 | throws Preexisti ngEntityEx ception, E xception { | |||||
| 39 | try { | |||||
| 40 | this.e ntityManag er.persist (location) ; | |||||
| 41 | } ca tch (final Exception ex) { | |||||
| 42 | if (th is.findLoc ation(loca tion.getLo cationId() ) != null) { | |||||
| 43 | throw ne w Preexist ingEntityE xception(" Location " + locatio n | |||||
| 44 | + " already exists.", ex); | |||||
| 45 | } | |||||
| 46 | throw ex; | |||||
| 47 | } | |||||
| 48 | } | |||||
| 49 | ||||||
| 50 | pu blic void destroy(fi nal Long i d) throws Nonexisten tEntityExc eption { | |||||
| 51 | this .entityMan ager.getTr ansaction( ).begin(); | |||||
| 52 | Loca tion locat ion; | |||||
| 53 | try { | |||||
| 54 | locati on = this. entityMana ger.getRef erence(Loc ation.clas s, id); | |||||
| 55 | locati on.getLoca tionId(); | |||||
| 56 | } ca tch (final EntityNot FoundExcep tion enfe) { | |||||
| 57 | throw new Nonexi stentEntit yException ("The loca tion with id " + id | |||||
| 58 | + " no lon ger exists .", enfe); | |||||
| 59 | } | |||||
| 60 | this .entityMan ager.remov e(location ); | |||||
| 61 | this .entityMan ager.getTr ansaction( ).commit() ; | |||||
| 62 | } | |||||
| 63 | ||||||
| 64 | @O verride | |||||
| 65 | pu blic void edit(Locat ion locati on) throws Nonexiste ntEntityEx ception, | |||||
| 66 | Except ion { | |||||
| 67 | try { | |||||
| 68 | locati on = this. entityMana ger.merge( location); | |||||
| 69 | } ca tch (final Exception ex) { | |||||
| 70 | final String msg = ex.getL ocalizedMe ssage(); | |||||
| 71 | if ((m sg == null ) || (msg. length() = = 0)) { | |||||
| 72 | final Lo ng id = lo cation.get LocationId (); | |||||
| 73 | if (this .findLocat ion(id) == null) { | |||||
| 74 | throw new Nonexisten tEntityExc eption( | |||||
| 75 | "The location with id " + id + " n o longer e xists."); | |||||
| 76 | } | |||||
| 77 | } | |||||
| 78 | throw ex; | |||||
| 79 | } | |||||
| 80 | } | |||||
| 81 | ||||||
| 82 | @O verride | |||||
| 83 | pu blic Colle ction<Loca tion> find ActiveLoca tions() { | |||||
| 84 | fina l Query q = this.ent ityManager | |||||
| 85 | .createN amedQuery( "Location. findByActi ve"); | |||||
| 86 | q.se tParameter ("active", 'Y'); | |||||
| 87 | retu rn q.getRe sultList() ; | |||||
| 88 | } | |||||
| 89 | ||||||
| 90 | @O verride | |||||
| 91 | pu blic Colle ction<Loca tion> find ByFacility (final Fac ility faci lity) { | |||||
| 92 | fina l Query q = this.ent ityManager | |||||
| 93 | .createN amedQuery( "Location. findByFaci lity"); | |||||
| 94 | q.se tParameter ("facility ", facilit y); | |||||
| 95 | retu rn q.getRe sultList() ; | |||||
| 96 | } | |||||
| 97 | ||||||
| 98 | @O verride | |||||
| 99 | pu blic Locat ion findBy LocationCo de(final S tring loca tionCode) { | |||||
| 100 | fina l Query q = this.ent ityManager | |||||
| 101 | .createN amedQuery( "Location. findByLoca tionCode") ; | |||||
| 102 | q.se tParameter ("location Code", loc ationCode) ; | |||||
| 103 | retu rn (Locati on) q.getS ingleResul t(); | |||||
| 104 | } | |||||
| 105 | ||||||
| 106 | @O verride | |||||
| 107 | pu blic Locat ion findLo cation(fin al Long id ) { | |||||
| 108 | retu rn this.en tityManage r.find(Loc ation.clas s, id); | |||||
| 109 | } | |||||
| 110 | ||||||
| 111 | @O verride | |||||
| 112 | pu blic List< Location> findLocati onEntities () { | |||||
| 113 | retu rn this.fi ndLocation Entities(t rue, -1, - 1); | |||||
| 114 | } | |||||
| 115 | ||||||
| 116 | pr ivate List <Location> findLocat ionEntitie s(final bo olean all, | |||||
| 117 | final int maxRes ults, fina l int firs tResult) { | |||||
| 118 | fina l Query q = this.ent ityManager | |||||
| 119 | .createQ uery("sele ct object( o) from Lo cation as o"); | |||||
| 120 | if ( !all) { | |||||
| 121 | q.setM axResults( maxResults ); | |||||
| 122 | q.setF irstResult (firstResu lt); | |||||
| 123 | } | |||||
| 124 | retu rn q.getRe sultList() ; | |||||
| 125 | } | |||||
| 126 | ||||||
| 127 | @O verride | |||||
| 128 | pu blic List< Location> findLocati onEntities (final int maxResult s, | |||||
| 129 | final int firstR esult) { | |||||
| 130 | retu rn this.fi ndLocation Entities(f alse, maxR esults, fi rstResult) ; | |||||
| 131 | } | |||||
| 132 | ||||||
| 133 | pu blic int g etLocation Count() { | |||||
| 134 | fina l Query q = this.ent ityManager | |||||
| 135 | .createQ uery("sele ct count(o ) from Loc ation as o "); | |||||
| 136 | retu rn ((Long) q.getSing leResult() ).intValue (); | |||||
| 137 | } | |||||
| 138 | ||||||
| 139 | pu blic void setEntityM anager(fin al EntityM anager ent ityManager ) { | |||||
| 140 | this .entityMan ager = ent ityManager ; | |||||
| 141 | } | |||||
| 142 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.