Produced by Araxis Merge on 9/11/2017 8:05:39 AM Central 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 | MHV_CIF_2017.4.0.0.zip\MHV_CIF_2017.4.0.0\MHV_CIF_2017.4.0.0\mhv_source\mhv_user\mhv-usermgmt-portal-portlet\src\main\java\gov\va\med\mhv\usermgmt\web\controller | AbstractListController.java | Wed May 24 22:13:24 2017 UTC |
2 | MHV_CIF_2017.4.0.0.zip\MHV_CIF_2017.4.0.0\MHV_CIF_2017.4.0.0\mhv_source\mhv_user\mhv-usermgmt-portal-portlet\src\main\java\gov\va\med\mhv\usermgmt\web\controller | AbstractListController.java | Thu Sep 7 19:12:24 2017 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 510 |
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.m hv.usermgm t.web.cont roller; | |
2 | ||
3 | import jav a.io.Seria lizable; | |
4 | import jav a.util.Arr ayList; | |
5 | import jav a.util.Lis t; | |
6 | ||
7 | import jav ax.annotat ion.Resour ce; | |
8 | import jav ax.faces.a pplication .FacesMess age; | |
9 | import jav ax.faces.c omponent.U ICommand; | |
10 | import jav ax.faces.c ontext.Fac esContext; | |
11 | import jav ax.faces.e vent.Actio nEvent; | |
12 | ||
13 | import org .apache.lo gging.log4 j.LogManag er; | |
14 | import org .apache.lo gging.log4 j.Logger; | |
15 | import org .springfra mework.bea ns.factory .annotatio n.Value; | |
16 | import org .springfra mework.con text.annot ation.Prop ertySource ; | |
17 | ||
18 | import gov .va.med.mh v.common.a pi.dto.Use rProfileDT O; | |
19 | import gov .va.med.mh v.common.a pi.excepti on.MHVExce ption; | |
20 | import gov .va.med.mh v.common.p rops.Tomca tJndiDataS ourcePrope rtySourceF actory; | |
21 | import gov .va.med.mh v.usermgmt .service.U serMgmtSer vice; | |
22 | ||
23 | /** | |
24 | * Abstrac t class us ed to supp ort list p ages that require pa gination. | |
25 | * @author
|
|
26 | * | |
27 | * @param <M> | |
28 | */ | |
29 | public abs tract clas s Abstract ListContro ller<M> im plements S erializabl e { | |
30 | ||
31 | pr ivate stat ic final l ong serial VersionUID = 8170893 1540740479 67L; | |
32 | ||
33 | pr ivate stat ic Logger log = LogM anager.get Logger(Abs tractListC ontroller. class); | |
34 | ||
35 | pr otected Us erProfileD TO userPro file = nul l; | |
36 | ||
37 | @R esource(na me = "user MgmtServic eProxy") | |
38 | pr otected Us erMgmtServ ice userMg mtService; | |
39 | ||
40 | @V alue("${en dpointUrl} ") | |
41 | pr ivate Stri ng endpoin tUrl; | |
42 | ||
43 | @V alue("${lo goutUrl}") | |
44 | pr ivate Stri ng logoutU rl; | |
45 | ||
46 | pr otected Li st<M> view List = nul l; | |
47 | pr otected Li st<M> mode lList = nu ll; | |
48 | ||
49 | pr otected In teger toDi splay = ne w Integer( 10); | |
50 | ||
51 | pr otected in t totalRow s; | |
52 | ||
53 | // Pag ing. | |
54 | pr otected in t firstRow = 0; | |
55 | ||
56 | pr otected in t rowsPerP age = 10; | |
57 | pr otected in t totalPag es = 1000; | |
58 | pr otected in t pageRang e = 10; | |
59 | pr otected In teger[] pa ges; | |
60 | pr otected in t currentP age = 0; | |
61 | pr otected in t total = 0; | |
62 | ||
63 | /** | |
64 | * This me thod needs to be ove rriden by the child class Thi s method i s intended to popula te the mod elList fro m the appr opriates d ata source . | |
65 | */ | |
66 | pu blic abstr act void l oadModel() ; | |
67 | ||
68 | pu blic void loadList() { | |
69 | log. debug("Abs tractListP ortlet.loa dList"); | |
70 | if( modelList == null || modelList .size() == 0 ) { | |
71 | loadMo del(); | |
72 | } | |
73 | tota lRows = mo delList.si ze(); | |
74 | log. debug("Abs tractListP ortlet.loa dList - to talRows: " + totalRo ws); | |
75 | log. debug("Abs tractListP ortlet.loa dList - fi rstRows: " + firstRo w); | |
76 | view List = new ArrayList <M>(); | |
77 | tota l = firstR ow + rowsP erPage; | |
78 | ||
79 | if( total > mo delList.si ze() ) | |
80 | total = modelLis t.size(); | |
81 | ||
82 | page s = new In teger[0]; | |
83 | ||
84 | view List = mod elList.sub List(first Row, total ); | |
85 | ||
86 | curr entPage = (totalRows / rowsPer Page) - (( totalRows - firstRow ) / rowsPe rPage) + 1 ; | |
87 | to talPages = (totalRow s / rowsPe rPage) + ( (totalRows % rowsPer Page != 0) ? 1 : 0); | |
88 | in t pagesLen gth = Math .min(pageR ange, tota lPages); | |
89 | pa ges = new Integer[pa gesLength] ; | |
90 | ||
91 | // firstPage must be g reater tha n 0 and le sser than totalPages -pageLengt h. | |
92 | in t firstPag e = Math.m in(Math.ma x(0, curre ntPage - ( pageRange / 2)), tot alPages - pagesLengt h); | |
93 | ||
94 | // Create pa ges (page numbers fo r page lin ks). | |
95 | fo r (int i = 0; i < pa gesLength; i++) { | |
96 | pages[i] = ++first Page; | |
97 | } | |
98 | ||
99 | } | |
100 | ||
101 | /* * | |
102 | * Method to get the U serProfile object | |
103 | * @param us erName | |
104 | * @return | |
105 | * / | |
106 | pr otected Us erProfileD TO getUser Profile(St ring userN ame) { | |
107 | if( userProfil e == null ) { | |
108 | ||
109 | try { | |
110 | userProf ile = this .userMgmtS ervice.get UserProfil e(userName ); | |
111 | } catc h (MHVExce ption e) { | |
112 | log.erro r("Error i n getuserp rofle:",e) ; | |
113 | FacesCon text.getCu rrentInsta nce().addM essage( | |
114 | nu ll, new Fa cesMessage (FacesMess age.SEVERI TY_ERROR, "Error get ting UserP rofile", " Error gett ing UserPr ofile")); | |
115 | } | |
116 | ||
117 | } | |
118 | return us erProfile; | |
119 | } | |
120 | ||
121 | ||
122 | ||
123 | ||
124 | pu blic List< M> getView List() { | |
125 | retu rn viewLis t; | |
126 | } | |
127 | ||
128 | pu blic void setViewLis t(List<M> viewList) { | |
129 | this .viewList = viewList ; | |
130 | } | |
131 | ||
132 | //-------- ------- Pa gination - ---------- ---------- ---------- ----- | |
133 | pu blic void pageFirst( ActionEven t e) { | |
134 | log. debug("Abs tractListP ortlet.pag eFirst"); | |
135 | page (0); | |
136 | } | |
137 | ||
138 | public void page Next(Actio nEvent e) { | |
139 | log. debug("Abs tractListP ortlet.pag eNext"); | |
140 | pa ge(firstRo w + rowsPe rPage); | |
141 | } | |
142 | ||
143 | public void page Previous(A ctionEvent e) { | |
144 | log. debug("Abs tractListP ortlet.pag ePrevious" ); | |
145 | pa ge(firstRo w - rowsPe rPage); | |
146 | } | |
147 | ||
148 | public void page Last(Actio nEvent e) { | |
149 | log. debug("Abs tractListP ortlet.pag eLast"); | |
150 | pa ge(totalRo ws - ((tot alRows % r owsPerPage != 0) ? t otalRows % rowsPerPa ge : rowsP erPage)); | |
151 | } | |
152 | ||
153 | public void page (ActionEve nt event) { | |
154 | log. debug("Abs tractListP ortlet.pag e"); | |
155 | pa ge(((Integ er) ((UICo mmand) eve nt.getComp onent()).g etValue() - 1) * row sPerPage); | |
156 | } | |
157 | public void disp lay10(Acti onEvent ev ent) { | |
158 | log. debug("Abs tractListP ortlet.dis play10"); | |
159 | rows PerPage = 10; | |
160 | load List(); | |
161 | } | |
162 | public void disp lay25(Acti onEvent ev ent) { | |
163 | log. debug("Abs tractListP ortlet.dis play25"); | |
164 | rows PerPage = 25; | |
165 | load List(); | |
166 | } | |
167 | public void disp lay50(Acti onEvent ev ent) { | |
168 | log. debug("Abs tractListP ortlet.dis play50"); | |
169 | rows PerPage = 50; | |
170 | load List(); | |
171 | } | |
172 | public void disp lay100(Act ionEvent e vent) { | |
173 | log. debug("Abs tractListP ortlet.dis play100"); | |
174 | rows PerPage = 100; | |
175 | load List(); | |
176 | } | |
177 | ||
178 | privat e void pag e(int firs tRow) { | |
179 | log. debug("Abs tractListP ortlet.pag e: " + fir stRow); | |
180 | th is.firstRo w = firstR ow; | |
181 | lo adList(); // Load re quested pa ge. | |
182 | } | |
183 | //-------- ---------- ---------- ---------- -- | |
184 | ||
185 | ||
186 | pu blic Integ er getToDi splay() { | |
187 | retu rn toDispl ay; | |
188 | } | |
189 | ||
190 | pu blic void setToDispl ay(Integer toDisplay ) { | |
191 | this .toDisplay = toDispl ay; | |
192 | } | |
193 | ||
194 | ||
195 | pu blic int g etTotalPag es() { | |
196 | retu rn totalPa ges; | |
197 | } | |
198 | ||
199 | pu blic void setTotalPa ges(int to talPages) { | |
200 | this .totalPage s = totalP ages; | |
201 | } | |
202 | ||
203 | pu blic int g etPageRang e() { | |
204 | retu rn pageRan ge; | |
205 | } | |
206 | ||
207 | pu blic void setPageRan ge(int pag eRange) { | |
208 | this .pageRange = pageRan ge; | |
209 | } | |
210 | ||
211 | pu blic Integ er[] getPa ges() { | |
212 | retu rn pages; | |
213 | } | |
214 | ||
215 | pu blic void setPages(I nteger[] p ages) { | |
216 | this .pages = p ages; | |
217 | } | |
218 | ||
219 | pu blic int g etCurrentP age() { | |
220 | retu rn current Page; | |
221 | } | |
222 | ||
223 | pu blic void setCurrent Page(int c urrentPage ) { | |
224 | this .currentPa ge = curre ntPage; | |
225 | } | |
226 | ||
227 | public int getFi rstRow() { | |
228 | re turn first Row; | |
229 | } | |
230 | public void setF irstRow(in t firstRow ) { | |
231 | th is.firstRo w = firstR ow; | |
232 | } | |
233 | public int getTo talRows() { | |
234 | retu rn totalRo ws; | |
235 | } | |
236 | ||
237 | pu blic void setTotalRo ws(int tot alRows) { | |
238 | this .totalRows = totalRo ws; | |
239 | } | |
240 | ||
241 | pu blic int g etRowsPerP age() { | |
242 | retu rn rowsPer Page; | |
243 | } | |
244 | ||
245 | pu blic void setRowsPer Page(int r owsPerPage ) { | |
246 | this .rowsPerPa ge = rowsP erPage; | |
247 | } | |
248 | ||
249 | pu blic int g etTotal() { | |
250 | retu rn total; | |
251 | } | |
252 | ||
253 | pu blic void setTotal(i nt total) { | |
254 | this .total = t otal; | |
255 | } | |
256 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.