1 package org.kuali.ole.util;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.jfree.util.Log;
5 import org.kuali.asr.service.ASRHelperServiceImpl;
6 import org.kuali.ole.OLEConstants;
7 import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
8 import org.kuali.ole.deliver.bo.OleItemSearch;
9 import org.kuali.ole.deliver.processor.LoanProcessor;
10 import org.kuali.ole.describe.keyvalue.LocationValuesBuilder;
11 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
12 import org.kuali.ole.docstore.common.document.*;
13 import org.kuali.ole.docstore.common.document.content.enums.DocType;
14 import org.kuali.ole.docstore.common.document.content.instance.Item;
15 import org.kuali.ole.docstore.common.document.content.instance.Location;
16 import org.kuali.ole.docstore.common.document.content.instance.OleHoldings;
17 import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
18 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
19 import org.kuali.ole.docstore.common.search.*;
20 import org.kuali.ole.sys.context.SpringContext;
21 import org.kuali.rice.core.api.config.property.ConfigContext;
22 import org.kuali.rice.krad.util.GlobalVariables;
23 import org.kuali.rice.krad.util.KRADConstants;
24
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30
31
32
33
34
35
36
37 public class DocstoreUtil {
38 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocstoreUtil.class);
39 private DocstoreClientLocator docstoreClientLocator;
40
41 public DocstoreClientLocator getDocstoreClientLocator() {
42 if (docstoreClientLocator == null) {
43 docstoreClientLocator = (DocstoreClientLocator) SpringContext.getService("docstoreClientLocator");
44 }
45 return docstoreClientLocator;
46 }
47
48 public boolean isItemAvailableInDocStore(OleDeliverRequestBo oleDeliverRequestBo) {
49 ASRHelperServiceImpl asrHelperService = new ASRHelperServiceImpl();
50 LOG.info("Inside isItemAvailableInDocStore");
51 boolean available = false;
52 Map<String, String> itemMap = new HashMap<String, String>();
53 LocationValuesBuilder locationValuesBuilder = new LocationValuesBuilder();
54 String holdingsId = "";
55 String bibTitle="";
56 String bibAuthor="";
57 try {
58 try {
59 org.kuali.ole.docstore.common.document.Item item = new ItemOleml();
60 org.kuali.ole.docstore.common.search.SearchParams search_Params = new org.kuali.ole.docstore.common.search.SearchParams();
61 SearchResponse searchResponse = null;
62 search_Params.getSearchConditions().add(search_Params.buildSearchCondition("phrase", search_Params.buildSearchField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), item.ITEM_BARCODE, oleDeliverRequestBo.getItemId()), ""));
63 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "id"));
64 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "holdingsIdentifier"));
65 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "Title_display"));
66 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "Author_display"));
67 searchResponse = getDocstoreClientLocator().getDocstoreClient().search(search_Params);
68 for (SearchResult searchResult : searchResponse.getSearchResults()) {
69 for (SearchResultField searchResultField : searchResult.getSearchResultFields()) {
70 String fieldName = searchResultField.getFieldName();
71 String fieldValue = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
72 if (fieldName.equalsIgnoreCase("holdingsIdentifier") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
73 holdingsId = fieldValue;
74 } else if (searchResultField.getFieldName().equalsIgnoreCase("Title_display") &&!fieldValue.isEmpty()) {
75 bibTitle = searchResultField.getFieldValue();
76 } else if (searchResultField.getFieldName().equalsIgnoreCase("Author_display") &&!fieldValue.isEmpty()) {
77 bibAuthor = searchResultField.getFieldValue();
78 } else if (searchResultField.getFieldName().equalsIgnoreCase("id") &&!fieldValue.isEmpty()){
79 oleDeliverRequestBo.setItemUuid(fieldValue);
80 }
81 }
82 }
83 } catch (Exception ex) {
84 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, "Item Exists");
85 LOG.error(OLEConstants.ITEM_EXIST + ex);
86 }
87 OleItemSearch itemSearchList = getOleItemSearchList(oleDeliverRequestBo.getItemUuid());
88 if (asrHelperService.isAnASRItem(itemSearchList.getShelvingLocation())) {
89 oleDeliverRequestBo.setAsrFlag(true);
90 } else {
91 oleDeliverRequestBo.setAsrFlag(false);
92 }
93 if (itemSearchList != null) {
94 oleDeliverRequestBo.setTitle(itemSearchList.getTitle());
95 oleDeliverRequestBo.setAuthor(itemSearchList.getAuthor());
96 oleDeliverRequestBo.setCallNumber(itemSearchList.getCallNumber());
97 oleDeliverRequestBo.setItemType(itemSearchList.getItemType());
98 oleDeliverRequestBo.setItemLocation(itemSearchList.getShelvingLocation());
99 }
100 if(StringUtils.isNotEmpty(bibTitle)){
101 oleDeliverRequestBo.setTitle(bibTitle);
102 }
103 if(StringUtils.isNotEmpty(bibAuthor)){
104 oleDeliverRequestBo.setAuthor(bibAuthor);
105 }
106 LoanProcessor loanProcessor = new LoanProcessor();
107 String itemXml = loanProcessor.getItemXML(oleDeliverRequestBo.getItemUuid());
108 Item oleItem = loanProcessor.getItemPojo(itemXml);
109 oleDeliverRequestBo.setOleItem(oleItem);
110 oleDeliverRequestBo.setCopyNumber(oleItem.getCopyNumber());
111 oleDeliverRequestBo.setEnumeration(oleItem.getEnumeration());
112 oleDeliverRequestBo.setChronology(oleItem.getChronology());
113 oleDeliverRequestBo.setItemStatus(oleItem.getItemStatus().getCodeValue());
114 oleDeliverRequestBo.setClaimsReturnedFlag(oleItem.isClaimsReturnedFlag());
115 locationValuesBuilder.getLocation(oleItem, oleDeliverRequestBo, holdingsId);
116 available = true;
117 } catch (Exception e) {
118 LOG.error(ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.INVAL_LOC) + e);
119 }
120 return available;
121 }
122
123 public OleItemSearch getOleItemSearchList(String itemUuid) {
124 OleItemSearch oleItemSearch = null;
125 try {
126 LoanProcessor loanProcessor = new LoanProcessor();
127 org.kuali.ole.docstore.common.document.Item item = getDocstoreClientLocator().getDocstoreClient().retrieveItem(itemUuid);
128 oleItemSearch = buildItemRecord(loanProcessor, item);
129 } catch (Exception ex) {
130 ex.printStackTrace();
131 Log.info("Item does not Exist");
132 }
133 return oleItemSearch;
134 }
135
136
137 public OleItemSearch getOleItemSearchListFromLocalClient(String itemUuid) {
138 OleItemSearch oleItemSearch = null;
139 try {
140 org.kuali.ole.docstore.common.document.Item item = getDocstoreClientLocator().getDocstoreLocalClient().retrieveItem(itemUuid);
141 LoanProcessor loanProcessor = new LoanProcessor();
142 oleItemSearch = buildItemRecord(loanProcessor, item);
143 } catch (Exception ex) {
144 ex.printStackTrace();
145 Log.info("Item does not Exist");
146 }
147 LoanProcessor loanProcessor = new LoanProcessor();
148 return oleItemSearch;
149 }
150
151 private OleItemSearch buildItemRecord(LoanProcessor loanProcessor, org.kuali.ole.docstore.common.document.Item item) throws Exception {
152 OleItemSearch oleItemSearch = new OleItemSearch();
153 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
154 Item itemContent = itemOlemlRecordProcessor.fromXML(item.getContent());
155 OleHoldings oleHoldings = new HoldingOlemlRecordProcessor().fromXML(item.getHolding().getContent());
156 oleItemSearch.setTitle(item.getHolding().getBib().getTitle());
157 oleItemSearch.setAuthor(item.getHolding().getBib().getAuthor());
158 oleItemSearch.setVolumeNumber(itemContent.getVolumeNumber());
159 oleItemSearch.setBibUUID(item.getHolding().getBib().getId());
160 StringBuffer locationLevel = new StringBuffer("");
161 String location = "";
162 if (itemContent.getLocation().getLocationLevel() != null) {
163 location = getLocation(itemContent.getLocation(), locationLevel);
164 oleItemSearch.setShelvingLocation(location);
165 } else {
166 oleItemSearch.setShelvingLocation(getLocation(oleHoldings.getLocation(), locationLevel));
167 }
168
169
170
171
172
173
174 String itemType;
175 if (itemContent.getTemporaryItemType() != null && itemContent.getTemporaryItemType().getCodeValue() != null) {
176 itemType = itemContent.getTemporaryItemType().getCodeValue();
177 } else {
178 itemType = itemContent.getItemType().getCodeValue();
179 }
180 oleItemSearch.setPublisher(item.getHolding().getBib().getPublisher());
181 oleItemSearch.setCallNumber(loanProcessor.getItemCallNumber(itemContent.getCallNumber(), oleHoldings.getCallNumber()));
182 oleItemSearch.setHoldingUUID(item.getHolding().getId());
183 oleItemSearch.setInstanceUUID(item.getHolding().getId());
184 oleItemSearch.setCopyNumber(itemContent.getCopyNumber());
185 oleItemSearch.setItemBarCode(itemContent.getAccessInformation().getBarcode());
186 oleItemSearch.setItemStatus(itemContent.getItemStatus().getFullValue());
187 oleItemSearch.setItemType(itemType);
188 oleItemSearch.setItemUUID(item.getId());
189 oleItemSearch.setEnumeration(itemContent.getEnumeration());
190 oleItemSearch.setChronology(itemContent.getChronology());
191
192 return oleItemSearch;
193 }
194
195
196 public boolean isItemAvailableInDocStore(String itemBarcode) {
197 LOG.info("Inside isItemAvailableInDocStore");
198 boolean available = false;
199 try {
200 org.kuali.ole.docstore.common.document.Item item = new ItemOleml();
201 org.kuali.ole.docstore.common.search.SearchParams search_Params = new org.kuali.ole.docstore.common.search.SearchParams();
202 SearchResponse searchResponse = null;
203 search_Params.getSearchConditions().add(search_Params.buildSearchCondition("phrase", search_Params.buildSearchField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), item.ITEM_BARCODE, itemBarcode), ""));
204 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), OLEConstants.ID));
205 searchResponse = getDocstoreClientLocator().getDocstoreClient().search(search_Params);
206 if (searchResponse.getSearchResults() != null && searchResponse.getSearchResults().size() > 0) {
207 available = true;
208 }
209 } catch (Exception ex) {
210
211 LOG.error(OLEConstants.ITEM_EXIST + ex);
212 }
213 return available;
214 }
215
216
217 public void getSearchResultFields(SearchParams searchParams) {
218 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(),OLEConstants.ID));
219 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), org.kuali.ole.docstore.common.document.Item.ITEM_BARCODE));
220 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.HOLDINGS.getCode(), org.kuali.ole.docstore.common.document.Item.CALL_NUMBER));
221 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), org.kuali.ole.docstore.common.document.Item.ITEM_TYPE));
222 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(),OLEConstants.TEMPITEMTYPE));
223 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), org.kuali.ole.docstore.common.document.Item.ITEM_STATUS));
224 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), org.kuali.ole.docstore.common.document.Item.COPY_NUMBER));
225 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.HOLDINGS.getCode(), Holdings.LOCATION_NAME));
226 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(DocType.ITEM.getCode(), OLEConstants.LOACTION_LEVEL_DISPLAY));
227 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), org.kuali.ole.docstore.common.document.Item.VOLUME_NUMBER));
228 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), org.kuali.ole.docstore.common.document.Item.CALL_NUMBER));
229 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.HOLDINGS.getCode(), OLEConstants.ID));
230 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), OLEConstants.ID));
231 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), Bib.TITLE));
232 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), Bib.AUTHOR));
233 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), OLEConstants.PUBLISHERDISPLAY));
234 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), OLEConstants.CHRONOLOGY));
235 searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), OLEConstants.ENUMARATION));
236 }
237
238 public List<OleItemSearch> getSearchResults(SearchResponse searchResponse) {
239
240 List<OleItemSearch> oleItemSearchList = new ArrayList<>();
241 if (searchResponse.getSearchResults() != null && searchResponse.getSearchResults().size() > 0) {
242 for (SearchResult searchResult : searchResponse.getSearchResults()) {
243 OleItemSearch oleItemSearch = new OleItemSearch();
244 for (SearchResultField searchResultField : searchResult.getSearchResultFields()) {
245 String callNumber = "";
246
247 if (searchResultField.getFieldName().equalsIgnoreCase(org.kuali.ole.docstore.common.document.Item.CALL_NUMBER) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.HOLDINGS.getCode())) {
248 callNumber = searchResultField.getFieldValue();
249 }
250 if (searchResultField.getFieldName().equalsIgnoreCase(OLEConstants.ID) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
251 oleItemSearch.setItemUUID(searchResultField.getFieldValue());
252 }
253 if (searchResultField.getFieldName().equalsIgnoreCase(Bib.TITLE) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode())) {
254 if (oleItemSearch.getTitle() == null) {
255 oleItemSearch.setTitle(searchResultField.getFieldValue());
256 }
257 }
258 if (searchResultField.getFieldName().equalsIgnoreCase(OLEConstants.ID) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.HOLDINGS.getCode())) {
259 oleItemSearch.setHoldingUUID(searchResultField.getFieldValue());
260 oleItemSearch.setInstanceUUID(searchResultField.getFieldValue());
261 }
262 if (searchResultField.getFieldName().equalsIgnoreCase(org.kuali.ole.docstore.common.document.Item.ITEM_BARCODE) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
263 oleItemSearch.setItemBarCode(searchResultField.getFieldValue());
264 }
265 if (searchResultField.getFieldName().equalsIgnoreCase(org.kuali.ole.docstore.common.document.Item.CALL_NUMBER) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
266 oleItemSearch.setCallNumber(searchResultField.getFieldValue());
267 } else if (org.apache.commons.lang.StringUtils.isEmpty(oleItemSearch.getCallNumber())) {
268 oleItemSearch.setCallNumber(callNumber);
269 }
270 if (searchResultField.getFieldName().equalsIgnoreCase(org.kuali.ole.docstore.common.document.Item.COPY_NUMBER) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
271 oleItemSearch.setCopyNumber(searchResultField.getFieldValue());
272 }
273 if (searchResultField.getFieldName().equalsIgnoreCase( OLEConstants.LOACTION_LEVEL_DISPLAY) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
274 oleItemSearch.setShelvingLocation(searchResultField.getFieldValue());
275 }
276 else if (StringUtils.isEmpty(oleItemSearch.getShelvingLocation()) && searchResultField.getFieldName().equalsIgnoreCase(Holdings.LOCATION_NAME) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.HOLDINGS.getCode())) {
277 oleItemSearch.setShelvingLocation(searchResultField.getFieldValue());
278 }
279 if (searchResultField.getFieldName().equalsIgnoreCase(org.kuali.ole.docstore.common.document.Item.ITEM_STATUS) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
280 oleItemSearch.setItemStatus(searchResultField.getFieldValue());
281 }
282 if (searchResultField.getFieldName().equalsIgnoreCase(OLEConstants.CHRONOLOGY) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
283 oleItemSearch.setChronology(searchResultField.getFieldValue());
284 }
285 if (searchResultField.getFieldName().equalsIgnoreCase(OLEConstants.ENUMARATION) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
286 oleItemSearch.setEnumeration(searchResultField.getFieldValue());
287 }
288
289 if (searchResultField.getFieldName().equalsIgnoreCase(OLEConstants.TEMPITEMTYPE) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
290 oleItemSearch.setItemType(searchResultField.getFieldValue());
291 }
292 else if (StringUtils.isEmpty(oleItemSearch.getItemType()) && searchResultField.getFieldName().equalsIgnoreCase(org.kuali.ole.docstore.common.document.Item.ITEM_TYPE) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
293 oleItemSearch.setItemType(searchResultField.getFieldValue());
294 }
295 if (searchResultField.getFieldName().equalsIgnoreCase(org.kuali.ole.docstore.common.document.Item.VOLUME_NUMBER) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode())) {
296 oleItemSearch.setVolumeNumber(searchResultField.getFieldValue());
297 }
298 if (searchResultField.getFieldName().equalsIgnoreCase(Bib.AUTHOR) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode())) {
299 if (oleItemSearch.getAuthor() == null) {
300 oleItemSearch.setAuthor(searchResultField.getFieldValue());
301 }
302 }
303 if (searchResultField.getFieldName().equalsIgnoreCase(OLEConstants.PUBLISHERDISPLAY) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode())) {
304 if (oleItemSearch.getPublisher() == null) {
305 oleItemSearch.setPublisher(searchResultField.getFieldValue());
306 }
307 }
308 if (searchResultField.getFieldName().equalsIgnoreCase(OLEConstants.ID) && searchResultField.getFieldValue() != null && !searchResultField.getFieldValue().isEmpty() && searchResultField.getDocType().equalsIgnoreCase(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode())) {
309 if (oleItemSearch.getBibUUID() == null) {
310 oleItemSearch.setBibUUID(searchResultField.getFieldValue());
311 }
312
313 }
314 }
315 oleItemSearchList.add(oleItemSearch);
316 }
317
318 }
319 return oleItemSearchList;
320 }
321
322 public String getLocation(Location location, StringBuffer locationLevel) {
323 StringBuffer locationName = new StringBuffer("");
324 if (location != null && location.getLocationLevel() != null) {
325 locationName = locationName.append(location.getLocationLevel().getName());
326 locationLevel = locationLevel.append(location.getLocationLevel().getLevel());
327 if (location.getLocationLevel().getLocationLevel() != null) {
328 locationName = locationName.append("/").append(location.getLocationLevel().getLocationLevel().getName());
329 locationLevel = locationLevel.append("/").append(location.getLocationLevel().getLocationLevel().getLevel());
330 if (location.getLocationLevel().getLocationLevel().getLocationLevel() != null) {
331 locationName = locationName.append("/").append(location.getLocationLevel().getLocationLevel().getLocationLevel().getName());
332 locationLevel = locationLevel.append("/").append(location.getLocationLevel().getLocationLevel().getLocationLevel().getLevel());
333 if (location.getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel() != null) {
334 locationName = locationName.append("/").append(location.getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel().getName());
335 locationLevel = locationLevel.append("/").append(location.getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel().getLevel());
336 if (location.getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel() != null) {
337 locationName = locationName.append("/").append(location.getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel().getName());
338 locationLevel = locationLevel.append("/").append(location.getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel().getLocationLevel().getLevel());
339 }
340 }
341 }
342 }
343 }
344 return locationName.toString();
345 }
346
347 public OleHoldings getOleHoldings(String instanceUUID) throws Exception {
348 LOG.info("--Inside getOleHoldings---");
349 Holdings holdings = new Holdings();
350 holdings = getDocstoreClientLocator().getDocstoreClient().retrieveHoldings(instanceUUID);
351 HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor();
352 OleHoldings oleHoldings = holdingOlemlRecordProcessor.fromXML(holdings.getContent());
353 return oleHoldings;
354 }
355
356 }