Produced by Araxis Merge on 11/9/2017 4:31:05 PM Central 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.
# | Location | File | Last Modified |
---|---|---|---|
1 | PPS-N_B397.zip\PPS-N_B397\PPS-N_B397\PS_PPS_srv\src\main\java\gov\va\med\pharmacy\peps\service\common\capability\impl | RxNormUpdateCapabilityImpl.java | Thu Nov 9 15:08:06 2017 UTC |
2 | PPS-N_B397.zip\PPS-N_B397\PPS-N_B397\PS_PPS_srv\src\main\java\gov\va\med\pharmacy\peps\service\common\capability\impl | RxNormUpdateCapabilityImpl.java | Thu Nov 9 20:00:35 2017 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 548 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
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 | package go v.va.med.p harmacy.pe ps.service .common.ca pability.i mpl; | |
2 | ||
3 | import sta tic gov.va .med.pharm acy.peps.c ommon.util ity.securi ty.ESAPIVa lidationTy pe.LOG_FOR GING; | |
4 | import sta tic gov.va .med.pharm acy.peps.c ommon.util ity.securi ty.ESAPIVa lidator.va lidateStri ngInput; | |
5 | ||
6 | import gov .va.med.ph armacy.pep s.common.e mail.Email Service; | |
7 | import gov .va.med.ph armacy.pep s.common.u tility.Con figFileUti lity; | |
8 | import gov .va.med.ph armacy.pep s.common.v o.National Setting; | |
9 | import gov .va.med.ph armacy.pep s.common.v o.National SettingVo; | |
10 | import gov .va.med.ph armacy.pep s.common.v o.UserVo; | |
11 | import gov .va.med.ph armacy.pep s.domain.c ommon.capa bility.Nat ionalSetti ngDomainCa pability; | |
12 | import gov .va.med.ph armacy.pep s.domain.c ommon.mode l.EplProdu ctDo; | |
13 | import gov .va.med.ph armacy.pep s.domain.c ommon.util ity.RxNorm Capability ; | |
14 | import gov .va.med.ph armacy.pep s.domain.c ommon.util ity.client .rxnorm.Rx NormClient ; | |
15 | import gov .va.med.ph armacy.pep s.service. common.cap ability.Rx NormUpdate Capability ; | |
16 | import gov .va.med.ph armacy.pep s.service. common.sch eduler.Pro cessStatus ; | |
17 | ||
18 | import jav a.util.Dat e; | |
19 | import jav a.util.Lis t; | |
20 | import jav a.util.con current.Ti meUnit; | |
21 | ||
22 | import org .apache.lo gging.log4 j.LogManag er; | |
23 | import org .apache.lo gging.log4 j.Logger; | |
24 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
25 | import org .springfra mework.tra nsaction.P latformTra nsactionMa nager; | |
26 | import org .springfra mework.tra nsaction.T ransaction Definition ; | |
27 | import org .springfra mework.tra nsaction.T ransaction Status; | |
28 | import org .springfra mework.tra nsaction.s upport.Def aultTransa ctionDefin ition; | |
29 | ||
30 | /** | |
31 | * This cl ass is the main impl ementation that mana ges the Rx Norm updat e process. | |
32 | * | |
33 | * @author DN S EdgecK | |
34 | * | |
35 | */ | |
36 | public cla ss RxNormU pdateCapab ilityImpl implements RxNormUpd ateCapabil ity { | |
37 | ||
38 | privat e static f inal Logge r LOG = Lo gManager.g etLogger(R xNormUpdat eCapabilit yImpl.clas s); | |
39 | privat e National SettingDom ainCapabil ity nation alSettingD omainCapab ility; | |
40 | privat e RxNormCa pability r xNormCapab ility; | |
41 | privat e static f inal int T IMEOUT = 2 00; | |
42 | privat e static f inal int L ONG_TIMEOU T = 1200; | |
43 | ||
44 | @Autow ired | |
45 | privat e Platform Transactio nManager t ransaction Manager; | |
46 | ||
47 | @Autow ired | |
48 | privat e EmailSer vice email Service; | |
49 | ||
50 | /* | |
51 | * (no n-Javadoc) | |
52 | * | |
53 | * @se e | |
54 | * gov .va.med.ph armacy.pep s.service. common.cap ability.Rx NormUpdate Capability #process(g ov.va.med. pharmacy.p eps.common .vo. | |
55 | * Use rVo) | |
56 | */ | |
57 | @Overr ide | |
58 | public void proc ess(UserVo user) { | |
59 | ||
60 | tr y { | |
61 | updateJo bStatusToR unning(use r); | |
62 | ||
63 | List<Epl ProductDo> products = fetchRxN ormUpdateP roducts(); | |
64 | ||
65 | processP roducts(us er, produc ts); | |
66 | ||
67 | updateJo bStatusToC ompleted(u ser); | |
68 | ||
69 | } catch (Exc eption e) { | |
70 | e.printS tackTrace( ); | |
71 | LOG.erro r("Excepti on in RxNo rmUpdateCa pabilityIm pl.process () " + va lidateStri ngInput(e. getMessage (), LOG_FO RGING), | |
72 | e); | |
73 | if (e.ge tCause() ! = null) { | |
74 | LOG. error("The Underlyin g cause is " + e.get Cause().ge tMessage() , e); | |
75 | } | |
76 | updateJo bStatusToE rror(user) ; | |
77 | } | |
78 | } | |
79 | ||
80 | /** | |
81 | * Cal ls the RxN orm domain capabilit y to fetch and retur n a list o f EPL Prod uct object s that are enabled f or rxNorm updates | |
82 | * | |
83 | * @re turn the l ist of EPL Product o bjects to process | |
84 | */ | |
85 | privat e List<Epl ProductDo> fetchRxNo rmUpdatePr oducts() { | |
86 | De faultTrans actionDefi nition def ; | |
87 | Tr ansactionS tatus stat us; | |
88 | de f = new De faultTrans actionDefi nition(Tra nsactionDe finition.P ROPAGATION _REQUIRES_ NEW); | |
89 | de f.setTimeo ut(LONG_TI MEOUT); | |
90 | st atus = tra nsactionMa nager.getT ransaction (def); | |
91 | ||
92 | Li st<EplProd uctDo> pro ducts = rx NormCapabi lity.fetch RxNormUpda teProducts (); | |
93 | tr ansactionM anager.com mit(status ); | |
94 | ||
95 | re turn produ cts; | |
96 | } | |
97 | ||
98 | /** | |
99 | * Upd ates the R xNorm job status to Error | |
100 | * | |
101 | * @pa ram user | |
102 | * @pa ram e | |
103 | */ | |
104 | privat e void upd ateJobStat usToError( UserVo use r) { | |
105 | De faultTrans actionDefi nition def ; | |
106 | Tr ansactionS tatus stat us; | |
107 | de f = new De faultTrans actionDefi nition(Tra nsactionDe finition.P ROPAGATION _REQUIRES_ NEW); | |
108 | de f.setTimeo ut(TIMEOUT ); | |
109 | st atus = tra nsactionMa nager.getT ransaction (def); | |
110 | ||
111 | up dateStatus (ProcessSt atus.ERROR , user); | |
112 | ||
113 | tr ansactionM anager.com mit(status ); | |
114 | } | |
115 | ||
116 | /** | |
117 | * Thi s method i terates th ru a list of product s, creates a new tra nsaction f or each pr oduct, and passes pr ocessing d own into | |
118 | * the populate and persis t method o f the RxNo rm domain capability object. | |
119 | * | |
120 | * @pa ram user | |
121 | * @pa ram produc ts the lis t of produ cts to sen d to rxnor m | |
122 | */ | |
123 | privat e void pro cessProduc ts(UserVo user, List <EplProduc tDo> produ cts) { | |
124 | // We create and assig ned a bran d new Conf igFileUtil ity instan ce every t ime we | |
125 | // run the R XNorm upda te process . | |
126 | Co nfigFileUt ility conf igFile = n ew ConfigF ileUtility (); | |
127 | Da te runDate = new Dat e(); | |
128 | fo r (EplProd uctDo prod uct : prod ucts) { | |
129 | processE achProduct (user, pro duct, runD ate, confi gFile); | |
130 | } | |
131 | } | |
132 | ||
133 | /** | |
134 | * Pro cesses eac h product | |
135 | * | |
136 | * @pa ram user | |
137 | * @pa ram produc tDo | |
138 | * @pa ram runDat e | |
139 | */ | |
140 | privat e void pro cessEachPr oduct(User Vo user, E plProductD o productD o, Date ru nDate, Con figFileUti lity confi gFile) { | |
141 | ||
142 | De faultTrans actionDefi nition def = new Def aultTransa ctionDefin ition(Tran sactionDef inition.PR OPAGATION_ REQUIRED); | |
143 | Tr ansactionS tatus stat us = trans actionMana ger.getTra nsaction(d ef); | |
144 | de f.setTimeo ut(TIMEOUT ); | |
145 | rx NormCapabi lity.popul ateAndPers ist(user, productDo, runDate, configFile ); | |
146 | // Job compl etes norma lly | |
147 | tr ansactionM anager.com mit(status ); | |
148 | } | |
149 | ||
150 | /** | |
151 | * Upd ates the R xNorm job status to Completed | |
152 | * | |
153 | * @pa ram user | |
154 | */ | |
155 | privat e void upd ateJobStat usToComple ted(UserVo user) { | |
156 | De faultTrans actionDefi nition def ; | |
157 | Tr ansactionS tatus stat us; | |
158 | de f = new De faultTrans actionDefi nition(Tra nsactionDe finition.P ROPAGATION _REQUIRES_ NEW); | |
159 | de f.setTimeo ut(TIMEOUT ); | |
160 | st atus = tra nsactionMa nager.getT ransaction (def); | |
161 | ||
162 | up dateStatus (ProcessSt atus.COMPL ETED, user ); | |
163 | up dateRuntim e(user); | |
164 | ||
165 | tr ansactionM anager.com mit(status ); | |
166 | } | |
167 | ||
168 | /** | |
169 | * Upd ates the R xNorm job status to Running | |
170 | * | |
171 | * @pa ram user | |
172 | */ | |
173 | privat e void upd ateJobStat usToRunnin g(UserVo u ser) { | |
174 | De faultTrans actionDefi nition def ; | |
175 | Tr ansactionS tatus stat us; | |
176 | de f = new De faultTrans actionDefi nition(Tra nsactionDe finition.P ROPAGATION _REQUIRES_ NEW); | |
177 | de f.setTimeo ut(TIMEOUT ); | |
178 | st atus = tra nsactionMa nager.getT ransaction (def); | |
179 | ||
180 | LO G.info("-- ---------- ---process ing RXNORM Update--- ---------- ------"); | |
181 | ||
182 | up dateStatus (ProcessSt atus.RUNNI NG, user); | |
183 | ||
184 | tr ansactionM anager.com mit(status ); | |
185 | } | |
186 | ||
187 | /** | |
188 | * The updateRun time metho d will upd ate the Rx Norm Updat e run stat us. | |
189 | * | |
190 | * @pa ram proces sStatus Pr ocessStatu s | |
191 | */ | |
192 | privat e void upd ateStatus( ProcessSta tus proces sStatus, U serVo user ) { | |
193 | ||
194 | // This code can be re placed wit h ProcessS tatusUpdat er. | |
195 | Na tionalSett ingVo retu rnedSettin g = nation alSettingD omainCapab ility | |
196 | .retriev e(National Setting.RX NORM_UPDAT E_RUN_STAT E.toString ()); | |
197 | ||
198 | re turnedSett ing.setStr ingValue(p rocessStat us.toStrin g()); | |
199 | na tionalSett ingDomainC apability. update(ret urnedSetti ng, user); | |
200 | } | |
201 | ||
202 | /** | |
203 | * The updateRun time metho d will upd ate the Rx Norm Updat e runtime date. | |
204 | */ | |
205 | privat e void upd ateRuntime (UserVo us er) { | |
206 | ||
207 | // This code can be re placed wit h ProcessS tatusUpdat er. | |
208 | Na tionalSett ingVo retu rnedSettin g = nation alSettingD omainCapab ility | |
209 | .retriev e(National Setting.RX NORM_UPDAT E_LAST_RUN .toString( )); | |
210 | ||
211 | re turnedSett ing.setDat eValue(new Date()); | |
212 | na tionalSett ingDomainC apability. update(ret urnedSetti ng, user); | |
213 | } | |
214 | ||
215 | /** | |
216 | * get s the Tran sactionMan ager for R xNormUpdat eCapabilit yImpl. | |
217 | * | |
218 | * @re turn the t ransaction Manager | |
219 | */ | |
220 | public PlatformT ransaction Manager ge tTransacti onManager( ) { | |
221 | re turn trans actionMana ger; | |
222 | } | |
223 | ||
224 | /** | |
225 | * set s the Tran sactionMan ager for R xNormUpdat eCapabilit yImpl. | |
226 | * | |
227 | * @pa ram transa ctionManag er the tra nsactionMa nager to s et | |
228 | */ | |
229 | public void setT ransaction Manager(Pl atformTran sactionMan ager trans actionMana ger) { | |
230 | th is.transac tionManage r = transa ctionManag er; | |
231 | } | |
232 | ||
233 | /** | |
234 | * set NationalSe ttingDomai nCapabilit y in Propo sedInactiv ateCapabil ityImpl. | |
235 | * | |
236 | * @pa ram nation alSettingD omainCapab ility the nationalSe ttingDomai nCapabilit y to set | |
237 | */ | |
238 | public void setN ationalSet tingDomain Capability (NationalS ettingDoma inCapabili ty nationa lSettingDo mainCapabi lity) { | |
239 | th is.nationa lSettingDo mainCapabi lity = nat ionalSetti ngDomainCa pability; | |
240 | } | |
241 | ||
242 | /** | |
243 | * Get s the rx n orm capabi lity. | |
244 | * | |
245 | * @re turn the r x norm cap ability | |
246 | */ | |
247 | public RxNormCap ability ge tRxNormCap ability() { | |
248 | re turn rxNor mCapabilit y; | |
249 | } | |
250 | ||
251 | /** | |
252 | * Set s the rx n orm capabi lity. | |
253 | * | |
254 | * @pa ram rxNorm Capability the new r x norm cap ability | |
255 | */ | |
256 | public void setR xNormCapab ility(RxNo rmCapabili ty rxNormC apability) { | |
257 | th is.rxNormC apability = rxNormCa pability; | |
258 | } | |
259 | ||
260 | /** | |
261 | * @re turn the e mailServic e | |
262 | */ | |
263 | public EmailServ ice getEma ilService( ) { | |
264 | re turn email Service; | |
265 | } | |
266 | ||
267 | /** | |
268 | * @pa ram emailS ervice the emailServ ice to set | |
269 | */ | |
270 | public void setE mailServic e(EmailSer vice email Service) { | |
271 | th is.emailSe rvice = em ailService ; | |
272 | } | |
273 | ||
274 | ||
275 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.