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