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