View Javadoc
1   package org.kuali.ole.deliver.controller;
2   
3   import org.apache.commons.collections.CollectionUtils;
4   import org.apache.commons.lang3.StringUtils;
5   import org.kuali.ole.OLEConstants;
6   import org.kuali.ole.OLEPropertyConstants;
7   import org.kuali.ole.deliver.bo.*;
8   import org.kuali.ole.deliver.form.OLEDeliverItemSearchForm;
9   import org.kuali.ole.deliver.service.OLEDeliverItemSearchService;
10  import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
11  import org.kuali.ole.docstore.common.document.*;
12  import org.kuali.ole.docstore.common.document.content.enums.DocType;
13  import org.kuali.ole.docstore.common.search.SearchParams;
14  import org.kuali.ole.docstore.common.search.SearchResponse;
15  import org.kuali.ole.docstore.common.search.SearchResult;
16  import org.kuali.ole.docstore.common.search.SearchResultField;
17  import org.kuali.ole.docstore.engine.service.index.solr.BibConstants;
18  import org.kuali.ole.docstore.engine.service.index.solr.ItemConstants;
19  import org.kuali.ole.sys.context.SpringContext;
20  import org.kuali.rice.core.api.config.property.ConfigContext;
21  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
22  import org.kuali.rice.krad.util.GlobalVariables;
23  import org.kuali.rice.krad.util.KRADConstants;
24  import org.kuali.rice.krad.web.controller.UifControllerBase;
25  import org.kuali.rice.krad.web.form.UifFormBase;
26  import org.springframework.stereotype.Controller;
27  import org.springframework.validation.BindingResult;
28  import org.springframework.web.bind.annotation.ModelAttribute;
29  import org.springframework.web.bind.annotation.RequestMapping;
30  import org.springframework.web.servlet.ModelAndView;
31  
32  import javax.servlet.http.HttpServletRequest;
33  import javax.servlet.http.HttpServletResponse;
34  import java.util.*;
35  
36  /**
37   * Created by chenchulakshmig on 1/12/15.
38   */
39  @Controller
40  @RequestMapping(value = "/deliverItemSearchController")
41  public class OLEDeliverItemSearchController extends UifControllerBase {
42  
43      String baseUrl = ConfigContext.getCurrentContextConfig().getProperty(OLEPropertyConstants.OLE_URL_BASE);
44  
45      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OLEDeliverItemSearchController.class);
46      private DocstoreClientLocator docstoreClientLocator;
47      private OLEDeliverItemSearchService oleDeliverItemSearchService;
48  
49      public DocstoreClientLocator getDocstoreClientLocator() {
50          if (docstoreClientLocator == null) {
51              docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
52          }
53          return docstoreClientLocator;
54      }
55  
56      public OLEDeliverItemSearchService getOleDeliverItemSearchService() {
57          if (oleDeliverItemSearchService == null) {
58              oleDeliverItemSearchService = GlobalResourceLoader.getService(OLEConstants.DELIVER_ITEM__SEARCH_SERVICE);
59          }
60          return oleDeliverItemSearchService;
61      }
62  
63      @Override
64      protected UifFormBase createInitialForm(HttpServletRequest request) {
65          return new OLEDeliverItemSearchForm();
66      }
67  
68      @RequestMapping(params = "methodToCall=search")
69      public ModelAndView search(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
70                                 HttpServletRequest request, HttpServletResponse response) {
71          OLEDeliverItemSearchForm oleDeliverItemSearchForm = (OLEDeliverItemSearchForm) form;
72          oleDeliverItemSearchForm.setSingleItemFlag(false);
73          oleDeliverItemSearchForm.setOleBibSearchResultDisplayRowList(new ArrayList<OLEBibSearchResultDisplayRow>());
74          oleDeliverItemSearchForm.setOleSingleItemResultDisplayRow(new OLESingleItemResultDisplayRow());
75          try {
76              String title = oleDeliverItemSearchForm.getTitle();
77              String author = oleDeliverItemSearchForm.getAuthor();
78              String publisher = oleDeliverItemSearchForm.getPublisher();
79              String itemBarcode = oleDeliverItemSearchForm.getItemBarCode();
80              String callNumber = oleDeliverItemSearchForm.getItemCallNumber();
81              String itemUUID = oleDeliverItemSearchForm.getItemUUID();
82              String itemType = oleDeliverItemSearchForm.getItemType();
83              String itemLocation = oleDeliverItemSearchForm.getItemLocation();
84              SearchParams searchParams = new SearchParams();
85              if (StringUtils.isNotBlank(title) || StringUtils.isNotBlank(author) || StringUtils.isNotBlank(publisher) || StringUtils.isNotBlank(itemBarcode)
86                      || StringUtils.isNotBlank(callNumber) || StringUtils.isNotBlank(itemUUID) || StringUtils.isNotBlank(itemType) || StringUtils.isNotBlank(itemLocation)) {
87                  if (StringUtils.isNotBlank(title)) {
88                      searchParams.getSearchConditions().add(searchParams.buildSearchCondition(OLEConstants.AND_SEARCH_SCOPE, searchParams.buildSearchField(DocType.ITEM.getCode(), Bib.TITLE, title), OLEConstants.AND_SEARCH_SCOPE));
89                  }
90                  if (StringUtils.isNotBlank(author)) {
91                      searchParams.getSearchConditions().add(searchParams.buildSearchCondition(OLEConstants.AND_SEARCH_SCOPE, searchParams.buildSearchField(DocType.ITEM.getCode(), Bib.AUTHOR, author), OLEConstants.AND_SEARCH_SCOPE));
92                  }
93                  if (StringUtils.isNotBlank(publisher)) {
94                      searchParams.getSearchConditions().add(searchParams.buildSearchCondition(OLEConstants.AND_SEARCH_SCOPE, searchParams.buildSearchField(DocType.ITEM.getCode(), Bib.PUBLISHER, publisher), OLEConstants.AND_SEARCH_SCOPE));
95                  }
96                  if (StringUtils.isNotBlank(itemBarcode)) {
97                      searchParams.getSearchConditions().add(searchParams.buildSearchCondition(OLEConstants.AND_SEARCH_SCOPE, searchParams.buildSearchField(DocType.ITEM.getCode(), Item.ITEM_BARCODE, itemBarcode), OLEConstants.AND_SEARCH_SCOPE));
98                  }
99                  if (StringUtils.isNotBlank(callNumber)) {
100                     searchParams.getSearchConditions().add(searchParams.buildSearchCondition(OLEConstants.AND_SEARCH_SCOPE, searchParams.buildSearchField(DocType.ITEM.getCode(), Item.CALL_NUMBER, callNumber), OLEConstants.AND_SEARCH_SCOPE));
101                 }
102                 if (StringUtils.isNotBlank(itemUUID)) {
103                     searchParams.getSearchConditions().add(searchParams.buildSearchCondition(OLEConstants.AND_SEARCH_SCOPE, searchParams.buildSearchField(DocType.ITEM.getCode(), Item.ITEMIDENTIFIER, itemUUID), OLEConstants.AND_SEARCH_SCOPE));
104                 }
105                 if (StringUtils.isNotBlank(itemType)) {
106                     searchParams.getSearchConditions().add(searchParams.buildSearchCondition(OLEConstants.AND_SEARCH_SCOPE, searchParams.buildSearchField(DocType.ITEM.getCode(), Item.ITEM_TYPE, itemType), OLEConstants.AND_SEARCH_SCOPE));
107                 }
108                 if (StringUtils.isNotBlank(itemLocation)) {
109                     searchParams.getSearchConditions().add(searchParams.buildSearchCondition(OLEConstants.PHRASE, searchParams.buildSearchField(DocType.ITEM.getCode(), ItemConstants.LOCATION_LEVEL_SEARCH, itemLocation), OLEConstants.AND_SEARCH_SCOPE));
110                 }
111                 searchParams.setPageSize(100000);
112                 getSearchResultFields(searchParams);
113                 SearchResponse searchResponse = getDocstoreClientLocator().getDocstoreClient().search(searchParams);
114                 getSearchResults(searchResponse, oleDeliverItemSearchForm);
115             } else {
116                 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ITM_BLANK_SEARCH_ERROR_MSG);
117                 return getUIFModelAndView(oleDeliverItemSearchForm);
118             }
119         } catch (Exception e) {
120             LOG.error("Exception " + e);
121         }
122         return getUIFModelAndView(oleDeliverItemSearchForm);
123     }
124 
125     private void getSearchResultFields(SearchParams searchParams) {
126         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.BIB_IDENTIFIER));
127         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), Bib.TITLE));
128         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), Bib.AUTHOR));
129         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), Bib.PUBLISHER));
130         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.HOLDINGS_LOCATION_DISPLAY));
131         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.LOCATION_LEVEL_DISPLAY));
132         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), Item.CALL_NUMBER));
133         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), Item.ITEM_STATUS));
134         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), OLEConstants.ITEM_TYPE_FULL_VALUE));
135         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.HOLDINGS_IDENTIFIER));
136         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.HOLDINGS_CALLNUMBER_DISPLAY));
137         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), Item.ID));
138         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), Item.ITEM_BARCODE));
139         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.ENUMERATION_DISPLAY));
140         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.CHRONOLOGY_DISPLAY));
141         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.ITEM_STATUS_EFFECTIVE_DATE));
142         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.DUE_DATE_TIME));
143         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.NUMBER_OF_PIECES_DISPLAY));
144         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.PUBLICATIONDATE_DISPLAY));
145         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.CURRENT_BORROWER));
146         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.PROXY_BORROWER));
147         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.BIB.getCode(), "mdf_035a"));
148         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.ISBN_DISPLAY));
149         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.ITEMNOTE_VALUE_DISPLAY));
150         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.ITEMNOTE_TYPE_DISPLAY));
151         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.MISSING_PIECE_FLAG_DISPLAY));
152         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.MISSING_PIECE_COUNT_DISPLAY));
153         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.MISSING_PIECE_FLAG_NOTE_DISPLAY));
154         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.CLMS_RET_FLAG));
155         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.CLMS_RET_NOTE));
156         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.CLMS_RET_FLAG_CRE_DATE));
157         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.ITEM_DAMAGED_FLAG_DISPLAY));
158         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), ItemConstants.DAMAGED_ITEM_NOTE_DISPLAY));
159         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.CREATED_BY));
160         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.DATE_ENTERED));
161         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.UPDATED_BY));
162         searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), BibConstants.DATE_UPDATED));
163     }
164 
165     private void getSearchResults(SearchResponse searchResponse, OLEDeliverItemSearchForm oleDeliverItemSearchForm) {
166         Map<String, OLEBibSearchResultDisplayRow> bibSearchResultDisplayRowMap = new HashMap<>();
167         Map<String, OLEHoldingsSearchResultDisplayRow> holdingsSearchResultDisplayRowMap = new HashMap<>();
168         List<OLEBibSearchResultDisplayRow> bibSearchResultDisplayRowList = new ArrayList<>();
169         OLESingleItemResultDisplayRow singleItemResultDisplayRow = new OLESingleItemResultDisplayRow();
170         if (searchResponse != null && CollectionUtils.isNotEmpty(searchResponse.getSearchResults())) {
171             for (SearchResult searchResult : searchResponse.getSearchResults()) {
172                 if (CollectionUtils.isNotEmpty(searchResult.getSearchResultFields())) {
173                     OLEBibSearchResultDisplayRow bibSearchResultDisplayRow = new OLEBibSearchResultDisplayRow();
174                     OLEHoldingsSearchResultDisplayRow holdingsSearchResultDisplayRow = new OLEHoldingsSearchResultDisplayRow();
175                     singleItemResultDisplayRow = new OLESingleItemResultDisplayRow();
176                     OLEItemSearchResultDisplayRow itemSearchResultDisplayRow = new OLEItemSearchResultDisplayRow();
177                     for (SearchResultField searchResultField : searchResult.getSearchResultFields()) {
178                         if (searchResultField.getFieldName().equalsIgnoreCase(Bib.BIBIDENTIFIER)) {
179                             bibSearchResultDisplayRow.setId(searchResultField.getFieldValue());
180                             holdingsSearchResultDisplayRow.setBibIdentifier(searchResultField.getFieldValue());
181                             singleItemResultDisplayRow.setBibIdentifier(searchResultField.getFieldValue());
182                             itemSearchResultDisplayRow.setBibIdentifier(searchResultField.getFieldValue());
183                         } else if (searchResultField.getFieldName().equalsIgnoreCase(Bib.TITLE)) {
184                             singleItemResultDisplayRow.setTitle(searchResultField.getFieldValue());
185                             bibSearchResultDisplayRow.setTitle(searchResultField.getFieldValue());
186                         } else if (searchResultField.getFieldName().equalsIgnoreCase(Bib.AUTHOR)) {
187                             singleItemResultDisplayRow.setAuthor(searchResultField.getFieldValue());
188                             bibSearchResultDisplayRow.setAuthor(searchResultField.getFieldValue());
189                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.HOLDINGS_LOCATION_DISPLAY)) {
190                             holdingsSearchResultDisplayRow.setLocation(searchResultField.getFieldValue());
191                             singleItemResultDisplayRow.setHoldingsLocation(searchResultField.getFieldValue());
192                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.LOCATION_LEVEL_DISPLAY)) {
193                             singleItemResultDisplayRow.setLocation(searchResultField.getFieldValue());
194                             itemSearchResultDisplayRow.setLocation(searchResultField.getFieldValue());
195                         } else if (searchResultField.getFieldName().equalsIgnoreCase(Item.CALL_NUMBER)) {
196                             singleItemResultDisplayRow.setCallNumber(searchResultField.getFieldValue());
197                             itemSearchResultDisplayRow.setCallNumber(searchResultField.getFieldValue());
198                         } else if (searchResultField.getFieldName().equalsIgnoreCase(Item.ITEM_STATUS)) {
199                             singleItemResultDisplayRow.setItemStatus(searchResultField.getFieldValue());
200                             itemSearchResultDisplayRow.setItemStatus(searchResultField.getFieldValue());
201                         } else if (searchResultField.getFieldName().equalsIgnoreCase(OLEConstants.ITEM_TYPE_FULL_VALUE)) {
202                             singleItemResultDisplayRow.setItemType(searchResultField.getFieldValue());
203                             itemSearchResultDisplayRow.setItemType(searchResultField.getFieldValue());
204                         } else if (searchResultField.getFieldName().equalsIgnoreCase(Holdings.HOLDINGSIDENTIFIER)) {
205                             holdingsSearchResultDisplayRow.setId(searchResultField.getFieldValue());
206                             singleItemResultDisplayRow.setHoldingsIdentifier(searchResultField.getFieldValue());
207                             itemSearchResultDisplayRow.setHoldingsIdentifier(searchResultField.getFieldValue());
208                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.HOLDINGS_CALLNUMBER_DISPLAY)) {
209                             holdingsSearchResultDisplayRow.setCallNumber(searchResultField.getFieldValue());
210                         } else if (searchResultField.getFieldName().equalsIgnoreCase(Item.ID)) {
211                             singleItemResultDisplayRow.setId(searchResultField.getFieldValue());
212                             itemSearchResultDisplayRow.setId(searchResultField.getFieldValue());
213                         } else if (searchResultField.getFieldName().equalsIgnoreCase(Item.ITEM_BARCODE)) {
214                             singleItemResultDisplayRow.setItemBarCode(searchResultField.getFieldValue());
215                             itemSearchResultDisplayRow.setItemBarCode(searchResultField.getFieldValue());
216                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.ENUMERATION_DISPLAY)) {
217                             singleItemResultDisplayRow.setEnumeration(searchResultField.getFieldValue());
218                             itemSearchResultDisplayRow.setEnumeration(searchResultField.getFieldValue());
219                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.CHRONOLOGY_DISPLAY)) {
220                             singleItemResultDisplayRow.setChronology(searchResultField.getFieldValue());
221                             itemSearchResultDisplayRow.setChronology(searchResultField.getFieldValue());
222                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.ITEM_STATUS_EFFECTIVE_DATE)) {
223                             singleItemResultDisplayRow.setItemStatusDate(searchResultField.getFieldValue());
224                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.DUE_DATE_TIME)) {
225                             singleItemResultDisplayRow.setDueDate(searchResultField.getFieldValue());
226                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.NUMBER_OF_PIECES_DISPLAY)) {
227                             singleItemResultDisplayRow.setNoOfPieces(searchResultField.getFieldValue());
228                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.PUBLICATIONDATE_DISPLAY)) {
229                             singleItemResultDisplayRow.setPublication(searchResultField.getFieldValue());
230                             bibSearchResultDisplayRow.setPublicationYear(searchResultField.getFieldValue());
231                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.CURRENT_BORROWER)) {
232                             singleItemResultDisplayRow.setCurrentBorrowerId(searchResultField.getFieldValue());
233                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.PROXY_BORROWER)) {
234                             singleItemResultDisplayRow.setProxyBorrowerId(searchResultField.getFieldValue());
235                         } else if (searchResultField.getFieldName().equalsIgnoreCase("mdf_035a")) {
236                             singleItemResultDisplayRow.setOclcNumber(searchResultField.getFieldValue());
237                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.ISBN_DISPLAY)) {
238                             singleItemResultDisplayRow.setIsbn(searchResultField.getFieldValue());
239                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.ITEMNOTE_VALUE_DISPLAY)) {
240                             singleItemResultDisplayRow.setItemNoteValue(searchResultField.getFieldValue());
241                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.ITEMNOTE_TYPE_DISPLAY)) {
242                             singleItemResultDisplayRow.setItemNoteType(searchResultField.getFieldValue());
243                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.MISSING_PIECE_FLAG_DISPLAY)) {
244                             singleItemResultDisplayRow.setMissingPieceFlag(searchResultField.getFieldValue());
245                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.MISSING_PIECE_COUNT_DISPLAY)) {
246                             singleItemResultDisplayRow.setMissingPieceCount(searchResultField.getFieldValue());
247                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.MISSING_PIECE_FLAG_NOTE_DISPLAY)) {
248                             singleItemResultDisplayRow.setMissingPieceNote(searchResultField.getFieldValue());
249                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.CLMS_RET_FLAG)) {
250                             singleItemResultDisplayRow.setClaimsReturnedFlag(searchResultField.getFieldValue());
251                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.CLMS_RET_NOTE)) {
252                             singleItemResultDisplayRow.setClaimsReturnedNote(searchResultField.getFieldValue());
253                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.CLMS_RET_FLAG_CRE_DATE)) {
254                             singleItemResultDisplayRow.setClaimsReturnedDate(searchResultField.getFieldValue());
255                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.ITEM_DAMAGED_FLAG_DISPLAY)) {
256                             singleItemResultDisplayRow.setItemDamagedStatusFlag(searchResultField.getFieldValue());
257                         } else if (searchResultField.getFieldName().equalsIgnoreCase(ItemConstants.DAMAGED_ITEM_NOTE_DISPLAY)) {
258                             singleItemResultDisplayRow.setItemDamagedNote(searchResultField.getFieldValue());
259                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.CREATED_BY)) {
260                             singleItemResultDisplayRow.setCreatedBy(searchResultField.getFieldValue());
261                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.DATE_ENTERED)) {
262                             singleItemResultDisplayRow.setCreatedDate(searchResultField.getFieldValue());
263                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.UPDATED_BY)) {
264                             singleItemResultDisplayRow.setUpdatedBy(searchResultField.getFieldValue());
265                         } else if (searchResultField.getFieldName().equalsIgnoreCase(BibConstants.DATE_UPDATED)) {
266                             singleItemResultDisplayRow.setUpdatedDate(searchResultField.getFieldValue());
267                         }
268                     }
269                     if (searchResponse.getSearchResults().size() > 1) {
270                         if (!holdingsSearchResultDisplayRowMap.containsKey(holdingsSearchResultDisplayRow.getId())) {
271                             List<OLEItemSearchResultDisplayRow> itemSearchResultDisplayRowList = new ArrayList<>();
272                             itemSearchResultDisplayRowList.add(itemSearchResultDisplayRow);
273                             holdingsSearchResultDisplayRow.setOleItemSearchResultDisplayRowList(itemSearchResultDisplayRowList);
274                             holdingsSearchResultDisplayRowMap.put(holdingsSearchResultDisplayRow.getId(), holdingsSearchResultDisplayRow);
275                         } else {
276                             holdingsSearchResultDisplayRowMap.get(holdingsSearchResultDisplayRow.getId()).getOleItemSearchResultDisplayRowList().add(itemSearchResultDisplayRow);
277                         }
278                         if (!bibSearchResultDisplayRowMap.containsKey(bibSearchResultDisplayRow.getId())) {
279                             List<OLEHoldingsSearchResultDisplayRow> holdingsSearchResultDisplayRowList = new ArrayList<>();
280                             holdingsSearchResultDisplayRowList.add(holdingsSearchResultDisplayRow);
281                             bibSearchResultDisplayRow.setOleHoldingsSearchResultDisplayRowList(holdingsSearchResultDisplayRowList);
282                             bibSearchResultDisplayRowMap.put(bibSearchResultDisplayRow.getId(), bibSearchResultDisplayRow);
283                         } else {
284                             boolean flag = false;
285                             for (OLEHoldingsSearchResultDisplayRow oleHoldingsSearchResultDisplayRow : bibSearchResultDisplayRowMap.get(bibSearchResultDisplayRow.getId()).getOleHoldingsSearchResultDisplayRowList()) {
286                                 if (oleHoldingsSearchResultDisplayRow.getId().equals(holdingsSearchResultDisplayRow.getId())) {
287                                     flag = true;
288                                     break;
289                                 }
290                             }
291                             if (!flag) {
292                                 bibSearchResultDisplayRowMap.get(bibSearchResultDisplayRow.getId()).getOleHoldingsSearchResultDisplayRowList().add(holdingsSearchResultDisplayRow);
293                             }
294                         }
295                     }
296                 }
297             }
298             if (searchResponse.getSearchResults().size() > 1) {
299                 for (OLEBibSearchResultDisplayRow bibSearchResultDisplayRow : bibSearchResultDisplayRowMap.values()) {
300                     if (bibSearchResultDisplayRow.getOleHoldingsSearchResultDisplayRowList().size() == 1) {
301                         bibSearchResultDisplayRow.setHoldingsLocation(bibSearchResultDisplayRow.getOleHoldingsSearchResultDisplayRowList().get(0).getLocation());
302                         if (bibSearchResultDisplayRow.getOleHoldingsSearchResultDisplayRowList().get(0).getOleItemSearchResultDisplayRowList().size() > 1) {
303                             bibSearchResultDisplayRow.setItemLocation(OLEConstants.MULTIPLE);
304                             bibSearchResultDisplayRow.setItemType(OLEConstants.MULTIPLE);
305                             bibSearchResultDisplayRow.setItemStatus(OLEConstants.MULTIPLE);
306                             bibSearchResultDisplayRow.setItemCallNumber(OLEConstants.MULTIPLE);
307                         } else if (bibSearchResultDisplayRow.getOleHoldingsSearchResultDisplayRowList().get(0).getOleItemSearchResultDisplayRowList().size() == 1) {
308                             OLEItemSearchResultDisplayRow oleItemSearchResultDisplayRow = bibSearchResultDisplayRow.getOleHoldingsSearchResultDisplayRowList().get(0).getOleItemSearchResultDisplayRowList().get(0);
309                             bibSearchResultDisplayRow.setItemLocation(oleItemSearchResultDisplayRow.getLocation());
310                             bibSearchResultDisplayRow.setItemType(oleItemSearchResultDisplayRow.getItemType());
311                             bibSearchResultDisplayRow.setItemStatus(oleItemSearchResultDisplayRow.getItemStatus());
312                             bibSearchResultDisplayRow.setItemCallNumber(oleItemSearchResultDisplayRow.getCallNumber());
313                         }
314                     } else if (bibSearchResultDisplayRow.getOleHoldingsSearchResultDisplayRowList().size() > 1) {
315                         bibSearchResultDisplayRow.setHoldingsLocation(OLEConstants.MULTIPLE);
316                         bibSearchResultDisplayRow.setItemLocation(OLEConstants.MULTIPLE);
317                         bibSearchResultDisplayRow.setItemType(OLEConstants.MULTIPLE);
318                         bibSearchResultDisplayRow.setItemStatus(OLEConstants.MULTIPLE);
319                         bibSearchResultDisplayRow.setItemCallNumber(OLEConstants.MULTIPLE);
320                     }
321                     for (OLEHoldingsSearchResultDisplayRow holdingsSearchResultDisplayRow : bibSearchResultDisplayRow.getOleHoldingsSearchResultDisplayRowList()) {
322                         if (holdingsSearchResultDisplayRow.getOleItemSearchResultDisplayRowList().size() == 1) {
323                             OLEItemSearchResultDisplayRow oleItemSearchResultDisplayRow = holdingsSearchResultDisplayRow.getOleItemSearchResultDisplayRowList().get(0);
324                             holdingsSearchResultDisplayRow.setItemLocation(oleItemSearchResultDisplayRow.getLocation());
325                         } else if (holdingsSearchResultDisplayRow.getOleItemSearchResultDisplayRowList().size() > 1) {
326                             holdingsSearchResultDisplayRow.setItemLocation(OLEConstants.MULTIPLE);
327                         }
328                     }
329                     bibSearchResultDisplayRowList.add(bibSearchResultDisplayRow);
330                 }
331                 oleDeliverItemSearchForm.setOleBibSearchResultDisplayRowList(bibSearchResultDisplayRowList);
332             } else if (searchResponse.getSearchResults().size() == 1) {
333                 Map itemIdMap = new HashMap();
334                 itemIdMap.put(OLEConstants.ITEM_UUID, singleItemResultDisplayRow.getId());
335                 if (singleItemResultDisplayRow.getItemStatusDate() != null) {
336                     String[] itemStatusEffectiveDate = singleItemResultDisplayRow.getItemStatusDate().split(" ");
337                     singleItemResultDisplayRow.setItemStatusDate(itemStatusEffectiveDate[0]);
338                 }
339                 //borrower
340                 getOleDeliverItemSearchService().setBorrowerInfo(singleItemResultDisplayRow);
341                 //request
342                 getOleDeliverItemSearchService().setDeliverRequestInfo(itemIdMap, singleItemResultDisplayRow);
343                 //outstanding fine
344                 getOleDeliverItemSearchService().setOutstandingFineInfo(itemIdMap, singleItemResultDisplayRow);
345                 //notes
346                 getOleDeliverItemSearchService().setNoteInfo(singleItemResultDisplayRow);
347                 //additional copies
348                 getOleDeliverItemSearchService().setAdditionalCopiesInfo(singleItemResultDisplayRow);
349                 //item history
350                 getOleDeliverItemSearchService().setInTransitHistoryInfo(singleItemResultDisplayRow);
351                 getOleDeliverItemSearchService().setRequestHistoryInfo(singleItemResultDisplayRow);
352                 oleDeliverItemSearchForm.setOleSingleItemResultDisplayRow(singleItemResultDisplayRow);
353                 oleDeliverItemSearchForm.setSingleItemFlag(true);
354             }
355         } else {
356             GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.NO_RECORD_FOUND);
357         }
358     }
359 
360     @RequestMapping(params = "methodToCall=clearSearch")
361     public ModelAndView clearSearch(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
362                                     HttpServletRequest request, HttpServletResponse response) {
363         OLEDeliverItemSearchForm oleDeliverItemSearchForm = (OLEDeliverItemSearchForm) form;
364         oleDeliverItemSearchForm.setTitle(null);
365         oleDeliverItemSearchForm.setAuthor(null);
366         oleDeliverItemSearchForm.setPublisher(null);
367         oleDeliverItemSearchForm.setItemBarCode(null);
368         oleDeliverItemSearchForm.setItemCallNumber(null);
369         oleDeliverItemSearchForm.setItemUUID(null);
370         oleDeliverItemSearchForm.setItemType(null);
371         oleDeliverItemSearchForm.setItemLocation(null);
372         oleDeliverItemSearchForm.setOleBibSearchResultDisplayRowList(new ArrayList<OLEBibSearchResultDisplayRow>());
373         oleDeliverItemSearchForm.setSingleItemFlag(false);
374         oleDeliverItemSearchForm.setOleSingleItemResultDisplayRow(new OLESingleItemResultDisplayRow());
375         return getUIFModelAndView(oleDeliverItemSearchForm);
376     }
377 
378 
379 }