1 package org.kuali.ole.docstore.common.document;
2
3 import com.thoughtworks.xstream.converters.ConversionException;
4 import org.apache.commons.lang3.StringUtils;
5 import org.apache.log4j.Logger;
6 import org.kuali.ole.docstore.common.document.content.enums.DocCategory;
7 import org.kuali.ole.docstore.common.document.content.enums.DocFormat;
8 import org.kuali.ole.docstore.common.document.content.enums.DocType;
9 import org.kuali.ole.docstore.common.document.content.instance.*;
10 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
11 import org.kuali.ole.docstore.common.document.factory.JAXBContextFactory;
12
13 import javax.xml.bind.Marshaller;
14 import javax.xml.bind.Unmarshaller;
15 import javax.xml.bind.annotation.*;
16 import javax.xml.transform.stream.StreamSource;
17 import java.io.ByteArrayInputStream;
18 import java.io.StringWriter;
19 import java.util.ArrayList;
20 import java.util.List;
21 import java.util.Map;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 @XmlAccessorType(XmlAccessType.FIELD)
55 @XmlType(name = "item", propOrder = {
56 "callNumberType",
57 "callNumberPrefix",
58 "itemStatus",
59 "volumeNumber",
60 "itemType",
61 "locationName",
62 "chronology",
63 "enumeration",
64 "copyNumber",
65 "barcode",
66 "shelvingOrder",
67 "location",
68 "callNumber",
69 "holding",
70 "isAnalytic",
71 "holdings"
72 })
73 @XmlRootElement(name = "itemDoc")
74
75 public class Item
76 extends DocstoreDocument implements Comparable<Item> {
77
78 private static final Logger LOG = Logger.getLogger(Item.class);
79 public static final String CALL_NUMBER = "CALLNUMBER";
80 public static final String CALL_NUMBER_TYPE = "CALLNUMBERTYPE";
81 public static final String CALL_NUMBER_PREFIX = "CALLNUMBERPREFIX";
82 public static final String HOLDINGS_CALL_NUMBER = "HOLDINGSCALLNUMBER";
83 public static final String HOLDINGS_CALL_NUMBER_TYPE = "HOLDINGSCALLNUMBERTYPE";
84 public static final String HOLDINGS_CALL_NUMBER_PREFIX = "HOLDINGSCALLNUMBERPREFIX";
85 public static final String LOCATION = "LOCATION";
86 public static final String HOLDINGS_LOCATION_LEVEL1 = "HOLDINGSLOCATIONLEVEL1";
87 public static final String HOLDINGS_LOCATION_LEVEL2 = "HOLDINGSLOCATIONLEVEL2";
88 public static final String HOLDINGS_LOCATION_LEVEL3 = "HOLDINGSLOCATIONLEVEL3";
89 public static final String HOLDINGS_LOCATION_LEVEL4 = "HOLDINGSLOCATIONLEVEL4";
90 public static final String HOLDINGS_LOCATION_LEVEL5 = "HOLDINGSLOCATIONLEVEL5";
91 public static final String VENDOR_LINE_ITEM_IDENTIFIER = "VENDORLINEITEMIDENTIFIER";
92 public static final String SHELVING_ORDER = "SHELVINGORDER";
93 public static final String ITEM_BARCODE = "ITEMBARCODE";
94 public static final String COPY_NUMBER = "COPYNUMBER";
95 public static final String HOLDINGS_COPY_NUMBER = "HOLDINGSCOPYNUMBER";
96 public static final String ENUMERATION = "ENUMERATION";
97 public static final String CHRONOLOGY = "CHRONOLOGY";
98 public static final String ITEM_TYPE = "ITEMTYPE";
99 public static final String VOLUME_NUMBER = "VOLUMENUMBER";
100 public static final String ITEM_STATUS = "ITEMSTATUS";
101 public static final String ITEMIDENTIFIER = "ITEMIDENTIFIER";
102 public static final String DONOR_CODE = "DONORCODE";
103 public static final String DONOR_NOTE = "DONORNOTE";
104 public static final String DONOR_PUBLIC = "DONORPUBLICDISPLAY";
105 public static final String DESTINATION_FIELD_ITEM_ITEM_BARCODE = "Item Barcode";
106 public static final String DESTINATION_FIELD_CALL_NUMBER = "Call Number";
107 public static final String DESTINATION_FIELD_COPY_NUMBER = "Copy Number";
108 public static final String DESTINATION_FIELD_CALL_NUMBER_TYPE = "Call Number Type";
109 public static final String DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX = "Call Number Prefix";
110 public static final String DESTINATION_ITEM_TYPE = "Item Type";
111 public static final String DESTINATION_ITEM_STATUS = "Item Status";
112 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER = "Holdings Call Number";
113 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE = "Holdings Call Number Type";
114 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER = "Holdings Copy Number";
115 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX = "Holdings Call Number Prefix";
116 public static final String DESTINATION_FIELD_LOCATION_LEVEL_1 = "Location Level1";
117 public static final String DESTINATION_FIELD_LOCATION_LEVEL_2 = "Location Level2";
118 public static final String DESTINATION_FIELD_LOCATION_LEVEL_3 = "Location Level3";
119 public static final String DESTINATION_FIELD_LOCATION_LEVEL_4 = "Location Level4";
120 public static final String DESTINATION_FIELD_LOCATION_LEVEL_5 = "Location Level5";
121 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1 = "Holdings Location Level1";
122 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2 = "Holdings Location Level2";
123 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3 = "Holdings Location Level3";
124 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4 = "Holdings Location Level4";
125 public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5 = "Holdings Location Level5";
126 public static final String DESTINATION_FIELD_ITEM_VENDOR_LINE_ITEM_IDENTIFIER = "Vendor Line Item Identifier";
127
128 @XmlTransient
129 private String holdingsCallNumber;
130 @XmlTransient
131 private String holdingsCallNumberType;
132 @XmlTransient
133 private String holdingsCopyNumber;
134 @XmlTransient
135 private String holdingsCallNumberPrefix;
136 @XmlTransient
137 private String holdingsLocationLevel1;
138 @XmlTransient
139 private String holdingsLocationLevel2;
140 @XmlTransient
141 private String holdingsLocationLevel3;
142 @XmlTransient
143 private String holdingsLocationLevel4;
144 @XmlTransient
145 private String holdingsLocationLevel5;
146
147
148 @XmlTransient
149 protected boolean dataMappingFlag;
150
151 public boolean isDataMappingFlag() {
152 return dataMappingFlag;
153 }
154
155 public void setDataMappingFlag(boolean dataMappingFlag) {
156 this.dataMappingFlag = dataMappingFlag;
157 }
158
159 protected String callNumberType;
160 protected String callNumberPrefix;
161 protected String itemStatus;
162 protected String volumeNumber;
163 protected String itemType;
164 protected String locationName;
165 protected String chronology;
166 protected String enumeration;
167 protected String copyNumber;
168 protected String barcode;
169 protected String shelvingOrder;
170 protected String location;
171 protected String callNumber;
172 @XmlElement(name = "holdingsDoc")
173 protected Holdings holding;
174 @XmlElement(name = "holdingsDocs")
175 protected List<Holdings> holdings;
176 protected boolean isAnalytic = false;
177 @XmlTransient
178 protected String locationLevel1;
179 @XmlTransient
180 protected String locationLevel2;
181 @XmlTransient
182 protected String locationLevel3;
183 @XmlTransient
184 protected String locationLevel4;
185 @XmlTransient
186 protected String locationLevel5;
187
188 @XmlTransient
189 protected String level1Location;
190 @XmlTransient
191 protected String level2Location;
192 @XmlTransient
193 protected String level3Location;
194 @XmlTransient
195 protected String level4Location;
196 @XmlTransient
197 protected String level5Location;
198
199 public String getLevel1Location() {
200 return level1Location;
201 }
202
203 public void setLevel1Location(String level1Location) {
204 this.level1Location = level1Location;
205 }
206
207 public String getLevel5Location() {
208 return level5Location;
209 }
210
211 public void setLevel5Location(String level5Location) {
212 this.level5Location = level5Location;
213 }
214
215 public String getLevel4Location() {
216 return level4Location;
217 }
218
219 public void setLevel4Location(String level4Location) {
220 this.level4Location = level4Location;
221 }
222
223 public String getLevel3Location() {
224 return level3Location;
225 }
226
227 public void setLevel3Location(String level3Location) {
228 this.level3Location = level3Location;
229 }
230
231 public String getLevel2Location() {
232 return level2Location;
233 }
234
235 public void setLevel2Location(String level2Location) {
236 this.level2Location = level2Location;
237 }
238
239 public Item() {
240 category = DocCategory.WORK.getCode();
241 type = DocType.ITEM.getCode();
242 format = DocFormat.OLEML.getCode();
243 }
244
245 public String getLocationLevel1() {
246 return locationLevel1;
247 }
248
249 public void setLocationLevel1(String locationLevel1) {
250 this.locationLevel1 = locationLevel1;
251 }
252
253 public String getLocationLevel2() {
254 return locationLevel2;
255 }
256
257 public void setLocationLevel2(String locationLevel2) {
258 this.locationLevel2 = locationLevel2;
259 }
260
261 public String getLocationLevel3() {
262 return locationLevel3;
263 }
264
265 public void setLocationLevel3(String locationLevel3) {
266 this.locationLevel3 = locationLevel3;
267 }
268
269 public String getLocationLevel4() {
270 return locationLevel4;
271 }
272
273 public void setLocationLevel4(String locationLevel4) {
274 this.locationLevel4 = locationLevel4;
275 }
276
277 public String getLocationLevel5() {
278
279 return locationLevel5;
280 }
281
282 public void setLocationLevel5(String locationLevel5) {
283 this.locationLevel5 = locationLevel5;
284 }
285
286
287
288
289
290
291
292 public String getCallNumberType() {
293 return callNumberType;
294 }
295
296
297
298
299
300
301
302 public void setCallNumberType(String value) {
303 this.callNumberType = value;
304 }
305
306
307
308
309
310
311
312 public String getCallNumberPrefix() {
313 return callNumberPrefix;
314 }
315
316
317
318
319
320
321
322 public void setCallNumberPrefix(String value) {
323 this.callNumberPrefix = value;
324 }
325
326
327
328
329
330
331
332 public String getItemStatus() {
333 return itemStatus;
334 }
335
336
337
338
339
340
341
342 public void setItemStatus(String value) {
343 this.itemStatus = value;
344 }
345
346
347
348
349
350
351
352 public String getVolumeNumber() {
353 return volumeNumber;
354 }
355
356
357
358
359
360
361
362 public void setVolumeNumber(String value) {
363 this.volumeNumber = value;
364 }
365
366
367
368
369
370
371
372 public String getItemType() {
373 return itemType;
374 }
375
376
377
378
379
380
381
382 public void setItemType(String value) {
383 this.itemType = value;
384 }
385
386
387
388
389
390
391
392 public String getLocationName() {
393 return locationName;
394 }
395
396
397
398
399
400
401
402 public void setLocationName(String value) {
403 this.locationName = value;
404 }
405
406
407
408
409
410
411
412 public String getChronology() {
413 return chronology;
414 }
415
416
417
418
419
420
421
422 public void setChronology(String value) {
423 this.chronology = value;
424 }
425
426
427
428
429
430
431
432 public String getEnumeration() {
433 return enumeration;
434 }
435
436
437
438
439
440
441
442
443 public void setEnumeration(String value) {
444 this.enumeration = value;
445 }
446
447
448
449
450
451
452
453 public String getCopyNumber() {
454 return copyNumber;
455 }
456
457
458
459
460
461
462
463 public void setCopyNumber(String value) {
464 this.copyNumber = value;
465 }
466
467
468
469
470
471
472
473 public String getBarcode() {
474 return barcode;
475 }
476
477
478
479
480
481
482
483 public void setBarcode(String value) {
484 this.barcode = value;
485 }
486
487
488
489
490
491
492
493 public String getShelvingOrder() {
494 return shelvingOrder;
495 }
496
497
498
499
500
501
502
503 public void setShelvingOrder(String value) {
504 this.shelvingOrder = value;
505 }
506
507
508
509
510
511
512
513 public String getLocation() {
514 return location;
515 }
516
517
518
519
520
521
522
523 public void setLocation(String value) {
524 this.location = value;
525 }
526
527
528
529
530
531
532
533 public String getCallNumber() {
534 return callNumber;
535 }
536
537
538
539
540
541
542
543 public void setCallNumber(String value) {
544 this.callNumber = value;
545 }
546
547
548
549
550
551
552
553 public Holdings getHolding() {
554 return holding;
555 }
556
557
558
559
560
561
562
563 public void setHolding(Holdings value) {
564 this.holding = value;
565 }
566
567 public boolean isAnalytic() {
568 return isAnalytic;
569 }
570
571 public void setAnalytic(boolean analytic) {
572 isAnalytic = analytic;
573 }
574
575 public List<Holdings> getHoldings() {
576 return holdings;
577 }
578
579 public void setHoldings(List<Holdings> holdings) {
580 this.holdings = holdings;
581 }
582
583 @Override
584 public String serialize(Object object) {
585 String result = null;
586 Item item = (Item) object;
587 try {
588 StringWriter sw = new StringWriter();
589 Marshaller jaxbMarshaller = JAXBContextFactory.getInstance().getMarshaller(Item.class);
590 synchronized (jaxbMarshaller) {
591 jaxbMarshaller.marshal(item, sw);
592 }
593 result = sw.toString();
594 } catch (Exception e) {
595 LOG.error("Exception ", e);
596 }
597 return result;
598 }
599
600 @Override
601 public Object deserialize(String content) {
602 Item item = new Item();
603 try {
604 Unmarshaller unmarshaller = JAXBContextFactory.getInstance().getUnMarshaller(Item.class);
605 ByteArrayInputStream input = new ByteArrayInputStream(content.getBytes("UTF-8"));
606 synchronized (unmarshaller) {
607 item = unmarshaller.unmarshal(new StreamSource(input), Item.class).getValue();
608 }
609 } catch (Exception e) {
610 LOG.error("Exception ", e);
611 }
612 return item;
613 }
614
615 @Override
616 public Object deserializeContent(Object object) {
617
618
619 return null;
620 }
621
622 @Override
623 public Object deserializeContent(String content) {
624 return null;
625 }
626
627 @Override
628 public String serializeContent(Object object) {
629 if (object == null) {
630 object = getContentObject();
631 }
632 LocationLevel locationLevel1 = new LocationLevel();
633 LocationLevel locationLevel2 = new LocationLevel();
634 LocationLevel locationLevel3 = new LocationLevel();
635 LocationLevel locationLevel4 = new LocationLevel();
636 LocationLevel locationLevel5 = new LocationLevel();
637
638 locationLevel1.setName(getLocationLevel1());
639 locationLevel2.setName(getLocationLevel2());
640 locationLevel3.setName(getLocationLevel3());
641 locationLevel4.setName(getLocationLevel4());
642 locationLevel5.setName(getLocationLevel5());
643 locationLevel1.setLocationLevel(locationLevel2);
644 locationLevel2.setLocationLevel(locationLevel3);
645 locationLevel3.setLocationLevel(locationLevel4);
646 locationLevel4.setLocationLevel(locationLevel5);
647 Location locationPojo = new Location();
648 locationPojo.setLocationLevel(locationLevel1);
649 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) object;
650 itemPojo.setLocation(locationPojo);
651 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
652 String itemXml = itemOlemlRecordProcessor.toXML(itemPojo);
653 return itemXml;
654 }
655
656 public void serializeContent() {
657 if (contentObject == null) {
658 return;
659 }
660 Location locationPojo = buildLocationObj();
661 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) contentObject;
662 itemPojo.setLocation(locationPojo);
663 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
664 content = itemOlemlRecordProcessor.toXML(itemPojo);
665 }
666
667 public void setField(String docField, String fieldValue) {
668 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) getContentObject();
669
670
671 if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_ITEM_BARCODE)) {
672 if (itemPojo.getAccessInformation() == null) {
673 AccessInformation accessInformation = new AccessInformation();
674 itemPojo.setAccessInformation(accessInformation);
675 }
676 itemPojo.getAccessInformation().setBarcode(fieldValue);
677 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) {
678
679 buildItemCallNumber(itemPojo);
680 itemPojo.getCallNumber().setNumber(fieldValue);
681 String callNumberType = itemPojo.getCallNumber().getShelvingScheme().getCodeValue();
682 if(StringUtils.isEmpty(callNumberType) || callNumberType.equals(NO_INFO_CALL_NUMBER_TYPE_CODE)) {
683 itemPojo.getCallNumber().getShelvingScheme().setCodeValue("NONE");
684 }
685 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE)) {
686 buildItemCallNumber(itemPojo);
687 itemPojo.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
688 setDataMappingFlag(true);
689 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) {
690 buildItemCallNumber(itemPojo);
691 itemPojo.getCallNumber().setPrefix(fieldValue);
692 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) {
693 itemPojo.setCopyNumber(fieldValue);
694 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_TYPE)) {
695 ItemType itemType1 = new ItemType();
696 itemType1.setCodeValue(fieldValue);
697 itemPojo.setItemType(itemType1);
698 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER)) {
699 setHoldingsCallNumber(fieldValue);
700 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) {
701 setLocationLevel1(fieldValue);
702 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) {
703 setLocationLevel2(fieldValue);
704 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) {
705 setLocationLevel3(fieldValue);
706 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) {
707 setLocationLevel4(fieldValue);
708 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) {
709 setLocationLevel5(fieldValue);
710 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE)) {
711 setHoldingsCallNumberType(fieldValue);
712 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1)) {
713 setHoldingsLocationLevel1(fieldValue);
714 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2)) {
715 setHoldingsLocationLevel2(fieldValue);
716 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3)) {
717 setHoldingsLocationLevel3(fieldValue);
718 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4)) {
719 setHoldingsLocationLevel4(fieldValue);
720 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5)) {
721 setHoldingsLocationLevel5(fieldValue);
722 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER)) {
723 setHoldingsCopyNumber(fieldValue);
724 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX)) {
725 setHoldingsCallNumberPrefix(fieldValue);
726 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_STATUS)) {
727 ItemStatus itemStatus1 = new ItemStatus();
728 itemStatus1.setCodeValue(fieldValue);
729 itemPojo.setItemStatus(itemStatus1);
730 } else if (docField.equalsIgnoreCase(ENUMERATION)) {
731 itemPojo.setEnumeration(fieldValue);
732 } else if (docField.equalsIgnoreCase(CHRONOLOGY)) {
733 itemPojo.setChronology(fieldValue);
734 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_VENDOR_LINE_ITEM_IDENTIFIER)) {
735 itemPojo.setVendorLineItemIdentifier(fieldValue);
736 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_CODE) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_PUBLIC_DISPLAY) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_NOTE)) {
737 DonorInfo donorInfo = null;
738 if (itemPojo.getDonorInfo() != null && itemPojo.getDonorInfo().size() > 0) {
739 for (DonorInfo existingDonorInfo : itemPojo.getDonorInfo()) {
740 buildDonorInfo(docField, fieldValue, itemPojo, existingDonorInfo, false);
741 }
742 } else {
743 donorInfo = new DonorInfo();
744 buildDonorInfo(docField, fieldValue, itemPojo, donorInfo, false);
745 }
746 }
747 }
748
749 private void buildDonorInfo(String docField, String fieldValue, org.kuali.ole.docstore.common.document.content.instance.Item itemPojo, DonorInfo donorInfo, boolean isDefault) {
750 if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_CODE)) {
751 if (donorInfo.getDonorCode() == null) {
752 donorInfo.setDonorCode(fieldValue);
753 } else if (!isDefault) {
754 donorInfo.setDonorCode(fieldValue);
755 }
756 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_PUBLIC_DISPLAY)) {
757 if (donorInfo.getDonorPublicDisplay() == null) {
758 donorInfo.setDonorPublicDisplay(fieldValue);
759 } else if (!isDefault) {
760 donorInfo.setDonorPublicDisplay(fieldValue);
761 }
762 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_NOTE)) {
763 if (donorInfo.getDonorNote() == null) {
764 donorInfo.setDonorNote(fieldValue);
765 } else if (!isDefault) {
766 donorInfo.setDonorNote(fieldValue);
767 }
768 }
769 if (itemPojo.getDonorInfo() == null || itemPojo.getDonorInfo().size() == 0) {
770 itemPojo.getDonorInfo().add(donorInfo);
771 }
772 }
773
774 private void buildItemCallNumber(org.kuali.ole.docstore.common.document.content.instance.Item itemPojo) {
775 if (itemPojo.getCallNumber() == null) {
776 CallNumber callNumberPojo = new CallNumber();
777 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
778 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
779 callNumberPojo.setShelvingScheme(shelvingScheme1);
780 callNumberPojo.setShelvingOrder(shelvingOrder1);
781 itemPojo.setCallNumber(callNumberPojo);
782 } else {
783 if (itemPojo.getCallNumber().getShelvingOrder() == null) {
784 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
785 itemPojo.getCallNumber().setShelvingOrder(shelvingOrder1);
786 }
787 if (itemPojo.getCallNumber().getShelvingScheme() == null) {
788 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
789 itemPojo.getCallNumber().setShelvingScheme(shelvingScheme1);
790 }
791 }
792 }
793
794 public Object getContentObject() {
795 if (contentObject == null) {
796 contentObject = new org.kuali.ole.docstore.common.document.content.instance.Item();
797 if (content != null) {
798 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
799 contentObject = itemOlemlRecordProcessor.fromXML(content);
800 }
801 }
802 return contentObject;
803 }
804
805
806 public Location buildLocationObj() {
807
808 LocationLevel locationLevel1 = new LocationLevel();
809 locationLevel1.setName(getLocationLevel1());
810 locationLevel1.setLevel(getLevel1Location());
811 LocationLevel locationLevel2 = new LocationLevel();
812 locationLevel2.setName(getLocationLevel2());
813 locationLevel2.setLevel(getLevel2Location());
814 LocationLevel locationLevel3 = new LocationLevel();
815 locationLevel3.setName(getLocationLevel3());
816 locationLevel3.setLevel(getLevel3Location());
817 LocationLevel locationLevel4 = new LocationLevel();
818 locationLevel4.setName(getLocationLevel4());
819 locationLevel4.setLevel(getLevel4Location());
820 LocationLevel locationLevel5 = new LocationLevel();
821 locationLevel5.setName(getLocationLevel5());
822 locationLevel5.setLevel(getLevel5Location());
823
824 List<LocationLevel> locationLevels = new ArrayList<>();
825
826 if (StringUtils.isNotEmpty(locationLevel1.getName())) {
827 locationLevels.add(locationLevel1);
828 }
829 if (StringUtils.isNotEmpty(locationLevel2.getName())) {
830 locationLevels.add(locationLevel2);
831 }
832 if (StringUtils.isNotEmpty(locationLevel3.getName())) {
833 locationLevels.add(locationLevel3);
834 }
835 if (StringUtils.isNotEmpty(locationLevel4.getName())) {
836 locationLevels.add(locationLevel4);
837 }
838 if (StringUtils.isNotEmpty(locationLevel5.getName())) {
839 locationLevels.add(locationLevel5);
840 }
841
842 int locationLevelSize = locationLevels.size();
843
844 for (int i = 0; i < locationLevelSize; i++) {
845 if ((locationLevelSize - 1) != i) {
846 locationLevels.get(i).setLocationLevel(locationLevels.get(i + 1));
847 }
848 }
849
850 Location locationPojo = new Location();
851 if (locationLevels.size() > 0) {
852 locationPojo.setLocationLevel(locationLevels.get(0));
853 }
854
855 return locationPojo;
856 }
857
858
859 @Override
860 public int compareTo(Item o) {
861 return this.getSortedValue().compareTo(o.getSortedValue());
862 }
863
864
865 public void setItem(Item itemIncoming) throws ConversionException {
866 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
867 org.kuali.ole.docstore.common.document.content.instance.Item incomingItemContent = itemOlemlRecordProcessor.fromXML(itemIncoming.getContent());
868 org.kuali.ole.docstore.common.document.content.instance.Item existingItemContent = itemOlemlRecordProcessor.fromXML(this.getContent());
869
870 this.setId(existingItemContent.getItemIdentifier());
871
872 if (StringUtils.isNotBlank(itemIncoming.getUpdatedBy())) {
873 this.updatedBy = itemIncoming.getUpdatedBy();
874 } else {
875 this.updatedBy = "UNKNOWN";
876 }
877 if (incomingItemContent.getLocation() != null) {
878 existingItemContent.setLocation(incomingItemContent.getLocation());
879 }
880 if (incomingItemContent.getCallNumber() != null) {
881 existingItemContent.setCallNumber(incomingItemContent.getCallNumber());
882 }
883 if (StringUtils.isNotBlank(incomingItemContent.getChronology())) {
884 existingItemContent.setChronology(incomingItemContent.getChronology());
885 }
886 if (StringUtils.isNotBlank(incomingItemContent.getEnumeration())) {
887 existingItemContent.setEnumeration(incomingItemContent.getEnumeration());
888 }
889 if (StringUtils.isNotBlank(incomingItemContent.getCopyNumber())) {
890 existingItemContent.setCopyNumber(incomingItemContent.getCopyNumber());
891 }
892 if (incomingItemContent.getItemStatus() != null) {
893 existingItemContent.setItemStatus(incomingItemContent.getItemStatus());
894 }
895 if (incomingItemContent.getItemType() != null) {
896 existingItemContent.setItemType(incomingItemContent.getItemType());
897 }
898 if (StringUtils.isNotBlank(incomingItemContent.getBarcodeARSL())) {
899 existingItemContent.setBarcodeARSL(incomingItemContent.getBarcodeARSL());
900 }
901 if (StringUtils.isNotBlank(incomingItemContent.getVolumeNumber())) {
902 existingItemContent.setVolumeNumber(incomingItemContent.getVolumeNumber());
903 }
904 if (StringUtils.isNotBlank(incomingItemContent.getCheckinNote())) {
905 existingItemContent.setCheckinNote(incomingItemContent.getCheckinNote());
906 }
907 if (StringUtils.isNotBlank(incomingItemContent.getCurrentBorrower())) {
908 existingItemContent.setCurrentBorrower(incomingItemContent.getCurrentBorrower());
909 }
910 if (StringUtils.isNotBlank(incomingItemContent.getClaimsReturnedFlagCreateDate())) {
911 existingItemContent.setClaimsReturnedFlagCreateDate(incomingItemContent.getClaimsReturnedFlagCreateDate());
912 }
913 if (StringUtils.isNotBlank(incomingItemContent.getAnalytic())) {
914 existingItemContent.setAnalytic(incomingItemContent.getAnalytic());
915 }
916 if (StringUtils.isNotBlank(incomingItemContent.getDueDateTime())) {
917 existingItemContent.setDueDateTime(incomingItemContent.getDueDateTime());
918 }
919 if (StringUtils.isNotBlank(incomingItemContent.getDamagedItemNote())) {
920 existingItemContent.setDamagedItemNote(incomingItemContent.getDamagedItemNote());
921 }
922 if (StringUtils.isNotBlank(incomingItemContent.getItemStatusEffectiveDate())) {
923 existingItemContent.setItemStatusEffectiveDate(incomingItemContent.getItemStatusEffectiveDate());
924 }
925 if (StringUtils.isNotBlank(incomingItemContent.getMissingPieceEffectiveDate())) {
926 existingItemContent.setMissingPieceEffectiveDate(incomingItemContent.getMissingPieceEffectiveDate());
927 }
928 if (StringUtils.isNotBlank(incomingItemContent.getClaimsReturnedNote())) {
929 existingItemContent.setClaimsReturnedNote(incomingItemContent.getClaimsReturnedNote());
930 }
931 if (StringUtils.isNotBlank(incomingItemContent.getProxyBorrower())) {
932 existingItemContent.setProxyBorrower(incomingItemContent.getProxyBorrower());
933 }
934 if (StringUtils.isNotBlank(incomingItemContent.getMissingPieceFlagNote())) {
935 existingItemContent.setMissingPieceFlagNote(incomingItemContent.getMissingPieceFlagNote());
936 }
937 if (StringUtils.isNotBlank(incomingItemContent.getMissingPiecesCount())) {
938 existingItemContent.setMissingPiecesCount(incomingItemContent.getMissingPiecesCount());
939 }
940 if (incomingItemContent.getAccessInformation() != null) {
941 if(StringUtils.isNotBlank(incomingItemContent.getAccessInformation().getBarcode())) {
942 existingItemContent.getAccessInformation().setBarcode(incomingItemContent.getAccessInformation().getBarcode());
943 }
944 if(incomingItemContent.getAccessInformation().getUri()!=null){
945 existingItemContent.getAccessInformation().setUri(incomingItemContent.getAccessInformation().getUri());
946 }
947 }
948 if (incomingItemContent.getTemporaryItemType() != null) {
949 existingItemContent.setTemporaryItemType(incomingItemContent.getTemporaryItemType());
950 }
951 if (incomingItemContent.getStatisticalSearchingCode() != null) {
952 existingItemContent.setStatisticalSearchingCode(incomingItemContent.getStatisticalSearchingCode());
953 }
954 if (incomingItemContent.getNumberOfCirculations() != null) {
955 existingItemContent.setNumberOfCirculations(incomingItemContent.getNumberOfCirculations());
956 }
957 if (incomingItemContent.getDonorInfo() != null) {
958 existingItemContent.setDonorInfo(incomingItemContent.getDonorInfo());
959 }
960 if (incomingItemContent.getMissingPieceItemRecordList() != null) {
961 existingItemContent.setMissingPieceItemRecordList(incomingItemContent.getMissingPieceItemRecordList());
962 }
963 if(incomingItemContent.getItemClaimsReturnedRecords() != null){
964 existingItemContent.setItemClaimsReturnedRecords(incomingItemContent.getItemClaimsReturnedRecords());
965 }
966 if(incomingItemContent.getItemDamagedRecords() != null){
967 existingItemContent.setItemDamagedRecords(incomingItemContent.getItemDamagedRecords());
968 }
969 if (incomingItemContent.getHighDensityStorage() != null) {
970 existingItemContent.setHighDensityStorage(incomingItemContent.getHighDensityStorage());
971 }
972 if (incomingItemContent.getNote() != null) {
973 existingItemContent.setNote(incomingItemContent.getNote());
974 }
975 if (incomingItemContent.getFormerIdentifier() != null) {
976 existingItemContent.setFormerIdentifier(incomingItemContent.getFormerIdentifier());
977 }
978 if (StringUtils.isNotBlank(incomingItemContent.getVolumeNumberLabel())) {
979 existingItemContent.setVolumeNumberLabel(incomingItemContent.getVolumeNumberLabel());
980 }
981 if (StringUtils.isNotBlank(incomingItemContent.getVendorLineItemIdentifier())) {
982 existingItemContent.setVendorLineItemIdentifier(incomingItemContent.getVendorLineItemIdentifier());
983 }
984 if (StringUtils.isNotBlank(incomingItemContent.getPurchaseOrderLineItemIdentifier())) {
985 existingItemContent.setPurchaseOrderLineItemIdentifier(incomingItemContent.getPurchaseOrderLineItemIdentifier());
986 }
987 if (StringUtils.isNotBlank(incomingItemContent.getResourceIdentifier())) {
988 existingItemContent.setResourceIdentifier(incomingItemContent.getResourceIdentifier());
989 }
990 if (incomingItemContent.isStaffOnlyFlag() != existingItemContent.isStaffOnlyFlag()) {
991 existingItemContent.setStaffOnlyFlag(incomingItemContent.isStaffOnlyFlag());
992 this.setStaffOnly(incomingItemContent.isStaffOnlyFlag());
993
994 }
995 this.setContent(itemOlemlRecordProcessor.toXML(existingItemContent));
996 }
997
998
999 public void setDefaultField(String docField, String fieldValue) {
1000
1001 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) getContentObject();
1002
1003
1004 if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_ITEM_BARCODE)) {
1005 if (itemPojo.getAccessInformation() == null) {
1006 AccessInformation accessInformation = new AccessInformation();
1007 itemPojo.setAccessInformation(accessInformation);
1008 }
1009
1010 if (itemPojo.getAccessInformation().getBarcode() == null) {
1011 itemPojo.getAccessInformation().setBarcode(fieldValue);
1012 }
1013
1014 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) {
1015
1016 buildItemCallNumber(itemPojo);
1017 itemPojo.getCallNumber().setNumber(fieldValue);
1018 String callNumberType = itemPojo.getCallNumber().getShelvingScheme().getCodeValue();
1019 if(StringUtils.isEmpty(callNumberType)) {
1020 itemPojo.getCallNumber().getShelvingScheme().setCodeValue("NONE");
1021 }
1022 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE) ) {
1023 buildItemCallNumber(itemPojo);
1024 if (itemPojo.getCallNumber().getShelvingScheme().getCodeValue() == null || !isDataMappingFlag()) {
1025 itemPojo.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
1026 }
1027
1028 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) {
1029 buildItemCallNumber(itemPojo);
1030 if (itemPojo.getCallNumber().getPrefix() == null) {
1031 itemPojo.getCallNumber().setPrefix(fieldValue);
1032 }
1033
1034 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) {
1035 if (itemPojo.getCopyNumber() == null) {
1036 itemPojo.setCopyNumber(fieldValue);
1037 }
1038
1039 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_TYPE)) {
1040 ItemType itemType1 = new ItemType();
1041 itemType1.setCodeValue(fieldValue);
1042 itemPojo.setItemType(itemType1);
1043 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER)) {
1044 setHoldingsCallNumber(fieldValue);
1045
1046 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) {
1047 if (getLevel1Location() == null) {
1048 setLocationLevel1(fieldValue);
1049 }
1050
1051 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) {
1052 if (getLevel2Location() == null) {
1053 setLocationLevel2(fieldValue);
1054 }
1055 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) {
1056 if (getLevel3Location() == null) {
1057 setLocationLevel3(fieldValue);
1058 }
1059 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) {
1060 if (getLevel4Location() == null) {
1061 setLocationLevel4(fieldValue);
1062 }
1063 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) {
1064 if (getLevel5Location() == null) {
1065 setLocationLevel5(fieldValue);
1066 }
1067 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE)) {
1068 setHoldingsCallNumberType(fieldValue);
1069 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1)) {
1070 setHoldingsLocationLevel1(fieldValue);
1071 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2)) {
1072 setHoldingsLocationLevel2(fieldValue);
1073 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3)) {
1074 setHoldingsLocationLevel3(fieldValue);
1075 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4)) {
1076 setHoldingsLocationLevel4(fieldValue);
1077 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5)) {
1078 setHoldingsLocationLevel5(fieldValue);
1079 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER)) {
1080 setHoldingsCopyNumber(fieldValue);
1081 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX)) {
1082 setHoldingsCallNumberPrefix(fieldValue);
1083 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_STATUS)) {
1084 if(itemPojo.getItemStatus() == null){
1085 ItemStatus itemStatus1 = new ItemStatus();
1086 itemStatus1.setCodeValue(fieldValue);
1087 itemPojo.setItemStatus(itemStatus1);
1088 }
1089 } else if (docField.equalsIgnoreCase(ENUMERATION)) {
1090 if (itemPojo.getEnumeration() == null) {
1091 itemPojo.setEnumeration(fieldValue);
1092 }
1093 } else if (docField.equalsIgnoreCase(CHRONOLOGY)) {
1094 if (itemPojo.getChronology() == null) {
1095 itemPojo.setChronology(fieldValue);
1096 }
1097 } else if (docField.equalsIgnoreCase(VENDOR_LINE_ITEM_IDENTIFIER)) {
1098 if (itemPojo.getVendorLineItemIdentifier() == null) {
1099 itemPojo.setVendorLineItemIdentifier(fieldValue);
1100 }
1101 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_CODE) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_PUBLIC_DISPLAY) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_NOTE)) {
1102 DonorInfo donorInfo = null;
1103 if (itemPojo.getDonorInfo().size() > 0) {
1104 for (DonorInfo donorInfo1 : itemPojo.getDonorInfo()) {
1105 buildDonorInfo(docField, fieldValue, itemPojo, donorInfo1, true);
1106 }
1107 } else {
1108 donorInfo = new DonorInfo();
1109 buildDonorInfo(docField, fieldValue, itemPojo, donorInfo, true);
1110 }
1111 }
1112
1113 }
1114
1115
1116 public String getItemHoldingsDataMappingValue(Map<String, String> itemDocFields) {
1117
1118 StringBuilder itemDataValue = new StringBuilder();
1119
1120
1121 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER) && getHoldingsCallNumber() != null) {
1122 itemDataValue.append(getHoldingsCallNumber());
1123 }
1124
1125 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX) && getHoldingsCallNumberPrefix() != null) {
1126 itemDataValue.append(getHoldingsCallNumberPrefix());
1127 }
1128 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE) && getHoldingsCallNumberType() != null) {
1129 itemDataValue.append(getHoldingsCallNumberType());
1130 }
1131
1132 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER) && getHoldingsCopyNumber() != null) {
1133 itemDataValue.append(getHoldingsCopyNumber());
1134 }
1135
1136 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1) && getHoldingsLocationLevel1() != null) {
1137 itemDataValue.append(getHoldingsLocationLevel1());
1138 }
1139 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2) && getHoldingsLocationLevel2() != null) {
1140 itemDataValue.append(getHoldingsLocationLevel2());
1141 }
1142 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3) && getHoldingsLocationLevel3() != null) {
1143 itemDataValue.append(getHoldingsLocationLevel3());
1144 }
1145 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4) && getHoldingsLocationLevel4() != null) {
1146 itemDataValue.append(getHoldingsLocationLevel4());
1147 }
1148 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5) && getHoldingsLocationLevel5() != null) {
1149 itemDataValue.append(getHoldingsLocationLevel5());
1150
1151 }
1152 return itemDataValue.toString();
1153 }
1154
1155
1156 public String getHoldingsCallNumber() {
1157 return holdingsCallNumber;
1158 }
1159
1160 public void setHoldingsCallNumber(String holdingsCallNumber) {
1161 this.holdingsCallNumber = holdingsCallNumber;
1162 }
1163
1164 public String getHoldingsCallNumberType() {
1165 return holdingsCallNumberType;
1166 }
1167
1168 public void setHoldingsCallNumberType(String holdingsCallNumberType) {
1169 this.holdingsCallNumberType = holdingsCallNumberType;
1170 }
1171
1172 public String getHoldingsCopyNumber() {
1173 return holdingsCopyNumber;
1174 }
1175
1176 public void setHoldingsCopyNumber(String holdingsCopyNumber) {
1177 this.holdingsCopyNumber = holdingsCopyNumber;
1178 }
1179
1180 public String getHoldingsCallNumberPrefix() {
1181 return holdingsCallNumberPrefix;
1182 }
1183
1184 public void setHoldingsCallNumberPrefix(String holdingsCallNumberPrefix) {
1185 this.holdingsCallNumberPrefix = holdingsCallNumberPrefix;
1186 }
1187
1188 public String getHoldingsLocationLevel1() {
1189 return holdingsLocationLevel1;
1190 }
1191
1192 public void setHoldingsLocationLevel1(String holdingsLocationLevel1) {
1193 this.holdingsLocationLevel1 = holdingsLocationLevel1;
1194 }
1195
1196 public String getHoldingsLocationLevel2() {
1197 return holdingsLocationLevel2;
1198 }
1199
1200 public void setHoldingsLocationLevel2(String holdingsLocationLevel2) {
1201 this.holdingsLocationLevel2 = holdingsLocationLevel2;
1202 }
1203
1204 public String getHoldingsLocationLevel3() {
1205 return holdingsLocationLevel3;
1206 }
1207
1208 public void setHoldingsLocationLevel3(String holdingsLocationLevel3) {
1209 this.holdingsLocationLevel3 = holdingsLocationLevel3;
1210 }
1211
1212 public String getHoldingsLocationLevel4() {
1213 return holdingsLocationLevel4;
1214 }
1215
1216 public void setHoldingsLocationLevel4(String holdingsLocationLevel4) {
1217 this.holdingsLocationLevel4 = holdingsLocationLevel4;
1218 }
1219
1220 public String getHoldingsLocationLevel5() {
1221 return holdingsLocationLevel5;
1222 }
1223
1224 public void setHoldingsLocationLevel5(String holdingsLocationLevel5) {
1225 this.holdingsLocationLevel5 = holdingsLocationLevel5;
1226 }
1227 }