1 package org.kuali.ole.describe.controller;
2
3 import org.apache.commons.collections.CollectionUtils;
4 import org.apache.commons.lang.StringUtils;
5 import org.apache.log4j.Logger;
6 import org.kuali.ole.DocumentUniqueIDPrefix;
7 import org.kuali.ole.OLEConstants;
8 import org.kuali.ole.describe.bo.SearchResultDisplayFields;
9 import org.kuali.ole.describe.bo.SearchResultDisplayRow;
10 import org.kuali.ole.describe.form.GlobalEditForm;
11 import org.kuali.ole.describe.form.OLESearchForm;
12 import org.kuali.ole.describe.service.BrowseService;
13 import org.kuali.ole.describe.service.impl.BrowseServiceImpl;
14 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
15 import org.kuali.ole.docstore.common.document.*;
16 import org.kuali.ole.docstore.common.document.config.DocFieldConfig;
17 import org.kuali.ole.docstore.common.document.config.DocFormatConfig;
18 import org.kuali.ole.docstore.common.document.config.DocTypeConfig;
19 import org.kuali.ole.docstore.common.document.config.DocumentSearchConfig;
20 import org.kuali.ole.docstore.common.document.content.enums.DocFormat;
21 import org.kuali.ole.docstore.common.document.content.enums.DocType;
22 import org.kuali.ole.docstore.common.document.content.instance.OleHoldings;
23 import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
24 import org.kuali.ole.docstore.common.search.*;
25 import org.kuali.ole.select.bo.OLEEditorResponse;
26 import org.kuali.ole.select.businessobject.OleCopy;
27 import org.kuali.ole.select.businessobject.OleDocstoreResponse;
28 import org.kuali.ole.select.document.OLEEResourceRecordDocument;
29 import org.kuali.ole.service.OLEEResourceSearchService;
30 import org.kuali.ole.sys.context.SpringContext;
31 import org.kuali.rice.core.api.exception.RiceRuntimeException;
32 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
33 import org.kuali.rice.kim.api.identity.Person;
34 import org.kuali.rice.kim.api.identity.PersonService;
35 import org.kuali.rice.kim.api.permission.PermissionService;
36 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
37 import org.kuali.rice.kns.service.KNSServiceLocator;
38 import org.kuali.rice.krad.service.BusinessObjectService;
39 import org.kuali.rice.krad.service.DocumentService;
40 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
41 import org.kuali.rice.krad.uif.UifParameters;
42 import org.kuali.rice.krad.uif.view.View;
43 import org.kuali.rice.krad.util.GlobalVariables;
44 import org.kuali.rice.krad.util.KRADConstants;
45 import org.kuali.rice.krad.web.controller.MethodAccessible;
46 import org.kuali.rice.krad.web.controller.UifControllerBase;
47 import org.kuali.rice.krad.web.form.UifFormBase;
48 import org.springframework.stereotype.Controller;
49 import org.springframework.validation.BindingResult;
50 import org.springframework.web.bind.annotation.ModelAttribute;
51 import org.springframework.web.bind.annotation.RequestMapping;
52 import org.springframework.web.bind.annotation.RequestMethod;
53 import org.springframework.web.servlet.ModelAndView;
54
55 import javax.servlet.http.HttpServletRequest;
56 import javax.servlet.http.HttpServletResponse;
57 import java.util.*;
58
59
60
61
62
63
64
65
66 @Controller
67 @RequestMapping(value = "/olesearchcontroller")
68 public class OLESearchController extends UifControllerBase {
69
70 private static final Logger LOG = Logger.getLogger(OLESearchController.class);
71 private String eResourceId;
72 private String tokenId;
73 private String linkToOrderOption;
74 private int totalRecCount;
75 private int start;
76 private int pageSize;
77 private DocstoreClientLocator docstoreClientLocator;
78 private OLEEResourceSearchService oleEResourceSearchService;
79 private BrowseService browseService;
80 private DocumentService documentService;
81
82 public BrowseService getBrowseService() {
83 if (browseService == null) {
84 browseService = new BrowseServiceImpl();
85 }
86 return browseService;
87 }
88
89 public OLEEResourceSearchService getOleEResourceSearchService() {
90 if (oleEResourceSearchService == null) {
91 oleEResourceSearchService = GlobalResourceLoader.getService(OLEConstants.OLEEResourceRecord.ERESOURSE_SEARCH_SERVICE);
92 }
93 return oleEResourceSearchService;
94 }
95
96 public DocumentService getDocumentService() {
97 if (this.documentService == null) {
98 this.documentService = KRADServiceLocatorWeb.getDocumentService();
99 }
100 return this.documentService;
101 }
102
103 public void setDocumentService(DocumentService documentService) {
104 this.documentService = documentService;
105 }
106
107 DocumentSearchConfig documentSearchConfig = DocumentSearchConfig.getDocumentSearchConfig();
108
109
110 public DocstoreClientLocator getDocstoreClientLocator() {
111 if (null == docstoreClientLocator) {
112 return SpringContext.getBean(DocstoreClientLocator.class);
113 }
114 return docstoreClientLocator;
115 }
116
117 public int getTotalRecCount() {
118 return totalRecCount;
119 }
120
121 public void setTotalRecCount(int totalRecCount) {
122 this.totalRecCount = totalRecCount;
123 }
124
125 public int getStart() {
126 return start;
127 }
128
129 public void setStart(int start) {
130 this.start = start;
131 }
132
133 public int getPageSize() {
134 return pageSize;
135 }
136
137 public void setPageSize(int pageSize) {
138 this.pageSize = pageSize;
139 }
140
141 public boolean getPreviousFlag() {
142 if (this.start == 0)
143 return false;
144 return true;
145 }
146
147 public boolean getNextFlag() {
148 if (this.start + this.pageSize < this.totalRecCount)
149 return true;
150 return false;
151 }
152
153 public String getPageShowEntries() {
154 return "Showing " + ((this.start == 0) ? 1 : this.start + 1) + " to "
155 + (((this.start + this.pageSize) > this.totalRecCount) ? this.totalRecCount : (this.start + this.pageSize))
156 + " of " + this.totalRecCount + " entries";
157 }
158
159 public String getFacetShowEntries(SearchParams searchParams, int totalRecordCount) {
160 return "Showing " + ((searchParams.getFacetOffset() == 0) ? 1 : searchParams.getFacetOffset() + 1) + " to "
161 + (((searchParams.getFacetOffset() + searchParams.getFacetLimit()) > totalRecordCount) ? totalRecordCount : (searchParams.getFacetOffset() + searchParams.getFacetLimit()))
162 + " of " + totalRecordCount + " entries";
163 }
164
165 @Override
166 protected UifFormBase createInitialForm() {
167 return new OLESearchForm();
168
169 }
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234 @Override
235 @MethodAccessible
236 @RequestMapping(params = "methodToCall=start")
237 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form) {
238 this.start = 0;
239 LOG.debug("Inside the olesearchform start method");
240 OLESearchForm oleSearchForm = (OLESearchForm) form;
241 oleSearchForm.setWorkBibDocumentList(null);
242 oleSearchForm.setWorkHoldingsDocumentList(null);
243 oleSearchForm.setWorkItemDocumentList(null);
244 oleSearchForm.setWorkEHoldingsDocumentList(null);
245 oleSearchForm.setSearchTypeField("OLESearch");
246 oleSearchForm.getRequest().getSession().setAttribute("selectedFacetResults", null);
247 if (oleSearchForm.getDocType() == null) {
248 oleSearchForm.setDocType(DocType.BIB.getCode());
249 }
250 if (oleSearchForm.getSearchParams() == null) {
251 oleSearchForm.setSearchParams(new SearchParams());
252 }
253 if (StringUtils.isEmpty(oleSearchForm.getSearchType())) {
254 oleSearchForm.setSearchType("search");
255 }
256 if (StringUtils.isEmpty(oleSearchForm.getBrowseField())) {
257 oleSearchForm.setBrowseField("title");
258 }
259
260 oleSearchForm.getSearchConditions().clear();
261
262 SearchCondition searchCondition = new SearchCondition();
263 searchCondition.setOperator("AND");
264 SearchField searchField = new SearchField();
265 searchField.setDocType(oleSearchForm.getDocType());
266 searchField.setFieldName("any");
267 searchCondition.setSearchField(searchField);
268 oleSearchForm.getSearchConditions().add(searchCondition);
269 String eInstance = oleSearchForm.getRequest().getParameter(OLEConstants.E_INSTANCE);
270 if (eInstance != null && eInstance.equalsIgnoreCase(OLEConstants.LINK_EXISTING_INSTANCE)) {
271 oleSearchForm.setLinkExistingInstance(eInstance);
272 }
273 if (oleSearchForm.getRequest().getParameter(OLEConstants.E_RESOURCE_ID) != null) {
274 eResourceId = oleSearchForm.getRequest().getParameter(OLEConstants.E_RESOURCE_ID);
275 }
276 if (oleSearchForm.getRequest().getParameter(OLEConstants.TOKEN_ID) != null) {
277 tokenId = oleSearchForm.getRequest().getParameter(OLEConstants.TOKEN_ID);
278 oleSearchForm.setTokenId(tokenId);
279 }
280 if (oleSearchForm.getRequest().getParameter(OLEConstants.LINK_TO_ORDER_OPTION) != null) {
281 linkToOrderOption = oleSearchForm.getRequest().getParameter(OLEConstants.LINK_TO_ORDER_OPTION);
282 oleSearchForm.setLinkToOrderOption(linkToOrderOption);
283 }
284 oleSearchForm.setStart(0);
285 if (oleSearchForm.getSearchParams() != null) {
286 oleSearchForm.getSearchParams().setStartIndex(0);
287 }
288 clearForm(oleSearchForm);
289 GlobalVariables.getMessageMap().clearErrorMessages();
290 boolean hasSearchPermission = canSearch(GlobalVariables.getUserSession().getPrincipalId());
291 if (!hasSearchPermission && oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.BIB_DOC_TYPE)) {
292 boolean hasLinkPermission = canLinkBibForRequisition(GlobalVariables.getUserSession().getPrincipalId());
293 if (!hasLinkPermission) {
294 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_AUTHORIZATION);
295 return super.navigate(oleSearchForm);
296 }
297 } else if (!hasSearchPermission) {
298 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_AUTHORIZATION);
299 return super.navigate(oleSearchForm);
300 }
301 oleSearchForm.setMessage(null);
302 oleSearchForm.setSearchResultDisplayRowList(null);
303 oleSearchForm.setBibSearchResultDisplayRowList(null);
304 oleSearchForm.setHoldingSearchResultDisplayRowList(null);
305 oleSearchForm.setShowTime(true);
306 return super.navigate(oleSearchForm);
307 }
308
309 private boolean canSearch(String principalId) {
310 PermissionService service = KimApiServiceLocator.getPermissionService();
311 return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.DESC_WORKBENCH_SEARCH);
312 }
313
314 private boolean canLinkBibForRequisition(String principalId) {
315 PermissionService service = KimApiServiceLocator.getPermissionService();
316 return service.hasPermission(principalId, OLEConstants.SELECT_NMSPC, OLEConstants.LINK_EXISTING_BIB);
317 }
318
319 @MethodAccessible
320 @RequestMapping(params = "methodToCall=submit")
321 public ModelAndView submit(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
322 HttpServletRequest request, HttpServletResponse response) throws Exception {
323 OLESearchForm oleSearchForm = (OLESearchForm) form;
324 boolean isValid = false;
325 BusinessObjectService boService = KNSServiceLocator.getBusinessObjectService();
326 Map<String, String> map = new HashMap<>();
327 List<Integer> resultList = new ArrayList<>();
328 for (SearchResultDisplayRow searchResultDisplayRow : oleSearchForm.getSearchResultDisplayRowList()) {
329 if (searchResultDisplayRow.isSelect()) {
330 map.put(OLEConstants.BIB_ID, DocumentUniqueIDPrefix.getPrefixedId("wbm", searchResultDisplayRow.getLocalId()));
331 List<OleCopy> listOfValues = (List<OleCopy>) KRADServiceLocatorWeb.getLegacyDataAdapter().findMatching(OleCopy.class, map);
332 if (listOfValues.size() > 0 && (oleSearchForm.getMessage() == null || oleSearchForm.getMessage().equals(""))) {
333 for (OleCopy oleCopy : listOfValues) {
334 resultList.add(oleCopy.getReqDocNum());
335 }
336 Set<Integer> resultSet = new HashSet<>(resultList);
337 resultList = new ArrayList<>(resultSet);
338 StringBuffer reqIds = new StringBuffer("");
339 if (resultList.size() > 0) {
340 int count = 0;
341 for (; count < resultList.size() - 1; count++) {
342 reqIds.append(resultList.get(count) + ",");
343 }
344 reqIds.append(resultList.get(count));
345 }
346 oleSearchForm.setMessage(OLEConstants.POPUP_MESSAGE + reqIds.toString() + OLEConstants.PROCEED_MESSAGE);
347 return getModelAndView(oleSearchForm);
348 }
349 oleSearchForm.setMessage("");
350 processNewRecordResponseForOLE(searchResultDisplayRow.getLocalId(), oleSearchForm.getTokenId(), oleSearchForm.getLinkToOrderOption());
351 oleSearchForm.setSuccessMessage(OLEConstants.LINK_SUCCESS_MESSAGE);
352 isValid = true;
353 break;
354 }
355 }
356 if (isValid == false) {
357 GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.GLOBAL_ERRORS, OLEConstants.BIB_SELECT);
358 return getModelAndView(oleSearchForm);
359 }
360 return getModelAndView(oleSearchForm);
361 }
362
363 @MethodAccessible
364 @RequestMapping(params = "methodToCall=search")
365 public ModelAndView search(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
366 HttpServletRequest request, HttpServletResponse response) {
367 float start = System.currentTimeMillis() / 1000;
368 OLESearchForm oleSearchForm = (OLESearchForm) form;
369 boolean hasSearchPermission = canSearch(GlobalVariables.getUserSession().getPrincipalId());
370 if (!hasSearchPermission && oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.BIB_DOC_TYPE)) {
371 boolean hasLinkPermission = canLinkBibForRequisition(GlobalVariables.getUserSession().getPrincipalId());
372 if (!hasLinkPermission) {
373 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_AUTHORIZATION);
374 return super.navigate(oleSearchForm);
375 }
376 } else if (!hasSearchPermission) {
377 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_AUTHORIZATION);
378 return super.navigate(oleSearchForm);
379 }
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395 oleSearchForm.getSearchParams().setFacetOffset(0);
396 searchDocstoreData(oleSearchForm, request);
397 float end = System.currentTimeMillis() / 1000;
398 oleSearchForm.setServerTime(String.valueOf(end - start));
399 return super.navigate(oleSearchForm);
400 }
401 private void processNewRecordResponseForOLE(String bibId, String tokenId, String linkToOrderOption) throws Exception {
402 String instanceUUID = null;
403 BibTree bibTree = getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(bibId);
404 OLEEditorResponse oleEditorResponse = new OLEEditorResponse();
405 if (bibTree.getHoldingsTrees() != null && bibTree.getHoldingsTrees().size() > 0) {
406 instanceUUID = bibTree.getHoldingsTrees().get(0).getId();
407 }
408 oleEditorResponse.setLinkedInstanceId(instanceUUID);
409 oleEditorResponse.setBib(bibTree.getBib());
410 oleEditorResponse.setTokenId(tokenId);
411 oleEditorResponse.setLinkToOrderOption(linkToOrderOption);
412 HashMap<String, OLEEditorResponse> oleEditorResponseMap = new HashMap<String, OLEEditorResponse>();
413 oleEditorResponseMap.put(tokenId, oleEditorResponse);
414 OleDocstoreResponse.getInstance().setEditorResponse(oleEditorResponseMap);
415 }
416
417 protected void setShowPageSizeEntries(OLESearchForm oleSearchForm) {
418 List<Integer> pageSizes = documentSearchConfig.getPageSizes();
419 if (CollectionUtils.isEmpty(pageSizes)) {
420 pageSizes.add(10);
421 pageSizes.add(25);
422 pageSizes.add(50);
423 pageSizes.add(100);
424 }
425 oleSearchForm.setShowPageSize(pageSizes.toString());
426 }
427
428 @MethodAccessible
429 @RequestMapping(params = "methodToCall=nextSearch")
430 public ModelAndView nextSearch(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
431 HttpServletRequest request, HttpServletResponse response) throws Exception {
432
433 OLESearchForm oleSearchForm = (OLESearchForm) form;
434 SearchParams searchParams = oleSearchForm.getSearchParams();
435 int start = Math.max(0, searchParams.getStartIndex() + searchParams.getPageSize());
436 searchParams.setStartIndex(start);
437 return search(oleSearchForm,result,request,response);
438 }
439
440 @MethodAccessible
441 @RequestMapping(params = "methodToCall=previousSearch")
442 public ModelAndView previousSearch(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
443 HttpServletRequest request, HttpServletResponse response) throws Exception {
444
445 OLESearchForm oleSearchForm = (OLESearchForm) form;
446 SearchParams searchParams = oleSearchForm.getSearchParams();
447 int start = Math.max(0, searchParams.getStartIndex() - oleSearchForm.getPageSize());
448 searchParams.setStartIndex(start);
449 return search(oleSearchForm,result,request,response);
450 }
451
452 @MethodAccessible
453 @RequestMapping(params = "methodToCall=facetSearch")
454 public ModelAndView facetSearch(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
455 HttpServletRequest request, HttpServletResponse response) {
456 OLESearchForm oleSearchForm = (OLESearchForm) form;
457 String docType = request.getParameter("docType");
458 String selectedFacet = request.getParameter("selectedFacet");
459 String selectedFacetName = request.getParameter("selectedFacetName");
460 oleSearchForm.setDocType(docType);
461 if (oleSearchForm.getSearchParams() == null) {
462 SearchParams searchParams = (SearchParams) request.getSession().getAttribute("searchParams");
463 oleSearchForm.setSearchParams(searchParams);
464 }
465 oleSearchForm.getSearchConditions().clear();
466 SearchCondition searchCondition = new SearchCondition();
467 List<Integer> pageSizes = documentSearchConfig.getPageSizes();
468 if (!pageSizes.isEmpty() || pageSizes.size() > 0) {
469 oleSearchForm.setPageSize(pageSizes.get(0));
470 }
471 searchCondition.setOperator("AND");
472 oleSearchForm.getSearchConditions().addAll(oleSearchForm.getSearchParams().getSearchConditions());
473 String eInstance = request.getParameter(OLEConstants.E_INSTANCE);
474 if (eInstance != null && eInstance.equalsIgnoreCase(OLEConstants.LINK_EXISTING_INSTANCE)) {
475 oleSearchForm.setLinkExistingInstance(eInstance);
476 }
477 if (request.getParameter(OLEConstants.TOKEN_ID) != null) {
478 tokenId = request.getParameter(OLEConstants.TOKEN_ID);
479 }
480 oleSearchForm.getSearchParams().getFacetFields().addAll(getFacetFields(oleSearchForm.getDocType()));
481 oleSearchForm.getSearchParams().setFacetPrefix("");
482 oleSearchForm.getSearchParams().setFacetLimit(documentSearchConfig.getFacetPageSizeShort());
483 FacetCondition facetCondition = new FacetCondition();
484 facetCondition.setFieldName(selectedFacetName);
485 facetCondition.setFieldValue(selectedFacet);
486 oleSearchForm.getSearchParams().getFacetConditions().add(facetCondition);
487 oleSearchForm.setSearchType("search");
488 GlobalVariables.getMessageMap().clearErrorMessages();
489 return search(oleSearchForm,result,request,response);
490 }
491
492 @MethodAccessible
493 @RequestMapping(params = "methodToCall=removeFacet")
494 public ModelAndView removeFacet(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
495 HttpServletRequest request, HttpServletResponse response) {
496 OLESearchForm oleSearchForm = (OLESearchForm) form;
497 int index = Integer.parseInt(oleSearchForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
498 if (!CollectionUtils.isEmpty(oleSearchForm.getSearchParams().getFacetConditions()) && oleSearchForm.getSearchParams().getFacetConditions().size() > index) {
499 oleSearchForm.getSearchParams().getFacetConditions().remove(index);
500 }
501 return search(oleSearchForm,result,request,response);
502 }
503
504 @MethodAccessible
505 @RequestMapping(params = "methodToCall=moreFacets")
506 public ModelAndView moreFacets(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
507 HttpServletRequest request, HttpServletResponse response) {
508 OLESearchForm oleSearchForm = (OLESearchForm) form;
509 if (StringUtils.isEmpty(oleSearchForm.getDocType())) {
510 oleSearchForm.setDocType(request.getParameter("docType"));
511 }
512 SearchParams searchParams = oleSearchForm.getSearchParams();
513 if (searchParams == null) {
514 searchParams = (SearchParams) request.getSession().getAttribute("searchParams");
515 }
516 if (StringUtils.isNotEmpty(request.getParameter("facetField"))) {
517 if (!CollectionUtils.isEmpty(searchParams.getFacetFields())) {
518 searchParams.getFacetFields().clear();
519 }
520 searchParams.getFacetFields().add(request.getParameter("facetField"));
521 }
522 if (StringUtils.isNotEmpty(request.getParameter("facetPrefix"))) {
523 searchParams.setFacetPrefix(request.getParameter("facetPrefix"));
524 }
525 oleSearchForm.setSearchParams(searchParams);
526 searchParams.setFacetOffset(0);
527 searchParams.setFacetLimit(documentSearchConfig.getFacetPageSizeLong());
528 oleSearchForm.setMoreFacets(true);
529 searchDocstoreData(oleSearchForm, request);
530 return super.navigate(oleSearchForm);
531 }
532
533 @MethodAccessible
534 @RequestMapping(params = "methodToCall=nextFacet")
535 public ModelAndView nextFacet(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
536 HttpServletRequest request, HttpServletResponse response) {
537 OLESearchForm oleSearchForm = (OLESearchForm) form;
538 if (StringUtils.isEmpty(oleSearchForm.getDocType())) {
539 oleSearchForm.setDocType(request.getParameter("docType"));
540 }
541 SearchParams searchParams = oleSearchForm.getSearchParams();
542 if (searchParams == null) {
543 searchParams = (SearchParams) request.getSession().getAttribute("searchParams");
544 }
545 if (StringUtils.isNotEmpty(request.getParameter("facetField"))) {
546 if (!CollectionUtils.isEmpty(searchParams.getFacetFields())) {
547 searchParams.getFacetFields().clear();
548 }
549 searchParams.getFacetFields().add(request.getParameter("facetField"));
550 }
551 int facetCount = oleSearchForm.getSearchResponse().getFacetResult().getFacetResultFields().get(0).getTotalCount();
552 int facetOffset = searchParams.getFacetOffset() + documentSearchConfig.getFacetPageSizeLong();
553 searchParams.setFacetOffset(facetOffset);
554 oleSearchForm.setSearchParams(searchParams);
555 oleSearchForm.setMoreFacets(true);
556
557
558 oleSearchForm.setFacetPageEntries(getFacetShowEntries(searchParams, facetCount));
559 searchDocstoreData(oleSearchForm, request);
560 return super.navigate(oleSearchForm);
561 }
562
563 @MethodAccessible
564 @RequestMapping(params = "methodToCall=previousFacet")
565 public ModelAndView previousFacet(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
566 HttpServletRequest request, HttpServletResponse response) {
567 OLESearchForm oleSearchForm = (OLESearchForm) form;
568 if (StringUtils.isEmpty(oleSearchForm.getDocType())) {
569 oleSearchForm.setDocType(request.getParameter("docType"));
570 }
571 SearchParams searchParams = oleSearchForm.getSearchParams();
572 if (searchParams == null) {
573 searchParams = (SearchParams) request.getSession().getAttribute("searchParams");
574 }
575 if (StringUtils.isNotEmpty(request.getParameter("facetField"))) {
576 if (!CollectionUtils.isEmpty(searchParams.getFacetFields())) {
577 searchParams.getFacetFields().clear();
578 }
579 searchParams.getFacetFields().add(request.getParameter("facetField"));
580 }
581 int facetCount = oleSearchForm.getSearchResponse().getFacetResult().getFacetResultFields().get(0).getTotalCount();
582 int facetLimit = searchParams.getFacetOffset() - documentSearchConfig.getFacetPageSizeLong();
583 searchParams.setFacetOffset(facetLimit > 0 ? facetLimit : 0);
584 oleSearchForm.setSearchParams(searchParams);
585 oleSearchForm.setMoreFacets(true);
586 oleSearchForm.setFacetPageEntries(getFacetShowEntries(searchParams, facetCount));
587 searchDocstoreData(oleSearchForm, request);
588 return super.navigate(oleSearchForm);
589 }
590
591 @MethodAccessible
592 @RequestMapping(params = "methodToCall=browse")
593 public ModelAndView browse(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
594 HttpServletRequest request, HttpServletResponse response) {
595 OLESearchForm oleSearchForm = (OLESearchForm) form;
596
597 boolean hasPermission = performBrowse(GlobalVariables.getUserSession().getPrincipalId());
598 if (!hasPermission) {
599 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_INFO, OLEConstants.ERROR_AUTHORIZATION);
600 return getModelAndView(oleSearchForm);
601 }
602 if (request.getParameter(OLEConstants.CLS_BTN_SHOWN_FLG) != null) {
603 if (request.getParameter(OLEConstants.CLS_BTN_SHOWN_FLG).equalsIgnoreCase(OLEConstants.TRUE)) {
604 if (oleSearchForm.getDocType() == null || oleSearchForm.getDocType().equalsIgnoreCase("")) {
605 oleSearchForm.setDocType(request.getParameter(OLEConstants.DOCTYPE));
606 }
607 if (oleSearchForm.getLocation() == null || oleSearchForm.getLocation().equalsIgnoreCase("")) {
608 oleSearchForm.setLocation(request.getParameter(OLEConstants.LOC));
609 }
610 if (oleSearchForm.getClassificationScheme() == null || oleSearchForm.getClassificationScheme().equalsIgnoreCase("")) {
611 oleSearchForm.setClassificationScheme(request.getParameter(OLEConstants.CLASSIFICATION_SCHEME));
612 }
613 if (oleSearchForm.getCallNumberBrowseText() == null || oleSearchForm.getCallNumberBrowseText().equalsIgnoreCase("")) {
614 oleSearchForm.setCallNumberBrowseText(request.getParameter(OLEConstants.CALL_NUMBER_BROWSE_TXT));
615 }
616 if (oleSearchForm.getSearchType() == null || oleSearchForm.getSearchType().equalsIgnoreCase("")) {
617 oleSearchForm.setSearchType(request.getParameter(OLEConstants.SEARCH_TYPE));
618 }
619 if (oleSearchForm.getBrowseField() == null || oleSearchForm.getBrowseField().equalsIgnoreCase("")) {
620 oleSearchForm.setBrowseField(request.getParameter(OLEConstants.BROWSE_FIELD));
621 }
622 }
623 }
624
625 if ("title".equals(oleSearchForm.getBrowseField())) {
626 oleSearchForm.setDocType(DocType.BIB.getCode());
627 List<SearchResultDisplayRow> searchResultDisplayRowList = getBrowseService().browse(oleSearchForm);
628 oleSearchForm.setSearchResultDisplayRowList(searchResultDisplayRowList);
629
630 } else {
631
632 String location = getBrowseService().validateLocation(oleSearchForm.getLocation());
633 oleSearchForm.setLocation(location);
634
635 if (oleSearchForm.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())) {
636 List<Item> itemList = getBrowseService().browse(oleSearchForm);
637 oleSearchForm.setItemList(itemList);
638 } else {
639 List<Holdings> holdingsList = getBrowseService().browse(oleSearchForm);
640 oleSearchForm.setHoldingsList(holdingsList);
641 }
642 }
643 setBrowsePageNextPrevoiusAndEntriesInfo(oleSearchForm);
644 return getModelAndView(form);
645 }
646
647 @MethodAccessible
648 @RequestMapping(params = "methodToCall=workBenchBrowseClear")
649 public ModelAndView workBenchClear(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
650 HttpServletRequest request, HttpServletResponse response) throws Exception {
651 OLESearchForm oleSearchForm = (OLESearchForm) form;
652 List<Integer> pageSizes = documentSearchConfig.getPageSizes();
653 if(!pageSizes.isEmpty() || pageSizes.size() > 0) {
654 oleSearchForm.setPageSize(pageSizes.get(0));
655 }
656 oleSearchForm.setBrowseText("");
657 if (oleSearchForm.getSearchResultDisplayRowList() != null) {
658 oleSearchForm.getSearchResultDisplayRowList().clear();
659 }
660 return navigate(oleSearchForm);
661 }
662
663 @MethodAccessible
664 @RequestMapping(params = "methodToCall=rowsBrowse")
665 public ModelAndView rowsBrowse(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
666 HttpServletRequest request, HttpServletResponse response) throws Exception {
667 LOG.debug("Inside the browse method");
668 OLESearchForm oleSearchForm = (OLESearchForm) form;
669 if ("title".equals(oleSearchForm.getBrowseField())) {
670 oleSearchForm.setDocType(DocType.BIB.getCode());
671 List<SearchResultDisplayRow> searchResultDisplayRowList = getBrowseService().browseOnChange(oleSearchForm);
672 oleSearchForm.setSearchResultDisplayRowList(searchResultDisplayRowList);
673
674 } else {
675
676 if (oleSearchForm.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())) {
677 List<Item> itemList = getBrowseService().browseOnChange(oleSearchForm);
678 oleSearchForm.setItemList(itemList);
679 } else {
680 List<Holdings> holdingsList = getBrowseService().browseOnChange(oleSearchForm);
681 oleSearchForm.setHoldingsList(holdingsList);
682 }
683 }
684 setBrowsePageNextPrevoiusAndEntriesInfo(oleSearchForm);
685 return getModelAndView(form);
686 }
687
688 @MethodAccessible
689 @RequestMapping(params = "methodToCall=previous")
690 public ModelAndView previous(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
691 HttpServletRequest request, HttpServletResponse response) throws Exception {
692 LOG.debug("Inside the browse method");
693 OLESearchForm oleSearchForm = (OLESearchForm) form;
694 if ("title".equals(oleSearchForm.getBrowseField())) {
695 oleSearchForm.setDocType(DocType.BIB.getCode());
696 List<SearchResultDisplayRow> searchResultDisplayRowList = getBrowseService().browsePrev(oleSearchForm);
697 oleSearchForm.setSearchResultDisplayRowList(searchResultDisplayRowList);
698
699 } else {
700
701 if (oleSearchForm.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())) {
702 List<Item> itemList = getBrowseService().browsePrev(oleSearchForm);
703 oleSearchForm.setItemList(itemList);
704 } else {
705 List<Holdings> holdingsList = getBrowseService().browsePrev(oleSearchForm);
706 oleSearchForm.setHoldingsList(holdingsList);
707 }
708 }
709 setBrowsePageNextPrevoiusAndEntriesInfo(oleSearchForm);
710 return getModelAndView(form);
711 }
712
713 @MethodAccessible
714 @RequestMapping(params = "methodToCall=next")
715 public ModelAndView next(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
716 HttpServletRequest request, HttpServletResponse response) throws Exception {
717 LOG.debug("Inside the browse method");
718 OLESearchForm oleSearchForm = (OLESearchForm) form;
719 if ("title".equals(oleSearchForm.getBrowseField())) {
720 oleSearchForm.setDocType(DocType.BIB.getCode());
721 List<SearchResultDisplayRow> searchResultDisplayRowList = getBrowseService().browseNext(oleSearchForm);
722 oleSearchForm.setSearchResultDisplayRowList(searchResultDisplayRowList);
723
724 } else {
725
726 if (oleSearchForm.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())) {
727 List<Item> itemList = getBrowseService().browseNext(oleSearchForm);
728 oleSearchForm.setItemList(itemList);
729 } else {
730 List<Holdings> holdingsList = getBrowseService().browseNext(oleSearchForm);
731 oleSearchForm.setHoldingsList(holdingsList);
732 }
733 }
734 setBrowsePageNextPrevoiusAndEntriesInfo(oleSearchForm);
735 return getModelAndView(form);
736 }
737
738 @MethodAccessible
739 @RequestMapping(params = "methodToCall=clear")
740 public ModelAndView clear(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
741 HttpServletRequest request, HttpServletResponse response) {
742 LOG.debug("Inside the clear method");
743 OLESearchForm oleSearchForm = (OLESearchForm) form;
744 clearForm(oleSearchForm);
745
746 return super.start(oleSearchForm);
747 }
748
749 @MethodAccessible
750 @RequestMapping(params = "methodToCall=back")
751 public ModelAndView back(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
752 HttpServletRequest request, HttpServletResponse response) {
753 LOG.debug("Inside the clear method");
754 return super.back(form);
755 }
756
757 @MethodAccessible
758 @RequestMapping(params = "methodToCall=exportToXml")
759 public ModelAndView exportToXml(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
760 HttpServletRequest request, HttpServletResponse response) {
761 OLESearchForm oleSearchForm = (OLESearchForm) form;
762 boolean hasPermission = canExportToRequestXml(GlobalVariables.getUserSession().getPrincipalId());
763 if (!hasPermission) {
764 oleSearchForm.setJumpToId("breadcrumb_label");
765 oleSearchForm.setFocusId("breadcrumb_label");
766 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_AUTHORIZATION);
767 return navigate(oleSearchForm);
768 }
769 List<String> idsToExport = new ArrayList<>();
770 for (SearchResultDisplayRow searchResultDisplayRow : oleSearchForm.getSearchResultDisplayRowList()) {
771 if (searchResultDisplayRow.isSelect()) {
772 idsToExport.add(searchResultDisplayRow.getLocalId());
773 }
774 }
775 String requestXml = "";
776 if (oleSearchForm.getDocType().equalsIgnoreCase(DocType.BIB.getCode())) {
777
778 try {
779 BibTrees bibTrees = new BibTrees();
780 for (String id : idsToExport) {
781 BibTree bibTree = getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(id);
782 bibTrees.getBibTrees().add(bibTree);
783 }
784 requestXml = BibTrees.serialize(bibTrees);
785 } catch (Exception e) {
786 e.printStackTrace();
787 }
788 }
789
790 if (oleSearchForm.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode())) {
791 try {
792 HoldingsTrees holdingsTrees = new HoldingsTrees();
793 for (String id : idsToExport) {
794 HoldingsTree holdingsTree = getDocstoreClientLocator().getDocstoreClient().retrieveHoldingsTree(id);
795 holdingsTrees.getHoldingsTrees().add(holdingsTree);
796 }
797 requestXml = HoldingsTrees.serialize(holdingsTrees);
798 } catch (Exception e) {
799 e.printStackTrace();
800 }
801
802 }
803
804 if (oleSearchForm.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())) {
805 try {
806 List<Item> itemList = getDocstoreClientLocator().getDocstoreClient().retrieveItems(idsToExport);
807 Items items = new Items();
808 items.getItems().addAll(itemList);
809 requestXml = Items.serialize(items);
810
811 } catch (Exception e) {
812 e.printStackTrace();
813 }
814 }
815 oleSearchForm.setShowRequestXml(true);
816 oleSearchForm.setRequestXMLTextArea(requestXml);
817 return super.navigate(oleSearchForm);
818 }
819
820 @MethodAccessible
821 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addLine")
822 public ModelAndView addLine(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
823 HttpServletRequest request, HttpServletResponse response) {
824 OLESearchForm oleSearchForm = (OLESearchForm) uifForm;
825 oleSearchForm.setCollectionPathIndex(0);
826 String selectedCollectionPath = oleSearchForm.getActionParamaterValue(UifParameters.SELECTED_COLLECTION_PATH);
827 if (StringUtils.isBlank(selectedCollectionPath)) {
828 throw new RuntimeException("Selected collection was not set for add line action, cannot add new line");
829 }
830
831
832 View view = oleSearchForm.getView();
833
834 String selectedCollectionId = oleSearchForm.getActionParamaterValue(UifParameters.SELECTED_COLLECTION_ID);
835 view.getViewHelperService().processCollectionAddLine(oleSearchForm, selectedCollectionId, selectedCollectionPath);
836 SearchCondition searchCondition = oleSearchForm.getSearchParams().getSearchConditions().get(oleSearchForm.getSearchParams().getSearchConditions().size() - 1);
837 if (StringUtils.isEmpty(searchCondition.getSearchField().getFieldValue())) {
838 oleSearchForm.getSearchParams().getSearchConditions().remove(oleSearchForm.getSearchParams().getSearchConditions().size() - 1);
839 GlobalVariables.getMessageMap().putErrorForSectionId("SearchConditionsSection", OLEConstants.DESCRIBE_ENTER_SEARCH_TEXT);
840 return getModelAndView(oleSearchForm);
841 }
842 oleSearchForm.getSearchParams().setStartIndex(0);
843 return getModelAndView(oleSearchForm);
844 }
845
846 @MethodAccessible
847 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteLine")
848 public ModelAndView deleteLine(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
849 HttpServletRequest request, HttpServletResponse response) {
850 OLESearchForm oleSearchForm = (OLESearchForm) uifForm;
851 String selectedCollectionPath = oleSearchForm.getActionParamaterValue(UifParameters.SELECTED_COLLECTION_PATH);
852 if (StringUtils.isBlank(selectedCollectionPath)) {
853 throw new RuntimeException("Selected collection was not set for delete line action, cannot delete line");
854 }
855
856 int selectedLineIndex = -1;
857 String selectedLine = oleSearchForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
858 if (StringUtils.isNotBlank(selectedLine)) {
859 selectedLineIndex = Integer.parseInt(selectedLine);
860 }
861
862 if (selectedLineIndex == -1) {
863 throw new RuntimeException("Selected line index was not set for delete line action, cannot delete line");
864 }
865
866
867 View view = oleSearchForm.getView();
868
869 String selectedCollectionId = oleSearchForm.getActionParamaterValue(UifParameters.SELECTED_COLLECTION_ID);
870 view.getViewHelperService().processCollectionDeleteLine(oleSearchForm, selectedCollectionId, selectedCollectionPath, selectedLineIndex);
871 oleSearchForm.getSearchParams().setStartIndex(0);
872 return getModelAndView(oleSearchForm);
873 }
874
875
876 private boolean performBrowse(String principalId) {
877 PermissionService service = KimApiServiceLocator.getPermissionService();
878 return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.CALL_NUMBER_BROWSE);
879 }
880
881 public Set<String> getFacetFields(String docType) {
882 Set<String> facetFields = new TreeSet<String>();
883 for (DocTypeConfig docTypeConfig : documentSearchConfig.getDocTypeConfigs()) {
884 if (docTypeConfig.getName().equalsIgnoreCase(docType)) {
885 for (DocFormatConfig docFormatConfig : docTypeConfig.getDocFormatConfigList()) {
886 if (docFormatConfig.getName().equalsIgnoreCase(DocFormat.MARC.getCode())) {
887 for (DocFieldConfig docFieldConfig : docFormatConfig.getDocFieldConfigList()) {
888 if (docFieldConfig.isFacet() && docFieldConfig.getDocType().getName().equalsIgnoreCase(docType)) {
889 facetFields.add(docFieldConfig.getName());
890 }
891 }
892 }
893 }
894 }
895 }
896 return facetFields;
897 }
898
899 public SearchResultDisplayFields getDisplayFields(OLESearchForm oleSearchForm) {
900 SearchResultDisplayFields searchResultDisplayFields = new SearchResultDisplayFields();
901 searchResultDisplayFields.buildSearchResultDisplayFields(documentSearchConfig.getDocTypeConfigs(), oleSearchForm.getDocType());
902 return searchResultDisplayFields;
903 }
904
905 public void setPageNextPreviousAndEntriesInfo(OLESearchForm oleSearchForm) {
906 this.totalRecCount = oleSearchForm.getSearchResponse().getTotalRecordCount();
907 this.start = oleSearchForm.getSearchResponse().getStartIndex();
908 this.pageSize = oleSearchForm.getPageSize();
909 oleSearchForm.setPreviousFlag(getPreviousFlag());
910 oleSearchForm.setNextFlag(getNextFlag());
911 oleSearchForm.setPageShowEntries(getPageShowEntries());
912 }
913
914
915 public void setBrowsePageNextPrevoiusAndEntriesInfo(OLESearchForm oleSearchForm) {
916 oleSearchForm.setPreviousFlag(getBrowseService().getPreviosFlag());
917 oleSearchForm.setNextFlag(getBrowseService().getNextFlag());
918 oleSearchForm.setPageShowEntries(getBrowseService().getPageShowEntries());
919 }
920
921 private boolean canExportToRequestXml(String principalId) {
922 PermissionService service = KimApiServiceLocator.getPermissionService();
923 return service.hasPermission(principalId, OLEConstants.CAT_NAMESPACE, OLEConstants.DESC_WORKBENCH_EXPORT_XML);
924 }
925
926 @MethodAccessible
927 @RequestMapping(params = "methodToCall=addLineField")
928 public ModelAndView addLineField(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
929 HttpServletRequest request, HttpServletResponse response) {
930
931 String selectedCollectionPath = uifForm.getActionParamaterValue(UifParameters.SELECTED_COLLECTION_PATH);
932 if (StringUtils.isBlank(selectedCollectionPath)) {
933 throw new RuntimeException("Selected collection was not set for add line action, cannot add new line");
934 }
935 OLESearchForm oleSearchForm = (OLESearchForm) uifForm;
936 oleSearchForm.setCollectionPathIndex(0);
937 Set<String> docTypes = new HashSet<>();
938 docTypes.add(oleSearchForm.getDocType());
939 for (SearchCondition searchCondition : oleSearchForm.getSearchConditions()) {
940 if (searchCondition.getSearchField() != null) {
941 if (searchCondition.getSearchField().getDocType() != null && !searchCondition.getSearchField().getDocType().isEmpty()) {
942 docTypes.add(searchCondition.getSearchField().getDocType());
943 }
944 }
945
946 }
947 if (docTypes != null && docTypes.size() > 2) {
948 String errorMessage = null;
949 if (oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.HOLDING_DOC_TYPE)) {
950 errorMessage = OLEConstants.DOCTYPE_HOLDING_COMBINATION;
951 } else if (oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.ITEM_DOC_TYPE)) {
952 errorMessage =OLEConstants.DOCTYPE_ITEM_COMBINATION;
953 } else if (oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.BIB_DOC_TYPE)) {
954 errorMessage = OLEConstants.DOCTYPE_BIB_COMBINATION;
955 }
956 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.DOCTYPE_COMBINATION_ERROR,errorMessage);
957 return super.navigate(oleSearchForm);
958 }
959 int index = Integer.parseInt(oleSearchForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
960 if (oleSearchForm.getSearchConditions().get(index).getSearchField().getFieldValue().isEmpty()) {
961 return getModelAndView(uifForm);
962 }
963 List<SearchCondition> searchConditions = oleSearchForm.getSearchConditions();
964 index++;
965 SearchCondition searchCondition = new SearchCondition();
966 searchCondition.setOperator("AND");
967 SearchField searchField = new SearchField();
968 searchField.setDocType(oleSearchForm.getDocType());
969 searchField.setFieldName("any");
970 searchCondition.setSearchField(searchField);
971 searchConditions.add(index, searchCondition);
972 return getModelAndView(uifForm);
973 }
974
975 public void searchDocstoreData(OLESearchForm oleSearchForm, HttpServletRequest request) {
976 boolean isRemoveSearchCondition = false;
977 setShowPageSizeEntries(oleSearchForm);
978 SearchParams searchParams = oleSearchForm.getSearchParams();
979 oleSearchForm.getSearchParams().getSearchConditions().clear();
980 searchParams.getSearchConditions().addAll(oleSearchForm.getSearchConditions());
981 searchParams.getSearchResultFields().clear();
982 if ("true".equals(oleSearchForm.getSortFlag())) {
983 searchParams.setPageSize(oleSearchForm.getPageSize());
984
985 searchParams.getSortConditions().clear();
986 if (oleSearchForm.getDocType().equalsIgnoreCase("holdings") && oleSearchForm.getSortField().equalsIgnoreCase("Relations")) {
987 searchParams.getSortConditions().add(searchParams.buildSortCondition("isBoundwith", oleSearchForm.getSortOrder()));
988 searchParams.getSortConditions().add(searchParams.buildSortCondition("isSeries", oleSearchForm.getSortOrder()));
989 searchParams.getSortConditions().add(searchParams.buildSortCondition("isAnalytic", oleSearchForm.getSortOrder()));
990 } else if (oleSearchForm.getDocType().equalsIgnoreCase("item") && oleSearchForm.getSortField().equalsIgnoreCase("Relations")) {
991 searchParams.getSortConditions().add(searchParams.buildSortCondition("isAnalytic", oleSearchForm.getSortOrder()));
992 searchParams.getSortConditions().add(searchParams.buildSortCondition("Title_sort", oleSearchForm.getSortOrder()));
993 } else {
994 searchParams.getSortConditions().add(searchParams.buildSortCondition(oleSearchForm.getSortField(), oleSearchForm.getSortOrder()));
995
996 }
997 } else {
998 searchParams.setPageSize(oleSearchForm.getPageSize());
999
1000 }
1001
1002
1003
1004 if (CollectionUtils.isEmpty(searchParams.getSearchConditions())) {
1005 isRemoveSearchCondition = true;
1006 searchParams.getSearchConditions().add(searchParams.buildSearchCondition("", searchParams.buildSearchField(oleSearchForm.getDocType(), "", ""), ""));
1007 }
1008 request.getSession().setAttribute("searchParams", searchParams);
1009 if (!oleSearchForm.isMoreFacets()) {
1010 searchParams.getFacetFields().clear();
1011 Set<String> facetFields = getFacetFields(oleSearchForm.getDocType());
1012 searchParams.getFacetFields().addAll(facetFields);
1013 searchParams.setFacetLimit(documentSearchConfig.getFacetPageSizeShort());
1014 }
1015 oleSearchForm.setFacetLimit(documentSearchConfig.getFacetPageSizeShort() - 1);
1016 SearchResponse searchResponse = null;
1017 oleSearchForm.setSearchResultDisplayFields(getDisplayFields(oleSearchForm));
1018 searchParams.buildSearchParams(searchParams, oleSearchForm.getDocType());
1019 if (oleSearchForm instanceof GlobalEditForm) {
1020 if (((GlobalEditForm) oleSearchForm).isSelectAll()) {
1021 searchParams.setStartIndex(0);
1022 }
1023 }
1024 float start = System.currentTimeMillis() / 1000;
1025 try {
1026 if (oleSearchForm.getDocType().equalsIgnoreCase(DocType.BIB.getCode()) && searchParams.getSortConditions() != null && searchParams.getSortConditions().size() == 0) {
1027 SortCondition sortCondition = new SortCondition();
1028 sortCondition.setSortField("Title_sort");
1029 sortCondition.setSortOrder("asc");
1030 searchParams.getSortConditions().add(sortCondition);
1031 }
1032
1033 searchParams.setDocType(oleSearchForm.getDocType());
1034 searchResponse = getDocstoreClientLocator().getDocstoreClient().search(searchParams);
1035 oleSearchForm.setSearchResponse(searchResponse);
1036 } catch (Exception e) {
1037 LOG.error("Exception : ", e);
1038 }
1039 float end = System.currentTimeMillis() / 1000;
1040 oleSearchForm.setSolrTime(String.valueOf(end - start));
1041 List<SearchResultDisplayRow> searchResultDisplayRows = new ArrayList<>();
1042 List<SearchResultDisplayRow> bibSearchResultDisplayRows = new ArrayList<>();
1043 List<SearchResultDisplayRow> holdingsSearchResultDisplayRows = new ArrayList<>();
1044 for (SearchResult searchResult : searchResponse.getSearchResults()) {
1045 SearchResultDisplayRow searchResultDisplayRow = new SearchResultDisplayRow();
1046 if (DocType.BIB.getCode().equalsIgnoreCase(oleSearchForm.getDocType())) {
1047 searchResultDisplayRow.buildBibSearchResultField(searchResult.getSearchResultFields(), eResourceId);
1048 bibSearchResultDisplayRows.add(searchResultDisplayRow);
1049 } else if (DocType.HOLDINGS.getCode().equals(oleSearchForm.getDocType())) {
1050 searchResultDisplayRow.buildHoldingSearchResultField(searchResult.getSearchResultFields());
1051 holdingsSearchResultDisplayRows.add(searchResultDisplayRow);
1052 } else if (DocType.EHOLDINGS.getCode().equals(oleSearchForm.getDocType())) {
1053 searchResultDisplayRow.buildEHoldingSearchResultField(searchResult.getSearchResultFields());
1054 holdingsSearchResultDisplayRows.add(searchResultDisplayRow);
1055 } else if (DocType.ITEM.getCode().equals(oleSearchForm.getDocType())) {
1056 searchResultDisplayRow.buildItemSearchResultField(searchResult.getSearchResultFields());
1057 }
1058 searchResultDisplayRows.add(searchResultDisplayRow);
1059 }
1060 oleSearchForm.setSearchResultDisplayRowList(searchResultDisplayRows);
1061 oleSearchForm.setBibSearchResultDisplayRowList(bibSearchResultDisplayRows);
1062 oleSearchForm.setHoldingSearchResultDisplayRowList(holdingsSearchResultDisplayRows);
1063 if (searchResponse != null && searchResponse.getFacetResult() != null) {
1064 oleSearchForm.setFacetResultFields(searchResponse.getFacetResult().getFacetResultFields());
1065 }
1066 if (searchResultDisplayRows.size() == 0) {
1067 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.DESCRIBE_SEARCH_MESSAGE);
1068 }
1069 request.getSession().setAttribute("searchResultDisplayRowList", searchResultDisplayRows);
1070 setPageNextPreviousAndEntriesInfo(oleSearchForm);
1071 if (isRemoveSearchCondition) {
1072 oleSearchForm.getSearchParams().getSearchConditions().clear();
1073 }
1074
1075 if (oleSearchForm.isMoreFacets()) {
1076 showFacetPreviousNext(oleSearchForm);
1077 }
1078 if (oleSearchForm instanceof GlobalEditForm) {
1079 ((GlobalEditForm) oleSearchForm).setTotalRecords(totalRecCount);
1080 }
1081 }
1082
1083 private void showFacetPreviousNext(OLESearchForm oleSearchForm) {
1084 int offset = oleSearchForm.getSearchParams().getFacetOffset();
1085 int size = oleSearchForm.getSearchParams().getFacetLimit();
1086 int totalRecordCount = 0;
1087 if (oleSearchForm.getSearchResponse() != null && oleSearchForm.getSearchResponse().getFacetResult() != null && oleSearchForm.getSearchResponse().getFacetResult().getFacetResultFields() != null && oleSearchForm.getSearchResponse().getFacetResult().getFacetResultFields().get(0) != null) {
1088 totalRecordCount = oleSearchForm.getSearchResponse().getFacetResult().getFacetResultFields().get(0).getValueCounts().size();
1089 }
1090 if (offset - size >= 0) {
1091 oleSearchForm.setShowMoreFacetPrevious(true);
1092 } else {
1093 oleSearchForm.setShowMoreFacetPrevious(false);
1094 }
1095
1096 if (totalRecordCount >= size) {
1097 oleSearchForm.setShowMoreFacetNext(true);
1098 } else {
1099 oleSearchForm.setShowMoreFacetNext(false);
1100 }
1101 }
1102
1103 @MethodAccessible
1104 @RequestMapping(params = "methodToCall=deleteLineField")
1105 public ModelAndView deleteLineField(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1106 HttpServletRequest request, HttpServletResponse response) {
1107
1108 String selectedCollectionPath = uifForm.getActionParamaterValue(UifParameters.SELECTED_COLLECTION_PATH);
1109 if (StringUtils.isBlank(selectedCollectionPath)) {
1110 throw new RuntimeException("Selected collection was not set for add line action, cannot add new line");
1111 }
1112 OLESearchForm oleSearchForm = (OLESearchForm) uifForm;
1113 oleSearchForm.setCollectionPathIndex(0);
1114 int index = Integer.parseInt(oleSearchForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
1115 List<SearchCondition> searchConditions = oleSearchForm.getSearchConditions();
1116 if (searchConditions.size() > 1) {
1117 searchConditions.remove(index);
1118 }
1119 return getModelAndView(uifForm);
1120 }
1121
1122 @MethodAccessible
1123 @RequestMapping(params = "methodToCall=showBibList")
1124 public ModelAndView showBibList(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1125 HttpServletRequest request, HttpServletResponse response) {
1126 this.start = 0;
1127 LOG.debug("Inside the showBibList method");
1128 OLESearchForm oleSearchForm = (OLESearchForm) uifForm;
1129 oleSearchForm.setSearchTypeField("OLESearch");
1130 String listOfBib = request.getParameter("listOfBib");
1131 String bibList[] = listOfBib.split(",");
1132 SearchParams searchParams = new SearchParams();
1133 for (int bibCount = 0; bibCount < bibList.length; bibCount++) {
1134 String uuid = listOfBib.split(",")[bibCount].replaceAll("\\D+", "");
1135 SearchCondition searchCondition = searchParams.buildSearchCondition("", searchParams.buildSearchField("bibliographic", "LocalId_search", uuid), "OR");
1136 searchParams.getSearchConditions().add(searchCondition);
1137 oleSearchForm.getSearchConditions().add(searchCondition);
1138 }
1139 oleSearchForm.setSearchParams(searchParams);
1140 request.getSession().setAttribute("selectedFacetResults", null);
1141 if (oleSearchForm.getDocType() == null) {
1142 oleSearchForm.setDocType(DocType.BIB.getCode());
1143 }
1144 if (StringUtils.isEmpty(oleSearchForm.getSearchType())) {
1145 oleSearchForm.setSearchType("search");
1146 }
1147 if (StringUtils.isEmpty(oleSearchForm.getBrowseField())) {
1148 oleSearchForm.setBrowseField("title");
1149 }
1150 oleSearchForm.setBrowseText(null);
1151 oleSearchForm.setShowRequestXml(false);
1152 oleSearchForm.setHoldingsList(null);
1153 oleSearchForm.setItemList(null);
1154 oleSearchForm.setSearchResultDisplayRowList(null);
1155 oleSearchForm.setCallNumberBrowseText(null);
1156 oleSearchForm.setLocation(null);
1157 oleSearchForm.setPageSize(10);
1158 GlobalVariables.getMessageMap().clearErrorMessages();
1159 boolean hasSearchPermission = canSearch(GlobalVariables.getUserSession().getPrincipalId());
1160 if (!hasSearchPermission && oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.BIB_DOC_TYPE)) {
1161 boolean hasLinkPermission = canLinkBibForRequisition(GlobalVariables.getUserSession().getPrincipalId());
1162 if (!hasLinkPermission) {
1163 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_AUTHORIZATION);
1164 return search(oleSearchForm,result,request,response);
1165 }
1166 } else if (!hasSearchPermission) {
1167 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ERROR_AUTHORIZATION);
1168 return search(oleSearchForm,result,request,response);
1169 }
1170 return search(oleSearchForm,result,request,response);
1171 }
1172
1173 private void clearForm(OLESearchForm oleSearchForm) {
1174
1175 List<Integer> pageSizes = documentSearchConfig.getPageSizes();
1176 if (!pageSizes.isEmpty() || pageSizes.size() > 0) {
1177 oleSearchForm.setPageSize(pageSizes.get(0));
1178 }
1179 oleSearchForm.setPreviousFlag(false);
1180 oleSearchForm.setNextFlag(false);
1181 oleSearchForm.setBrowseText(null);
1182 oleSearchForm.setShowRequestXml(false);
1183 oleSearchForm.setHoldingsList(null);
1184 oleSearchForm.setItemList(null);
1185 oleSearchForm.setSearchResultDisplayRowList(null);
1186 oleSearchForm.setCallNumberBrowseText(null);
1187 oleSearchForm.setLocation(null);
1188 oleSearchForm.setClassificationScheme("LCC");
1189 oleSearchForm.setCollectionPathIndex(0);
1190
1191
1192 if (oleSearchForm.getSearchParams() != null) {
1193 for (SearchCondition searchCondition : oleSearchForm.getSearchConditions()) {
1194 if (searchCondition.getSearchField() != null) {
1195
1196 searchCondition.getSearchField().setFieldValue("");
1197 }
1198 }
1199
1200 if (oleSearchForm.getSearchParams().getFacetFields() != null) {
1201 oleSearchForm.getSearchParams().getFacetFields().clear();
1202 }
1203 if (oleSearchForm.getSearchParams().getFacetConditions() != null) {
1204 oleSearchForm.getSearchParams().getFacetConditions().clear();
1205 }
1206 oleSearchForm.getSearchParams().getSearchResultFields().clear();
1207
1208 }
1209 if (oleSearchForm.getSearchResultDisplayRowList() != null && oleSearchForm.getSearchResultDisplayRowList().size() > 0) {
1210 oleSearchForm.getSearchResultDisplayRowList().clear();
1211 }
1212
1213 if (oleSearchForm.getFacetResultFields() != null) {
1214 oleSearchForm.getFacetResultFields().clear();
1215 }
1216
1217 }
1218
1219 @MethodAccessible
1220 @RequestMapping(params = "methodToCall=getHoldingsList")
1221 public ModelAndView getHoldingsList(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1222 HttpServletRequest request, HttpServletResponse response) throws Exception {
1223 OLESearchForm oleSearchForm = (OLESearchForm) form;
1224 oleSearchForm.setErrorMessage(null);
1225 oleSearchForm.setHoldingSearchResultDisplayRowList(null);
1226 oleSearchForm.seteHoldingsFlag("false");
1227 List<SearchResultDisplayRow> searchResultDisplayRowList = new ArrayList<>();
1228
1229 if (oleSearchForm.getSearchResultDisplayRowList() != null && oleSearchForm.getSearchResultDisplayRowList().size() > 0) {
1230 for (SearchResultDisplayRow searchResultDisplay : oleSearchForm.getSearchResultDisplayRowList()) {
1231 if (searchResultDisplay.isSelect()) {
1232 BibTree bibTree = getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(searchResultDisplay.getLocalId());
1233 List<HoldingsTree> holdingsTreeList = bibTree.getHoldingsTrees();
1234 if (holdingsTreeList.size() > 0) {
1235 oleSearchForm.setHoldingsFlag("true");
1236 for (HoldingsTree holdingsTree : holdingsTreeList) {
1237 if (holdingsTree.getHoldings().getHoldingsType().equalsIgnoreCase("print")) {
1238 SearchResultDisplayRow searchResultDisplayRow = new SearchResultDisplayRow();
1239 searchResultDisplayRow.setHoldingsIdentifier(holdingsTree.getHoldings().getId());
1240 searchResultDisplayRow.setTitle(holdingsTree.getHoldings().getBib().getTitle());
1241 searchResultDisplayRow.setBibIdentifier(holdingsTree.getHoldings().getBib().getId());
1242 searchResultDisplayRow.setCallNumber(holdingsTree.getHoldings().getCallNumber());
1243 searchResultDisplayRow.setLocalId(DocumentUniqueIDPrefix.getDocumentId(holdingsTree.getHoldings().getId()));
1244 searchResultDisplayRow.setLocationName(holdingsTree.getHoldings().getLocationName());
1245 searchResultDisplayRow.setInstanceIdentifier(holdingsTree.getHoldings().getId());
1246 searchResultDisplayRowList.add(searchResultDisplayRow);
1247 }
1248 }
1249 }
1250 }
1251 }
1252 }
1253 if (searchResultDisplayRowList.size() == 0) {
1254 oleSearchForm.setErrorMessage("selected bib doesnt have Holdings");
1255 }
1256 oleSearchForm.setHoldingSearchResultDisplayRowList(searchResultDisplayRowList);
1257 oleSearchForm.setWorkEHoldingsDocumentList(null);
1258 return super.navigate(oleSearchForm);
1259 }
1260
1261 @MethodAccessible
1262 @RequestMapping(params = "methodToCall=getEHoldingsList")
1263 public ModelAndView getEHoldingsList(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1264 HttpServletRequest request, HttpServletResponse response) throws Exception {
1265 OLESearchForm oleSearchForm = (OLESearchForm) form;
1266 oleSearchForm.setErrorMessage(null);
1267 oleSearchForm.setHoldingsFlag("false");
1268 oleSearchForm.setHoldingSearchResultDisplayRowList(null);
1269 List<SearchResultDisplayRow> searchResultDisplayRowArrayList = new ArrayList<>();
1270 if (oleSearchForm.getSearchResultDisplayRowList() != null && oleSearchForm.getSearchResultDisplayRowList().size() > 0) {
1271 for (SearchResultDisplayRow searchResultDisplay : oleSearchForm.getSearchResultDisplayRowList()) {
1272 if (searchResultDisplay.isSelect()) {
1273 BibTree bibTree = getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(searchResultDisplay.getLocalId());
1274 if (bibTree.getHoldingsTrees().size() > 0) {
1275 oleSearchForm.seteHoldingsFlag("true");
1276 for (HoldingsTree holdingsTree : bibTree.getHoldingsTrees()) {
1277 if (holdingsTree.getHoldings().getHoldingsType().equalsIgnoreCase("electronic")) {
1278 OleHoldings oleHoldings = new OleHoldings();
1279 SearchResultDisplayRow searchResultDisplayRow = new SearchResultDisplayRow();
1280 HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor();
1281 oleHoldings = (OleHoldings) holdingOlemlRecordProcessor.fromXML(holdingsTree.getHoldings().getContent());
1282 searchResultDisplayRow.setAccessStatus(oleHoldings.getAccessStatus());
1283 searchResultDisplayRow.setPlatForm(oleHoldings.getPlatform() != null ? oleHoldings.getPlatform().getPlatformName() : null);
1284 searchResultDisplayRow.setImprint(oleHoldings.getImprint());
1285 searchResultDisplayRow.setTitle(holdingsTree.getHoldings().getBib().getTitle());
1286 searchResultDisplayRow.setStatisticalCode(oleHoldings.getStatisticalSearchingCode() != null ? oleHoldings.getStatisticalSearchingCode().getCodeValue() : null);
1287 searchResultDisplayRow.setLocationName(holdingsTree.getHoldings().getLocationName());
1288 searchResultDisplayRow.setBibIdentifier(holdingsTree.getHoldings().getBib().getId());
1289 searchResultDisplayRow.setInstanceIdentifier(holdingsTree.getHoldings().getId());
1290 searchResultDisplayRow.setHoldingsIdentifier(holdingsTree.getHoldings().getId());
1291 searchResultDisplayRow.setLocalId(DocumentUniqueIDPrefix.getDocumentId(holdingsTree.getHoldings().getId()));
1292 searchResultDisplayRowArrayList.add(searchResultDisplayRow);
1293 }
1294 }
1295 }
1296 }
1297 }
1298 }
1299 if (searchResultDisplayRowArrayList.size() == 0) {
1300 oleSearchForm.setErrorMessage("selected bib doesnt have EHoldings");
1301 }
1302 oleSearchForm.setHoldingSearchResultDisplayRowList(searchResultDisplayRowArrayList);
1303 oleSearchForm.setWorkHoldingsDocumentList(null);
1304 return navigate(oleSearchForm);
1305 }
1306
1307 @MethodAccessible
1308 @RequestMapping(params = "methodToCall=linkToBib")
1309 public ModelAndView linkToBib(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1310 HttpServletRequest request, HttpServletResponse response) throws Exception {
1311 OLESearchForm oleSearchForm = (OLESearchForm) form;
1312 List<SearchResultDisplayRow> searchResultDisplayRowList = oleSearchForm.getHoldingSearchResultDisplayRowList();
1313 oleSearchForm.setSuccessMessage(null);
1314 if (searchResultDisplayRowList != null && searchResultDisplayRowList.size() > 0) {
1315 for (SearchResultDisplayRow searchResultDisplayRow : searchResultDisplayRowList) {
1316 if (searchResultDisplayRow.isSelect()) {
1317 processNewHoldingsResponse(searchResultDisplayRow, oleSearchForm.getTokenId());
1318 Holdings holdings = getDocstoreClientLocator().getDocstoreClient().retrieveHoldings(searchResultDisplayRow.getHoldingsIdentifier());
1319 if (holdings.getHoldingsType().equalsIgnoreCase("electronic")) {
1320 saveRecordToDocstore(searchResultDisplayRow, eResourceId);
1321 }
1322 oleSearchForm.setSuccessMessage("");
1323 break;
1324 } else {
1325 oleSearchForm.setSuccessMessage(OLEConstants.HOLDINGS_ERROR_MESSAGE);
1326 }
1327 }
1328 }
1329 if (eResourceId != null && !eResourceId.isEmpty()) {
1330 Map<String, String> tempId = new HashMap<String, String>();
1331 tempId.put(OLEConstants.OLEEResourceRecord.ERESOURCE_IDENTIFIER, eResourceId);
1332 OLEEResourceRecordDocument tempDocument = (OLEEResourceRecordDocument) KRADServiceLocatorWeb.getLegacyDataAdapter().findByPrimaryKey(OLEEResourceRecordDocument.class, tempId);
1333 try {
1334 Person principalPerson = SpringContext.getBean(PersonService.class).getPerson(GlobalVariables.getUserSession().getPerson().getPrincipalId());
1335 tempDocument.getDocumentHeader().setWorkflowDocument(KRADServiceLocatorWeb.getWorkflowDocumentService().loadWorkflowDocument(tempDocument.getDocumentNumber(), principalPerson));
1336 if (tempDocument != null) {
1337 try {
1338 tempDocument.setSelectInstance(OLEConstants.OLEEResourceRecord.LINK_EXIST_INSTANCE);
1339 tempDocument.seteInstanceFlag(true);
1340 getOleEResourceSearchService().getNewInstance(tempDocument, tempDocument.getDocumentNumber());
1341 getDocumentService().updateDocument(tempDocument);
1342 } catch (Exception e) {
1343 throw new RiceRuntimeException(
1344 "Exception trying to save document: " + tempDocument
1345 .getDocumentNumber(), e);
1346 }
1347 }
1348 } catch (Exception e) {
1349 throw new RiceRuntimeException(
1350 "Exception trying to save document: " + tempDocument
1351 .getDocumentNumber(), e);
1352 }
1353 }
1354 return getModelAndView(oleSearchForm);
1355 }
1356
1357 private void processNewHoldingsResponse(SearchResultDisplayRow searchResultDisplayRow, String tokenId) throws Exception {
1358 OLEEditorResponse oleEditorResponse = new OLEEditorResponse();
1359 oleEditorResponse.setLinkedInstanceId(searchResultDisplayRow.getHoldingsIdentifier());
1360 oleEditorResponse.setTokenId(tokenId);
1361 HashMap<String, OLEEditorResponse> oleEditorResponseMap = new HashMap<String, OLEEditorResponse>();
1362 oleEditorResponseMap.put(tokenId, oleEditorResponse);
1363 OleDocstoreResponse.getInstance().setEditorResponse(oleEditorResponseMap);
1364 }
1365
1366 private void saveRecordToDocstore(SearchResultDisplayRow searchResultDisplayRow, String eResourceId) throws Exception {
1367 Holdings eHoldings = new org.kuali.ole.docstore.common.document.EHoldings();
1368 OleHoldings oleHoldings = new OleHoldings();
1369 eHoldings = getDocstoreClientLocator().getDocstoreClient().retrieveHoldings(searchResultDisplayRow.getHoldingsIdentifier());
1370 oleHoldings = new HoldingOlemlRecordProcessor().fromXML(eHoldings.getContent());
1371 oleHoldings.setEResourceId(eResourceId);
1372 eHoldings.setContent(new HoldingOlemlRecordProcessor().toXML(oleHoldings));
1373 getDocstoreClientLocator().getDocstoreClient().updateHoldings(eHoldings);
1374 }
1375
1376 @MethodAccessible
1377 @RequestMapping(params = "methodToCall=changeDocType")
1378 public ModelAndView changeDocType(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1379 HttpServletRequest request, HttpServletResponse response) {
1380 OLESearchForm oleSearchForm = (OLESearchForm) form;
1381 oleSearchForm.setCollectionPathIndex(0);
1382 Set<String> docTypes = new HashSet<>();
1383 docTypes.add(oleSearchForm.getDocType());
1384 for (SearchCondition searchCondition : oleSearchForm.getSearchConditions()) {
1385 if (searchCondition.getSearchField() != null) {
1386 if (searchCondition.getSearchField().getDocType() != null && !searchCondition.getSearchField().getDocType().isEmpty()) {
1387 docTypes.add(searchCondition.getSearchField().getDocType());
1388 }
1389 }
1390
1391 }
1392
1393 if (docTypes != null && docTypes.size() > 2) {
1394 String errorMessage = null;
1395 if (oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.HOLDING_DOC_TYPE)) {
1396 errorMessage = OLEConstants.DOCTYPE_HOLDING_COMBINATION;
1397 } else if (oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.ITEM_DOC_TYPE)) {
1398 errorMessage =OLEConstants.DOCTYPE_ITEM_COMBINATION;
1399 } else if (oleSearchForm.getDocType().equalsIgnoreCase(OLEConstants.BIB_DOC_TYPE)) {
1400 errorMessage = OLEConstants.DOCTYPE_BIB_COMBINATION;
1401 }
1402 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.DOCTYPE_COMBINATION_ERROR,errorMessage);
1403
1404 return super.navigate(oleSearchForm);
1405 }
1406 return super.navigate(oleSearchForm);
1407 }
1408 }