1 package org.kuali.ole.docstore.engine.service;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.ole.DocumentUniqueIDPrefix;
5 import org.kuali.ole.docstore.common.document.*;
6 import org.kuali.ole.docstore.common.document.HoldingsTree;
7 import org.kuali.ole.docstore.common.document.Item;
8 import org.kuali.ole.docstore.common.document.content.instance.*;
9 import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
10 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
11 import org.kuali.ole.docstore.common.exception.*;
12 import org.kuali.ole.docstore.common.search.*;
13 import org.kuali.ole.docstore.common.service.DocstoreService;
14 import org.kuali.ole.docstore.engine.service.index.DocstoreIndexService;
15 import org.kuali.ole.docstore.engine.service.index.DocstoreIndexServiceImpl;
16 import org.kuali.ole.docstore.engine.service.search.DocstoreSearchService;
17 import org.kuali.ole.docstore.engine.service.search.DocstoreSolrSearchService;
18 import org.kuali.ole.docstore.engine.service.storage.DocstoreRDBMSStorageService;
19 import org.kuali.ole.docstore.engine.service.storage.DocstoreStorageService;
20 import org.kuali.ole.docstore.model.enums.DocCategory;
21 import org.kuali.ole.docstore.model.enums.DocFormat;
22 import org.kuali.ole.docstore.model.enums.DocType;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30
31
32
33
34
35
36
37
38 public class DocstoreServiceImpl implements DocstoreService {
39 private static final Logger LOG = LoggerFactory.getLogger(DocstoreServiceImpl.class);
40 private DocstoreStorageService docstoreStorageService = null;
41 private DocstoreSearchService docstoreSearchService = null;
42 private DocstoreIndexService docstoreIndexService = null;
43
44 @Override
45 public void createBib(Bib bib) {
46 try {
47 getDocstoreStorageService().createBib(bib);
48 } catch (Exception e) {
49 LOG.error("Exception occurred while creating Bib", e);
50 throw e;
51 }
52 try {
53 getDocstoreIndexService().createBib(bib);
54 } catch (Exception e) {
55 LOG.error("Exception occurred while indexing created Bib", e);
56 docstoreStorageService.rollback();
57 throw e;
58 }
59 }
60
61 @Override
62 public void createHoldings(Holdings holdings) {
63 try {
64 getDocstoreStorageService().createHoldings(holdings);
65 } catch (Exception e) {
66 LOG.error("Exception occurred while creating Holdings or EHoldings", e);
67 throw e;
68 }
69 try {
70 getDocstoreIndexService().createHoldings(holdings);
71 } catch (Exception e) {
72 LOG.error("Exception occurred while indexing created Holdings or EHoldings", e);
73 docstoreStorageService.rollback();
74 throw e;
75 }
76 }
77
78 @Override
79 public void createItem(Item item) {
80 try {
81 getDocstoreStorageService().createItem(item);
82 } catch (Exception e) {
83 LOG.error("Exception occurred while creating item", e);
84 throw e;
85 }
86 try {
87 getDocstoreIndexService().createItem(item);
88 } catch (Exception e) {
89 LOG.error("Exception occurred while indexing created item", e);
90 docstoreStorageService.rollback();
91 throw e;
92 }
93 }
94
95 @Override
96 public void createHoldingsTree(HoldingsTree holdingsTree) {
97 try {
98 getDocstoreStorageService().createHoldingsTree(holdingsTree);
99 } catch (Exception e) {
100 LOG.error("Exception occurred while creating Holdings tree", e);
101 throw e;
102 }
103 try {
104 getDocstoreIndexService().createHoldingsTree(holdingsTree);
105 } catch (Exception e) {
106 LOG.error("Exception occurred while indexing created Holdings tree", e);
107 docstoreStorageService.rollback();
108 throw e;
109 }
110 }
111
112 @Override
113 public void createBibTree(BibTree bibTree) {
114 try {
115 getDocstoreStorageService().createBibTree(bibTree);
116 } catch (Exception e) {
117 LOG.error("Exception occurred while creating Bib tree", e);
118 throw e;
119 }
120 try {
121 getDocstoreIndexService().createBibTree(bibTree);
122 } catch (Exception e) {
123 LOG.error("Exception occurred while indexing created Bib tree", e);
124 docstoreStorageService.rollback();
125 throw e;
126 }
127
128
129 }
130
131 @Override
132 public Bib retrieveBib(String bibId) {
133 Bib bib = getDocstoreStorageService().retrieveBib(bibId);
134 return bib;
135 }
136
137 @Override
138 public List<Bib> retrieveBibs(List<String> bibIds) {
139 List<Bib> bibs = getDocstoreStorageService().retrieveBibs(bibIds);
140 return bibs;
141 }
142
143 @Override
144 public List<Item> retrieveItems(List<String> itemIds) {
145 List<Item> items = getDocstoreStorageService().retrieveItems(itemIds);
146 return items;
147 }
148
149 @Override
150 public HashMap<String, Item> retrieveItemMap(List<String> itemIds) {
151 HashMap<String, Item> items = getDocstoreStorageService().retrieveItemMap(itemIds);
152 return items;
153 }
154
155 @Override
156 public Holdings retrieveHoldings(String holdingsId) {
157 Holdings holdings = getDocstoreStorageService().retrieveHoldings(holdingsId);
158
159
160
161
162 holdings.setId(holdingsId);
163 holdings.setCategory(DocCategory.WORK.getCode());
164 holdings.setType(DocType.HOLDINGS.getCode());
165 holdings.setFormat(DocFormat.OLEML.getCode());
166 return holdings;
167 }
168
169 @Override
170 public Item retrieveItem(String itemId) {
171 Item item = getDocstoreStorageService().retrieveItem(itemId);
172 item.setId(itemId);
173 item.setCategory(DocCategory.WORK.getCode());
174 item.setType(DocType.ITEM.getCode());
175 item.setFormat(DocFormat.OLEML.getCode());
176 return item;
177 }
178
179 @Override
180 public HoldingsTree retrieveHoldingsTree(String holdingsId) {
181 HoldingsTree holdingsTree = getDocstoreStorageService().retrieveHoldingsTree(holdingsId);
182 return holdingsTree;
183 }
184
185 @Override
186 public BibTree retrieveBibTree(String bibId) {
187 BibTree bibTree = getDocstoreStorageService().retrieveBibTree(bibId);
188 return bibTree;
189 }
190
191 @Override
192 public BibTrees retrieveBibTrees(List<String> bibIds) {
193 BibTrees bibTrees = new BibTrees();
194 bibTrees.getBibTrees().addAll(getDocstoreStorageService().retrieveBibTrees(bibIds));
195 return bibTrees;
196 }
197
198 @Override
199 public void updateBib(Bib bib) {
200 try {
201 getDocstoreStorageService().updateBib(bib);
202 } catch (Exception e) {
203 LOG.error("Exception occurred while updating Bib ", e);
204 throw e;
205 }
206 try {
207 getDocstoreIndexService().updateBib(bib);
208 } catch (Exception e) {
209 LOG.error("Exception occurred while indexing updated Bib ", e);
210 docstoreStorageService.rollback();
211 throw e;
212 }
213 }
214
215 @Override
216 public void updateBibs(List<Bib> bibs) {
217 try {
218 getDocstoreStorageService().updateBibs(bibs);
219 } catch (Exception e) {
220 LOG.error("Exception occurred while updating list of Bib ", e);
221 throw e;
222 }
223 try {
224 getDocstoreIndexService().updateBibs(bibs);
225 } catch (Exception e) {
226 LOG.error("Exception occurred while indexing updated list of Bib ", e);
227 docstoreStorageService.rollback();
228 throw e;
229 }
230 }
231
232 @Override
233 public void updateHoldings(Holdings holdings) {
234 try {
235 getDocstoreStorageService().updateHoldings(holdings);
236 } catch (Exception e) {
237 LOG.error("Exception occurred while updating Holdings ", e);
238 throw e;
239 }
240 try {
241 getDocstoreIndexService().updateHoldings(holdings);
242 } catch (Exception e) {
243 LOG.error("Exception occurred while indexing updated Holdings ", e);
244 docstoreStorageService.rollback();
245 throw e;
246 }
247 }
248
249 @Override
250 public void updateItem(Item item) {
251 try {
252 getDocstoreStorageService().updateItem(item);
253 } catch (Exception e) {
254 LOG.error("Exception occurred while updating item ", e);
255 throw e;
256 }
257 try {
258 getDocstoreIndexService().updateItem(item);
259 } catch (Exception e) {
260 LOG.error("Exception occurred while indexing updated item ", e);
261 docstoreStorageService.rollback();
262 throw e;
263 }
264 }
265
266 @Override
267 public void deleteBib(String bibId) {
268 if (!DocumentUniqueIDPrefix.hasPrefix(bibId)) {
269 bibId = DocumentUniqueIDPrefix.getPrefixedId(DocumentUniqueIDPrefix.PREFIX_WORK_BIB_MARC, bibId);
270 }
271 try {
272 getDocstoreStorageService().deleteBib(bibId);
273 } catch (Exception e) {
274 LOG.error("Exception occurred while deleting Bib ", e);
275 throw e;
276 }
277 try {
278 getDocstoreIndexService().deleteBib(bibId);
279 } catch (Exception e) {
280 LOG.error("Exception occurred while indexing deleted Bib ", e);
281 docstoreStorageService.rollback();
282 throw e;
283 }
284 }
285
286 @Override
287 public void deleteHoldings(String holdingsId) {
288 try {
289 getDocstoreStorageService().deleteHoldings(holdingsId);
290 } catch (Exception e) {
291 LOG.error("Exception occurred while deleting Holdings ", e);
292 throw e;
293 }
294 try {
295 getDocstoreIndexService().deleteHoldings(holdingsId);
296 } catch (Exception e) {
297 LOG.error("Exception occurred while indexing deleted Holdings ", e);
298 docstoreStorageService.rollback();
299 throw e;
300 }
301 }
302
303 @Override
304 public void deleteItem(String itemId) {
305 try {
306 getDocstoreStorageService().deleteItem(itemId);
307 } catch (Exception e) {
308 LOG.error("Exception occurred while deleting item ", e);
309 throw e;
310 }
311 try {
312 getDocstoreIndexService().deleteItem(itemId);
313 } catch (Exception e) {
314 LOG.error("Exception occurred while indexing deleted item ", e);
315 docstoreStorageService.rollback();
316 throw e;
317 }
318 }
319
320 @Override
321 public SearchResponse search(SearchParams searchParams) {
322 SearchResponse searchResponse = null;
323 try {
324 DocstoreSearchService searchService = getDocstoreSearchService();
325 searchResponse = searchService.search(searchParams);
326 } catch (Exception e) {
327 LOG.error("Exception occurred in Search Response service ", e);
328 throw e;
329 }
330 return searchResponse;
331 }
332
333 public void setResultFieldsForHoldings(Holdings holdings, List<SearchResultField> searchResultFields) {
334 OleHoldings oleHoldings = new HoldingOlemlRecordProcessor().fromXML(holdings.getContent());
335 try {
336 for (SearchResultField searchResultField : searchResultFields) {
337 if (searchResultField.getDocType().equalsIgnoreCase("Holdings")) {
338 if (searchResultField.getFieldName().equalsIgnoreCase(Holdings.CALL_NUMBER)) {
339 holdings.setCallNumber(oleHoldings.getCallNumber().getNumber());
340 } else if (searchResultField.getFieldName().equalsIgnoreCase(Holdings.CALLNUMBER_PREFIX)) {
341 holdings.setCallNumberPrefix(oleHoldings.getCallNumber().getPrefix());
342 } else if (searchResultField.getFieldName().equalsIgnoreCase(Holdings.CALLNUMBER_TYPE)) {
343 holdings.setCallNumberType(oleHoldings.getCallNumber().getType());
344 } else if (searchResultField.getFieldName().equalsIgnoreCase(Holdings.COPY_NUMBER)) {
345 holdings.setCopyNumber(oleHoldings.getCopyNumber());
346 } else if (searchResultField.getFieldName().equalsIgnoreCase(Holdings.LOCATION_NAME)) {
347 holdings.setLocationName(oleHoldings.getLocation().getLocationLevel().getName());
348
349
350
351
352
353
354
355
356 }
357 }
358 }
359 } catch (Exception e) {
360 LOG.error("Exception occurred in setting the result fields for Holdings ", e);
361 throw e;
362 }
363 }
364
365 public void setResultFieldsForItem(Item itemDoc, List<SearchResultField> searchResultFields) {
366 org.kuali.ole.docstore.common.document.content.instance.Item item = new ItemOlemlRecordProcessor().fromXML(itemDoc.getContent());
367 for (SearchResultField searchResultField : searchResultFields) {
368 if (searchResultField.getDocType().equalsIgnoreCase("Item")) {
369 if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.ITEM_STATUS)) {
370 itemDoc.setItemStatus(item.getItemStatus().getCodeValue());
371 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.CALL_NUMBER)) {
372 itemDoc.setCallNumber(item.getCallNumber().getNumber());
373 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.CALL_NUMBER_TYPE)) {
374 itemDoc.setCallNumber(item.getCallNumber().getShelvingScheme().getCodeValue());
375 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.CALL_NUMBER_PREFIX)) {
376 itemDoc.setCallNumberPrefix(item.getCallNumber().getPrefix());
377 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.LOCATION)) {
378 itemDoc.setLocation(item.getLocation().toString());
379 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.SHELVING_ORDER)) {
380 itemDoc.setShelvingOrder(item.getCallNumber().getShelvingOrder().getCodeValue());
381 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.ITEM_BARCODE)) {
382 itemDoc.setBarcode(item.getAccessInformation().getBarcode());
383 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.COPY_NUMBER)) {
384 itemDoc.setCopyNumber(item.getCopyNumber());
385 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.ENUMERATION)) {
386 itemDoc.setEnumeration(item.getEnumeration());
387 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.CHRONOLOGY)) {
388 itemDoc.setChronology(item.getChronology());
389 } else if (searchResultField.getFieldName().equalsIgnoreCase(itemDoc.ITEM_TYPE)) {
390 itemDoc.setItemType(item.getItemType().getCodeValue());
391 }
392 }
393 }
394 }
395
396 @Override
397 public void setResultFieldsForBib(Bib bib, List<SearchResultField> searchResultFields) {
398 for (SearchResultField searchResultField : searchResultFields) {
399 if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode())) {
400 if (searchResultField.getFieldName().equalsIgnoreCase("Title")) {
401 bib.setTitle(searchResultField.getFieldValue());
402 }
403 if (searchResultField.getFieldName().equalsIgnoreCase("Format")) {
404 bib.setFormat(searchResultField.getFieldValue());
405 }
406 if (searchResultField.getFieldName().equalsIgnoreCase("Id")) {
407 bib.setId(searchResultField.getFieldValue());
408 }
409 if (searchResultField.getFieldName().equalsIgnoreCase("LocalId")) {
410 bib.setLocalId(searchResultField.getFieldValue());
411 }
412 if (searchResultField.getFieldName().equalsIgnoreCase("Author")) {
413 bib.setAuthor(searchResultField.getFieldValue());
414 }
415 if (searchResultField.getFieldName().equalsIgnoreCase("PublicationDate")) {
416 bib.setPublicationDate(searchResultField.getFieldValue());
417 }
418 }
419 }
420 }
421
422 @Override
423 public void createLicense(License license) {
424 try {
425 getDocstoreStorageService().createLicense(license);
426 } catch (Exception e) {
427 LOG.error("Exception occurred while creating license for docstore ", e);
428 throw e;
429 }
430 try {
431 getDocstoreIndexService().createLicense(license);
432 } catch (Exception e) {
433 LOG.error("Exception occurred while indexing created license for docstore ", e);
434 docstoreStorageService.rollback();
435 throw e;
436 }
437 }
438
439 @Override
440 public Bib findBib(Map<String, String> map) {
441 String id = null;
442 try {
443 id = getDocstoreSearchService().findBib(map);
444 if (id != null) {
445 return retrieveBib(id);
446 }
447 } catch (Exception e) {
448 LOG.error("Exception occurred while retrieving a bib for the id:" + id, e);
449 throw e;
450 }
451 return null;
452 }
453
454 @Override
455 public BibTree findBibTree(Map<String, String> map) {
456 String id = null;
457 try {
458 id = getDocstoreSearchService().findBib(map);
459 if (id != null) {
460 return retrieveBibTree(id);
461 }
462 } catch (Exception e) {
463 LOG.error("Exception occurred while retrieving bib tree for the id:" + id, e);
464 throw e;
465 }
466 return null;
467 }
468
469 @Override
470 public Holdings findHoldings(Map<String, String> map) {
471 String id = null;
472 try {
473 id = getDocstoreSearchService().findBib(map);
474 if (id != null) {
475 return retrieveHoldings(id);
476 }
477 } catch (Exception e) {
478 LOG.error("Exception occurred while retrieving Holdings for the id:" + id, e);
479 throw e;
480 }
481 return null;
482 }
483
484 @Override
485 public HoldingsTree findHoldingsTree(Map<String, String> map) {
486 String id = null;
487 try {
488 id = getDocstoreSearchService().findBib(map);
489 if (id != null) {
490 return retrieveHoldingsTree(id);
491 }
492 } catch (Exception e) {
493 LOG.error("Exception occurred while retrieving Holdings tree for the id:" + id, e);
494 throw e;
495 }
496 return null;
497 }
498
499 @Override
500 public Item findItem(Map<String, String> map) {
501 String id = null;
502 try {
503 id = getDocstoreSearchService().findBib(map);
504 if (id != null) {
505 return retrieveItem(id);
506 }
507 } catch (Exception e) {
508 LOG.error("Exception occurred while retrieving item for the id:" + id, e);
509 throw e;
510 }
511 return null;
512 }
513
514 @Override
515 public void boundHoldingsWithBibs(String holdingsId, List<String> bibIds) {
516 try {
517 getDocstoreStorageService().boundHoldingsWithBibs(holdingsId, bibIds);
518 } catch (Exception e) {
519 LOG.error("Exception occurred in bound holdings with bibs ", e);
520 throw e;
521 }
522 try {
523 getDocstoreIndexService().boundHoldingsWithBibs(holdingsId, bibIds);
524 } catch (Exception e) {
525 docstoreStorageService.rollback();
526 LOG.error("Exception occurred while indexing the bounded holdings with bibs ", e);
527 throw e;
528 }
529
530 }
531
532 @Override
533 public void transferHoldings(List<String> holdingsIds, String bibId) {
534
535
536
537
538 try {
539 getDocstoreStorageService().transferHoldings(holdingsIds, bibId);
540 } catch (Exception e) {
541 LOG.error("Exception occurred while transferring Holdings ", e);
542 throw e;
543 }
544 try {
545 getDocstoreIndexService().transferHoldings(holdingsIds, bibId);
546 } catch (Exception e) {
547 LOG.error("Exception occurred while indexing a transferred Holdings ", e);
548 docstoreStorageService.rollback();
549 throw e;
550 }
551 }
552
553 @Override
554 public void transferItems(List<String> itemIds, String holdingsId) {
555 try {
556 getDocstoreStorageService().transferItems(itemIds, holdingsId);
557 } catch (Exception e) {
558 LOG.error("Exception occurred while transferring items ", e);
559 throw e;
560 }
561 try {
562 getDocstoreIndexService().transferItems(itemIds, holdingsId);
563 } catch (Exception e) {
564 LOG.error("Exception occurred while indexing a transferred items ", e);
565 docstoreStorageService.rollback();
566 throw e;
567 }
568 }
569
570 @Override
571 public void createBibTrees(BibTrees bibTrees) {
572 try {
573 getDocstoreStorageService().createBibTrees(bibTrees);
574 } catch (Exception e) {
575 LOG.error("Exception occurred while creating bib trees ", e);
576 }
577 try {
578 getDocstoreIndexService().createBibTrees(bibTrees);
579 } catch (Exception e) {
580 LOG.error("Exception occurred while indexing created bib trees ", e);
581 docstoreStorageService.rollback();
582 throw new DocstoreIndexException();
583 }
584 }
585
586 @Override
587 public void deleteBibs(List<String> bibIds) {
588 try {
589 getDocstoreStorageService().deleteBibs(bibIds);
590 } catch (Exception e) {
591 LOG.error("Exception occurred while deleting bib records ", e);
592 throw e;
593 }
594 try {
595 getDocstoreIndexService().deleteBibs(bibIds);
596 } catch (Exception e) {
597 LOG.error("Exception occurred while indexing bib records after deletion", e);
598 docstoreStorageService.rollback();
599 throw e;
600 }
601 }
602
603 @Override
604 public SearchResponse browseItems(BrowseParams browseParams) {
605 try {
606 SearchResponse searchResponse = getDocstoreSearchService().search(browseParams);
607
608
609
610
611
612
613
614
615
616 return searchResponse;
617
618 } catch (Exception e) {
619 LOG.error("Exception occurred getting the search response for browse items ", e);
620 throw e;
621 }
622
623 }
624
625 @Override
626 public SearchResponse browseHoldings(BrowseParams browseParams) {
627 try {
628 SearchResponse searchResponse = getDocstoreSearchService().search(browseParams);
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647 return searchResponse;
648 } catch (Exception e) {
649 LOG.error("Exception occurred getting the search response for browse Holdings ", e);
650 throw e;
651 }
652 }
653
654 private DocstoreStorageService getDocstoreStorageService() {
655 if (docstoreStorageService == null) {
656 docstoreStorageService = new DocstoreRDBMSStorageService();
657 }
658 return docstoreStorageService;
659 }
660
661 private DocstoreSearchService getDocstoreSearchService() {
662 if (docstoreSearchService == null) {
663 docstoreSearchService = new DocstoreSolrSearchService();
664 }
665
666 return docstoreSearchService;
667 }
668
669 private DocstoreIndexService getDocstoreIndexService() {
670 if (docstoreIndexService == null) {
671 docstoreIndexService = new DocstoreIndexServiceImpl();
672 }
673 return docstoreIndexService;
674 }
675
676 @Override
677 public void createLicenses(Licenses licenses) {
678 try {
679 getDocstoreStorageService().createLicenses(licenses);
680 } catch (Exception e) {
681 LOG.error("Exception occurred while creating license for docstore ", e);
682 throw e;
683 }
684 try {
685 getDocstoreIndexService().createLicenses(licenses);
686 } catch (Exception e) {
687 LOG.error("Exception occurred while doing indexing the created license ", e);
688 docstoreStorageService.rollback();
689 throw e;
690 }
691 }
692
693 @Override
694 public License retrieveLicense(String licenseId) {
695 License license = null;
696 try {
697 license = (License) getDocstoreStorageService().retrieveLicense(licenseId);
698 } catch (Exception e) {
699 LOG.error("Exception occurred while retrieving a created license , id : " + licenseId, e);
700 throw e;
701 }
702 return license;
703 }
704
705 @Override
706 public Licenses retrieveLicenses(List<String> licenseIds) {
707 Licenses licenses = null;
708 try {
709 licenses = getDocstoreStorageService().retrieveLicenses(licenseIds);
710 } catch (Exception e) {
711 LOG.error("Exception occurred while retrieving a created licenses , ids : " + licenseIds, e);
712 throw e;
713 }
714 return licenses;
715 }
716
717 @Override
718 public void updateLicense(License license) {
719 try {
720 getDocstoreStorageService().updateLicense(license);
721 } catch (Exception e) {
722 LOG.error("Exception occurred while updating license ", e);
723 throw e;
724 }
725 try {
726 getDocstoreIndexService().updateLicense(license);
727 } catch (Exception e) {
728 LOG.error("Exception occurred while indexing updated license ", e);
729 docstoreStorageService.rollback();
730 throw e;
731 }
732 }
733
734 @Override
735 public void updateLicenses(Licenses licenses) {
736 try {
737 getDocstoreStorageService().updateLicenses(licenses);
738 } catch (Exception e) {
739 LOG.error("Exception occurred while updating licenses ", e);
740 throw e;
741 }
742 try {
743 getDocstoreIndexService().updateLicenses(licenses);
744 } catch (Exception e) {
745 LOG.error("Exception occurred while indexing updated licenses ", e);
746 docstoreStorageService.rollback();
747 throw e;
748 }
749 }
750
751 @Override
752 public void deleteLicense(String licenseId) {
753
754
755
756 try {
757 getDocstoreStorageService().deleteLicense(licenseId);
758 } catch (Exception e) {
759 LOG.error("Exception occurred while deleting license for id : " + licenseId, e);
760 throw e;
761 }
762 try {
763 getDocstoreIndexService().deleteLicense(licenseId);
764 } catch (Exception e) {
765 LOG.error("Exception occurred while indexing the license for id : " + licenseId, e);
766 docstoreStorageService.rollback();
767 throw e;
768 }
769 }
770
771 @Override
772 public void createAnalyticsRelation(String seriesHoldingsId, List<String> itemIds) {
773 try {
774 getDocstoreStorageService().createAnalyticsRelation(seriesHoldingsId, itemIds);
775 } catch (Exception e) {
776 LOG.error("Exception occurred while creating analytical relation ", e);
777 throw e;
778 }
779
780 try {
781 getDocstoreIndexService().createAnalyticsRelation(seriesHoldingsId, itemIds);
782 } catch (Exception e) {
783 docstoreStorageService.rollback();
784 LOG.error("Exception occurred while indexing created analytical relation ", e);
785 throw e;
786 }
787 }
788
789 @Override
790 public void bulkUpdateHoldings(Holdings holdings, List<String> holdingIds, String canUpdateStaffOnlyFlag) {
791 HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor();
792 OleHoldings oleHoldings = holdingOlemlRecordProcessor.fromXML(holdings.getContent());
793 try {
794 for (String holdingId : holdingIds) {
795 Holdings existingHoldings = (Holdings) getDocstoreStorageService().retrieveHoldings(holdingId);
796 if (existingHoldings != null) {
797 OleHoldings existingOleHoldings = holdingOlemlRecordProcessor.fromXML(existingHoldings.getContent());
798 if (oleHoldings != null && oleHoldings.getLocation() != null &&
799 oleHoldings.getLocation().getLocationLevel() != null &&
800 oleHoldings.getLocation().getLocationLevel().getName() != null &&
801 !oleHoldings.getLocation().getLocationLevel().getName().isEmpty()) {
802
803
804
805 existingOleHoldings.setLocation(oleHoldings.getLocation());
806
807
808 }
809 if (canUpdateStaffOnlyFlag.equalsIgnoreCase("true")) {
810 existingHoldings.setStaffOnly(oleHoldings.isStaffOnlyFlag());
811 }
812 if (oleHoldings.getCallNumber() != null) {
813 if (existingOleHoldings.getCallNumber() != null) {
814 if (oleHoldings.getCallNumber().getPrefix() != null) {
815 existingOleHoldings.getCallNumber().setPrefix(oleHoldings.getCallNumber().getPrefix());
816 }
817 if (oleHoldings.getCallNumber().getNumber() != null) {
818 existingOleHoldings.getCallNumber().setNumber(oleHoldings.getCallNumber().getNumber());
819 }
820 if (oleHoldings.getCallNumber().getShelvingScheme() != null &&
821 oleHoldings.getCallNumber().getShelvingScheme().getCodeValue() != null) {
822 existingOleHoldings.getCallNumber().getShelvingScheme().setCodeValue(oleHoldings.getCallNumber().getShelvingScheme().getCodeValue());
823 }
824 if (oleHoldings.getCallNumber().getShelvingOrder() != null &&
825 oleHoldings.getCallNumber().getShelvingOrder().getFullValue() != null) {
826 existingOleHoldings.getCallNumber().getShelvingOrder().setFullValue(oleHoldings.getCallNumber().getShelvingOrder().getFullValue());
827 }
828 } else {
829 existingOleHoldings.setCallNumber(oleHoldings.getCallNumber());
830 }
831 }
832 if (oleHoldings.getNote() != null && oleHoldings.getNote().size() > 0) {
833 List<Note> holdingNotes = existingOleHoldings.getNote();
834 if (holdingNotes != null && holdingNotes.size() > 0) {
835 for (Note note : oleHoldings.getNote()) {
836 if (note.getType() != null && note.getValue() != null && !note.getValue().isEmpty()) {
837 holdingNotes.add(note);
838 }
839 }
840 existingOleHoldings.setNote(holdingNotes);
841 } else {
842
843 for (Note note : oleHoldings.getNote()) {
844 if (note.getType() != null && note.getValue() != null && !note.getValue().isEmpty()) {
845 holdingNotes.add(note);
846 }
847 }
848 if (holdingNotes != null && holdingNotes.size() > 0)
849 existingOleHoldings.setNote(holdingNotes);
850
851 }
852 }
853
854 if (holdings instanceof PHoldings) {
855 setPHoldingInformation(oleHoldings, existingOleHoldings);
856 } else {
857 setEHoldingInformation(oleHoldings, existingOleHoldings);
858 }
859 if (canUpdateStaffOnlyFlag.equalsIgnoreCase("true")) {
860 existingHoldings.setStaffOnly(holdings.isStaffOnly());
861 }
862 existingHoldings.setUpdatedBy(holdings.getUpdatedBy());
863 existingHoldings.setUpdatedOn(holdings.getUpdatedOn());
864 existingHoldings.setLastUpdated(holdings.getLastUpdated());
865 existingHoldings.setCategory(holdings.getCategory());
866 existingHoldings.setType(holdings.getType());
867 existingHoldings.setFormat(holdings.getFormat());
868 existingHoldings.setContent(holdingOlemlRecordProcessor.toXML(existingOleHoldings));
869 updateHoldings(existingHoldings);
870 } else {
871 DocstoreException docstoreException = new DocstoreValidationException(DocstoreResources.HOLDING_ID_NOT_FOUND, DocstoreResources.HOLDING_ID_NOT_FOUND);
872 docstoreException.addErrorParams("holdingsId", holdingId);
873 throw docstoreException;
874 }
875
876 }
877 } catch (Exception e) {
878 LOG.error("Exception occurred while doing bulk update of Holdings ", e);
879 throw e;
880 }
881 }
882
883 @Override
884 public void bulkUpdateItem(Item item, List<String> itemIds, String canUpdateStaffOnlyFlag) {
885 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
886 org.kuali.ole.docstore.common.document.content.instance.Item itemContent = itemOlemlRecordProcessor.fromXML(item.getContent());
887 try {
888 for (String itemId : itemIds) {
889 Item existingItem = (Item) getDocstoreStorageService().retrieveItem(itemId);
890 if (existingItem != null) {
891 org.kuali.ole.docstore.common.document.content.instance.Item existingItemContent = itemOlemlRecordProcessor.fromXML(existingItem.getContent());
892 if (itemContent != null && itemContent.getLocation() != null &&
893 itemContent.getLocation().getLocationLevel() != null &&
894 itemContent.getLocation().getLocationLevel().getName() != null &&
895 !itemContent.getLocation().getLocationLevel().getName().isEmpty()) {
896 if (existingItemContent.getLocation() != null && existingItemContent.getLocation().getLocationLevel() != null) {
897 existingItemContent.getLocation().getLocationLevel().setName(itemContent.getLocation().getLocationLevel().getName());
898 } else {
899 existingItemContent.setLocation(itemContent.getLocation());
900 }
901
902 }
903 if (canUpdateStaffOnlyFlag.equalsIgnoreCase("true")) {
904 existingItemContent.setStaffOnlyFlag(item.isStaffOnly());
905 }
906 if (itemContent.getCallNumber() != null) {
907 if (existingItemContent.getCallNumber() != null) {
908 if (StringUtils.isNotBlank(itemContent.getCallNumber().getPrefix())) {
909 existingItemContent.getCallNumber().setPrefix(itemContent.getCallNumber().getPrefix());
910 }
911 if (StringUtils.isNotBlank(itemContent.getCallNumber().getNumber())) {
912 existingItemContent.getCallNumber().setNumber(itemContent.getCallNumber().getNumber());
913 if (itemContent.getCallNumber().getShelvingScheme() != null &&
914 StringUtils.isNotBlank(itemContent.getCallNumber().getShelvingScheme().getCodeValue()) && !itemContent.getCallNumber().getShelvingScheme().getCodeValue().equalsIgnoreCase("NOINFO")) {
915 existingItemContent.getCallNumber().setShelvingScheme(itemContent.getCallNumber().getShelvingScheme());
916 }
917 }
918 if (itemContent.getCallNumber().getShelvingOrder() != null &&
919 StringUtils.isNotBlank(itemContent.getCallNumber().getShelvingOrder().getFullValue())) {
920 existingItemContent.getCallNumber().setShelvingOrder(itemContent.getCallNumber().getShelvingOrder());
921 }
922 } else {
923 existingItemContent.setCallNumber(itemContent.getCallNumber());
924 }
925 }
926 if (StringUtils.isNotBlank(itemContent.getEnumeration())) {
927 existingItemContent.setEnumeration(itemContent.getEnumeration());
928 }
929 if (itemContent.getAccessInformation() != null) {
930 if (itemContent.getAccessInformation().getBarcode() != null && !itemContent.getAccessInformation().getBarcode().isEmpty()) {
931 if (existingItemContent.getAccessInformation() != null && existingItemContent.getAccessInformation().getBarcode() != null) {
932 existingItemContent.getAccessInformation().setBarcode(itemContent.getAccessInformation().getBarcode());
933 } else {
934 existingItemContent.setAccessInformation(itemContent.getAccessInformation());
935 }
936 }
937 if (itemContent.getAccessInformation().getUri() != null &&
938 itemContent.getAccessInformation().getUri().getValue() != null && !itemContent.getAccessInformation().getUri().getValue().isEmpty()) {
939 existingItemContent.setAccessInformation(itemContent.getAccessInformation());
940 }
941 }
942 if (itemContent.getChronology() != null && !itemContent.getChronology().isEmpty()) {
943 existingItemContent.setChronology(itemContent.getChronology());
944 }
945 if (itemContent.getBarcodeARSL() != null && !itemContent.getBarcodeARSL().isEmpty()) {
946 existingItemContent.setBarcodeARSL(itemContent.getBarcodeARSL());
947 }
948 if (itemContent.getCopyNumber() != null && !itemContent.getCopyNumber().isEmpty()) {
949 existingItemContent.setCopyNumber(itemContent.getCopyNumber());
950 }
951 if (itemContent.getFormerIdentifier() != null && itemContent.getFormerIdentifier().size() > 0 &&
952 itemContent.getFormerIdentifier().get(0) != null && itemContent.getFormerIdentifier().get(0).getIdentifier() != null
953 && itemContent.getFormerIdentifier().get(0).getIdentifier().getIdentifierValue() != null) {
954 existingItemContent.setFormerIdentifier(itemContent.getFormerIdentifier());
955 }
956 if (itemContent.getStatisticalSearchingCode() != null && itemContent.getStatisticalSearchingCode().size() > 0 &&
957 itemContent.getStatisticalSearchingCode().get(0).getCodeValue() != null) {
958 existingItemContent.setStatisticalSearchingCode(itemContent.getStatisticalSearchingCode());
959 }
960 if (itemContent.getItemType() != null && itemContent.getItemType().getCodeValue() != null && !itemContent.getItemType().getCodeValue().isEmpty()) {
961 existingItemContent.setItemType(itemContent.getItemType());
962 }
963 if (itemContent.getTemporaryItemType() != null && itemContent.getTemporaryItemType().getCodeValue() != null &&
964 !itemContent.getTemporaryItemType().getCodeValue().isEmpty()) {
965 existingItemContent.setTemporaryItemType(itemContent.getTemporaryItemType());
966 }
967 if (itemContent.getNumberOfPieces() != null && !itemContent.getNumberOfPieces().isEmpty()) {
968 existingItemContent.setNumberOfPieces(itemContent.getNumberOfPieces());
969 }
970 if (itemContent.getPrice() != null) {
971 existingItemContent.setPrice(itemContent.getPrice());
972 }
973 if (itemContent.getDonorInfo() != null && itemContent.getDonorInfo().size() > 0) {
974 List<DonorInfo> donorInfos = existingItemContent.getDonorInfo();
975 if (donorInfos != null && donorInfos.size() > 0) {
976 for (DonorInfo donorInfo : itemContent.getDonorInfo()) {
977 donorInfos.add(donorInfo);
978 }
979 existingItemContent.setDonorInfo(donorInfos);
980 } else {
981
982 for (DonorInfo donorInfo : itemContent.getDonorInfo()) {
983 donorInfos.add(donorInfo);
984 }
985 if (donorInfos != null && donorInfos.size() > 0)
986 existingItemContent.setDonorInfo(donorInfos);
987
988 }
989 }
990
991
992 if (itemContent.getCheckinNote() != null && !itemContent.getCheckinNote().isEmpty()) {
993 existingItemContent.setCheckinNote(itemContent.getCheckinNote());
994 }
995 if (itemContent.isFastAddFlag()) {
996 existingItemContent.setFastAddFlag(itemContent.isFastAddFlag());
997 }
998 if (itemContent.isClaimsReturnedFlag()) {
999 existingItemContent.setClaimsReturnedFlag(itemContent.isClaimsReturnedFlag());
1000 if (itemContent.getClaimsReturnedFlagCreateDate() != null) {
1001 existingItemContent.setClaimsReturnedFlagCreateDate(itemContent.getClaimsReturnedFlagCreateDate());
1002 }
1003 if (itemContent.getClaimsReturnedNote() != null) {
1004 existingItemContent.setClaimsReturnedNote(itemContent.getClaimsReturnedNote());
1005 }
1006 }
1007 if (itemContent.isItemDamagedStatus()) {
1008 existingItemContent.setItemDamagedStatus(itemContent.isItemDamagedStatus());
1009 if (itemContent.getDamagedItemNote() != null) {
1010 existingItemContent.setDamagedItemNote(itemContent.getDamagedItemNote());
1011 }
1012 }
1013 if (itemContent.isMissingPieceFlag()) {
1014 existingItemContent.setMissingPieceFlag(itemContent.isMissingPieceFlag());
1015 if (itemContent.getMissingPiecesCount() != null) {
1016 existingItemContent.setMissingPiecesCount(itemContent.getMissingPiecesCount());
1017 }
1018 if (itemContent.getMissingPieceFlagNote() != null) {
1019 existingItemContent.setMissingPieceFlagNote(itemContent.getMissingPieceFlagNote());
1020 }
1021 }
1022 if (itemContent.getNote() != null && itemContent.getNote().size() > 0) {
1023 List<Note> notes = existingItemContent.getNote();
1024 if (notes != null) {
1025 for (Note note : itemContent.getNote()) {
1026 if (note.getType() != null && note.getValue() != null && !note.getValue().isEmpty()) {
1027 notes.add(note);
1028 }
1029 existingItemContent.setNote(notes);
1030 }
1031 } else {
1032
1033 for (Note note : itemContent.getNote()) {
1034 if (note.getType() != null && note.getValue() != null && !note.getValue().isEmpty()) {
1035 notes.add(note);
1036 }
1037 }
1038 if (notes != null && notes.size() > 0)
1039 existingItemContent.setNote(notes);
1040
1041 }
1042 }
1043
1044 if (itemContent.getHighDensityStorage() != null &&
1045 itemContent.getHighDensityStorage().getRow() != null) {
1046 existingItemContent.setHighDensityStorage(itemContent.getHighDensityStorage());
1047 }
1048 if (itemContent.getItemStatus() != null) {
1049 if (StringUtils.isNotBlank(itemContent.getItemStatus().getCodeValue()) || StringUtils.isNotBlank(itemContent.getItemStatus().getFullValue())) {
1050 existingItemContent.setItemStatus(itemContent.getItemStatus());
1051 }
1052 }
1053 if (canUpdateStaffOnlyFlag.equalsIgnoreCase("true")) {
1054 existingItem.setStaffOnly(item.isStaffOnly());
1055 }
1056 existingItem.setCategory(item.getCategory());
1057 existingItem.setType(item.getType());
1058 existingItem.setFormat(item.getFormat());
1059 existingItem.setContent(itemOlemlRecordProcessor.toXML(existingItemContent));
1060 updateItem(existingItem);
1061
1062 } else {
1063 DocstoreException docstoreException = new DocstoreValidationException(DocstoreResources.ITEM_ID_NOT_FOUND, DocstoreResources.ITEM_ID_NOT_FOUND);
1064 docstoreException.addErrorParams("itemId", itemId);
1065 throw docstoreException;
1066 }
1067 }
1068 } catch (Exception e) {
1069 LOG.error("Exception occurred while doing bulk update for item ", e);
1070 throw e;
1071 }
1072 }
1073
1074 @Override
1075 public Item retrieveItemByBarcode(String barcode) {
1076 Item item = getDocstoreStorageService().retrieveItemByBarcode(barcode);
1077 return item;
1078 }
1079
1080 private void setPHoldingInformation(OleHoldings oleHoldings, OleHoldings existingOleHoldings) {
1081 if (oleHoldings.getCopyNumber() != null) {
1082 existingOleHoldings.setCopyNumber(oleHoldings.getCopyNumber());
1083 }
1084 if (oleHoldings.getExtentOfOwnership() != null && oleHoldings.getExtentOfOwnership().size() > 0) {
1085 List<ExtentOfOwnership> extentOfOwnerships = existingOleHoldings.getExtentOfOwnership();
1086 if (extentOfOwnerships != null && extentOfOwnerships.size() > 0) {
1087 for (ExtentOfOwnership extentOfOwnership : oleHoldings.getExtentOfOwnership()) {
1088 if (extentOfOwnership.getType() != null && extentOfOwnership.getNote() != null && extentOfOwnership.getTextualHoldings() != null) {
1089
1090 extentOfOwnerships.add(extentOfOwnership);
1091 }
1092 }
1093 existingOleHoldings.setExtentOfOwnership(extentOfOwnerships);
1094 } else {
1095
1096 for (ExtentOfOwnership extentOfOwnership : oleHoldings.getExtentOfOwnership()) {
1097 if (extentOfOwnership.getType() != null && extentOfOwnership.getNote() != null && extentOfOwnership.getTextualHoldings() != null) {
1098 extentOfOwnerships.add(extentOfOwnership);
1099 }
1100 }
1101 if (extentOfOwnerships != null && extentOfOwnerships.size() > 0)
1102 existingOleHoldings.setExtentOfOwnership(extentOfOwnerships);
1103
1104 }
1105 }
1106 if (oleHoldings.getReceiptStatus() != null) {
1107 existingOleHoldings.setReceiptStatus(oleHoldings.getReceiptStatus());
1108 }
1109
1110 if (oleHoldings.getUri() != null && oleHoldings.getUri().size() > 0) {
1111 List<Uri> uriList = existingOleHoldings.getUri();
1112 if (uriList != null && uriList.size() > 0) {
1113 for (Uri uri : oleHoldings.getUri()) {
1114 if (uri.getValue() != null && !uri.getValue().isEmpty()) {
1115
1116 uriList.add(uri);
1117 }
1118 }
1119 existingOleHoldings.setUri(uriList);
1120 } else {
1121 for (Uri uri : oleHoldings.getUri()) {
1122 if (uri.getValue() != null && !uri.getValue().isEmpty()) {
1123 uriList.add(uri);
1124 }
1125 }
1126 if (uriList != null && uriList.size() > 0)
1127 existingOleHoldings.setUri(uriList);
1128 }
1129 }
1130 }
1131
1132 private void setEHoldingInformation(OleHoldings oleHoldings, OleHoldings existingOleHoldings) {
1133
1134 if (oleHoldings.getAccessStatus() != null) {
1135 existingOleHoldings.setAccessStatus(oleHoldings.getAccessStatus());
1136 }
1137 if (oleHoldings.getPlatform() != null) {
1138 if (existingOleHoldings.getPlatform() != null) {
1139 if (oleHoldings.getPlatform().getPlatformName() != null && !oleHoldings.getPlatform().getPlatformName().isEmpty()) {
1140 existingOleHoldings.getPlatform().setPlatformName(oleHoldings.getPlatform().getPlatformName());
1141 }
1142 if (oleHoldings.getPlatform().getAdminUrl() != null && !oleHoldings.getPlatform().getAdminUrl().isEmpty()) {
1143 existingOleHoldings.getPlatform().setAdminUrl(oleHoldings.getPlatform().getAdminUrl());
1144 }
1145 if (oleHoldings.getPlatform().getAdminPassword() != null && !oleHoldings.getPlatform().getAdminPassword().isEmpty()) {
1146 existingOleHoldings.getPlatform().setAdminPassword(oleHoldings.getPlatform().getAdminPassword());
1147 }
1148 if (oleHoldings.getPlatform().getAdminUserName() != null && !oleHoldings.getPlatform().getAdminUserName().isEmpty()) {
1149 existingOleHoldings.getPlatform().setAdminUserName(oleHoldings.getPlatform().getAdminUserName());
1150 }
1151 } else {
1152 existingOleHoldings.setPlatform(oleHoldings.getPlatform());
1153 }
1154 }
1155 if (oleHoldings.getStatusDate() != null && !oleHoldings.getStatusDate().isEmpty()) {
1156 existingOleHoldings.setStatusDate(oleHoldings.getStatusDate());
1157 }
1158 if (oleHoldings.getPublisher() != null && !oleHoldings.getPublisher().isEmpty()) {
1159 existingOleHoldings.setPublisher(oleHoldings.getPublisher());
1160 }
1161
1162
1163
1164 if (oleHoldings.getImprint() != null && !oleHoldings.getImprint().isEmpty()) {
1165 existingOleHoldings.setImprint(oleHoldings.getImprint());
1166 }
1167 if (oleHoldings.getStatisticalSearchingCode() != null && oleHoldings.getStatisticalSearchingCode().getCodeValue() != null &&
1168 !oleHoldings.getStatisticalSearchingCode().getCodeValue().isEmpty()) {
1169 if (existingOleHoldings.getStatisticalSearchingCode() != null) {
1170 existingOleHoldings.getStatisticalSearchingCode().setCodeValue(oleHoldings.getStatisticalSearchingCode().getCodeValue());
1171 } else {
1172 existingOleHoldings.setStatisticalSearchingCode(oleHoldings.getStatisticalSearchingCode());
1173 }
1174 }
1175 if (oleHoldings.getExtentOfOwnership() != null &&
1176 oleHoldings.getExtentOfOwnership().size() > 0) {
1177 List<ExtentOfOwnership> existingExtendOfOwnerShip = existingOleHoldings.getExtentOfOwnership();
1178 if (existingExtendOfOwnerShip != null && existingExtendOfOwnerShip.size() > 0) {
1179 for (ExtentOfOwnership extendOwnership : oleHoldings.getExtentOfOwnership()) {
1180 List<Coverage> extendCoverages = new ArrayList<>();
1181 if ((extendOwnership.getCoverages() != null && extendOwnership.getCoverages().getCoverage() != null &&
1182 extendOwnership.getCoverages().getCoverage().size() > 0) ||
1183 (extendOwnership.getPerpetualAccesses() != null && extendOwnership.getPerpetualAccesses().getPerpetualAccess() != null &&
1184 extendOwnership.getPerpetualAccesses().getPerpetualAccess().size() > 0)) {
1185 existingExtendOfOwnerShip.add(extendOwnership);
1186 }
1187 }
1188 existingOleHoldings.setExtentOfOwnership(existingExtendOfOwnerShip);
1189 } else {
1190 existingOleHoldings.setExtentOfOwnership(oleHoldings.getExtentOfOwnership());
1191 }
1192 }
1193 if (oleHoldings.getSubscriptionStatus() != null && !oleHoldings.getSubscriptionStatus().isEmpty()) {
1194 existingOleHoldings.setSubscriptionStatus(oleHoldings.getSubscriptionStatus());
1195 }
1196 if (oleHoldings.getDonorInfo() != null && oleHoldings.getDonorInfo().size() > 0) {
1197 List<DonorInfo> donorInfos = existingOleHoldings.getDonorInfo();
1198 if (donorInfos != null && donorInfos.size() > 0) {
1199 for (DonorInfo donorInfo : oleHoldings.getDonorInfo()) {
1200 donorInfos.add(donorInfo);
1201 }
1202 existingOleHoldings.setDonorInfo(donorInfos);
1203 } else {
1204
1205 for (DonorInfo donorInfo : oleHoldings.getDonorInfo()) {
1206 donorInfos.add(donorInfo);
1207 }
1208 if (donorInfos != null && donorInfos.size() > 0)
1209 existingOleHoldings.setDonorInfo(donorInfos);
1210 }
1211
1212 }
1213 if (oleHoldings.getLink() != null) {
1214 existingOleHoldings.setLink(oleHoldings.getLink());
1215 }
1216 if (oleHoldings.getHoldingsAccessInformation() != null &&
1217 ((oleHoldings.getHoldingsAccessInformation().getNumberOfSimultaneousUser() != null && !oleHoldings.getHoldingsAccessInformation().getNumberOfSimultaneousUser().isEmpty()) ||
1218 (oleHoldings.getHoldingsAccessInformation().getAccessUsername() != null && !oleHoldings.getHoldingsAccessInformation().getAccessUsername().isEmpty()) ||
1219 (oleHoldings.getHoldingsAccessInformation().getAccessPassword() != null && !oleHoldings.getHoldingsAccessInformation().getAccessPassword().isEmpty()) ||
1220 (oleHoldings.getHoldingsAccessInformation().getAuthenticationType() != null && !oleHoldings.getHoldingsAccessInformation().getAuthenticationType().isEmpty()) ||
1221 (oleHoldings.getHoldingsAccessInformation().getProxiedResource() != null && !oleHoldings.getHoldingsAccessInformation().getProxiedResource().isEmpty()) ||
1222 (oleHoldings.getHoldingsAccessInformation().getAccessLocation() != null && !oleHoldings.getHoldingsAccessInformation().getAccessLocation().isEmpty()))) {
1223 existingOleHoldings.setHoldingsAccessInformation(oleHoldings.getHoldingsAccessInformation());
1224 }
1225 if (oleHoldings.getLocalPersistentLink() != null && !oleHoldings.getLocalPersistentLink().isEmpty()) {
1226 existingOleHoldings.setLocalPersistentLink(oleHoldings.getLocalPersistentLink());
1227 }
1228 if (oleHoldings.getLink() != null) {
1229 existingOleHoldings.setLink(oleHoldings.getLink());
1230 }
1231 if (oleHoldings.isInterLibraryLoanAllowed()) {
1232 existingOleHoldings.setInterLibraryLoanAllowed(oleHoldings.isInterLibraryLoanAllowed());
1233 }
1234
1235 }
1236
1237 @Override
1238 public void breakAnalyticsRelation(String seriesHoldingsId, List<String> itemIds) {
1239 try {
1240 getDocstoreStorageService().breakAnalyticsRelation(seriesHoldingsId, itemIds);
1241 } catch (Exception e) {
1242 LOG.error("Exception occurred breaking analytical relation ", e);
1243 throw e;
1244 }
1245 try {
1246 getDocstoreIndexService().breakAnalyticsRelation(seriesHoldingsId, itemIds);
1247 } catch (Exception e) {
1248 docstoreStorageService.rollback();
1249 LOG.error("Exception occurred indexing of break analytical relation ", e);
1250 throw e;
1251 }
1252 }
1253
1254
1255
1256
1257
1258
1259
1260
1261 @Override
1262 public BibTrees processBibTrees(BibTrees bibTrees) {
1263 try {
1264 getDocstoreStorageService().processBibTrees(bibTrees);
1265 getDocstoreIndexService().processBibTrees(bibTrees);
1266 } catch (Exception e) {
1267 LOG.error("Exception occurred while processing bib trees ", e);
1268 throw e;
1269 }
1270 return bibTrees;
1271 }
1272
1273 }