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
12 import javax.xml.bind.JAXBContext;
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 StringWriter sw = new StringWriter();
588 Item item = (Item) object;
589 try {
590 JAXBContext jaxbContext = JAXBContext.newInstance(Item.class);
591 Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
592 jaxbMarshaller.marshal(item, sw);
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
603 JAXBElement<Item> itemElement = null;
604 try {
605 JAXBContext jaxbContext = JAXBContext.newInstance(Item.class);
606 Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
607 ByteArrayInputStream input = new ByteArrayInputStream(content.getBytes("UTF-8"));
608 itemElement = jaxbUnmarshaller.unmarshal(new StreamSource(input), Item.class);
609 } catch (Exception e) {
610 LOG.error("Exception ", e);
611 }
612 return itemElement.getValue();
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.getHighDensityStorage() != null) {
961 existingItemContent.setHighDensityStorage(incomingItemContent.getHighDensityStorage());
962 }
963 if (incomingItemContent.getNote() != null) {
964 existingItemContent.setNote(incomingItemContent.getNote());
965 }
966 if (incomingItemContent.getFormerIdentifier() != null) {
967 existingItemContent.setFormerIdentifier(incomingItemContent.getFormerIdentifier());
968 }
969 if (StringUtils.isNotBlank(incomingItemContent.getVolumeNumberLabel())) {
970 existingItemContent.setVolumeNumberLabel(incomingItemContent.getVolumeNumberLabel());
971 }
972 if (StringUtils.isNotBlank(incomingItemContent.getVendorLineItemIdentifier())) {
973 existingItemContent.setVendorLineItemIdentifier(incomingItemContent.getVendorLineItemIdentifier());
974 }
975 if (StringUtils.isNotBlank(incomingItemContent.getPurchaseOrderLineItemIdentifier())) {
976 existingItemContent.setPurchaseOrderLineItemIdentifier(incomingItemContent.getPurchaseOrderLineItemIdentifier());
977 }
978 if (StringUtils.isNotBlank(incomingItemContent.getResourceIdentifier())) {
979 existingItemContent.setResourceIdentifier(incomingItemContent.getResourceIdentifier());
980 }
981 if (incomingItemContent.isStaffOnlyFlag() != existingItemContent.isStaffOnlyFlag()) {
982 existingItemContent.setStaffOnlyFlag(incomingItemContent.isStaffOnlyFlag());
983 this.setStaffOnly(incomingItemContent.isStaffOnlyFlag());
984
985 }
986 this.setContent(itemOlemlRecordProcessor.toXML(existingItemContent));
987 }
988
989
990 public void setDefaultField(String docField, String fieldValue) {
991
992 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) getContentObject();
993
994
995 if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_ITEM_BARCODE)) {
996 if (itemPojo.getAccessInformation() == null) {
997 AccessInformation accessInformation = new AccessInformation();
998 itemPojo.setAccessInformation(accessInformation);
999 }
1000
1001 if (itemPojo.getAccessInformation().getBarcode() == null) {
1002 itemPojo.getAccessInformation().setBarcode(fieldValue);
1003 }
1004
1005 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) {
1006
1007 buildItemCallNumber(itemPojo);
1008 itemPojo.getCallNumber().setNumber(fieldValue);
1009 String callNumberType = itemPojo.getCallNumber().getShelvingScheme().getCodeValue();
1010 if(StringUtils.isEmpty(callNumberType)) {
1011 itemPojo.getCallNumber().getShelvingScheme().setCodeValue("NONE");
1012 }
1013 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE) ) {
1014 buildItemCallNumber(itemPojo);
1015 if (itemPojo.getCallNumber().getShelvingScheme().getCodeValue() == null || !isDataMappingFlag()) {
1016 itemPojo.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
1017 }
1018
1019 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) {
1020 buildItemCallNumber(itemPojo);
1021 if (itemPojo.getCallNumber().getPrefix() == null) {
1022 itemPojo.getCallNumber().setPrefix(fieldValue);
1023 }
1024
1025 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) {
1026 if (itemPojo.getCopyNumber() == null) {
1027 itemPojo.setCopyNumber(fieldValue);
1028 }
1029
1030 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_TYPE)) {
1031 ItemType itemType1 = new ItemType();
1032 itemType1.setCodeValue(fieldValue);
1033 itemPojo.setItemType(itemType1);
1034 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER)) {
1035 setHoldingsCallNumber(fieldValue);
1036
1037 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) {
1038 if (getLevel1Location() == null) {
1039 setLocationLevel1(fieldValue);
1040 }
1041
1042 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) {
1043 if (getLevel2Location() == null) {
1044 setLocationLevel2(fieldValue);
1045 }
1046 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) {
1047 if (getLevel3Location() == null) {
1048 setLocationLevel3(fieldValue);
1049 }
1050 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) {
1051 if (getLevel4Location() == null) {
1052 setLocationLevel4(fieldValue);
1053 }
1054 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) {
1055 if (getLevel5Location() == null) {
1056 setLocationLevel5(fieldValue);
1057 }
1058 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE)) {
1059 setHoldingsCallNumberType(fieldValue);
1060 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1)) {
1061 setHoldingsLocationLevel1(fieldValue);
1062 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2)) {
1063 setHoldingsLocationLevel2(fieldValue);
1064 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3)) {
1065 setHoldingsLocationLevel3(fieldValue);
1066 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4)) {
1067 setHoldingsLocationLevel4(fieldValue);
1068 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5)) {
1069 setHoldingsLocationLevel5(fieldValue);
1070 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER)) {
1071 setHoldingsCopyNumber(fieldValue);
1072 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX)) {
1073 setHoldingsCallNumberPrefix(fieldValue);
1074 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_STATUS)) {
1075 if(itemPojo.getItemStatus() == null){
1076 ItemStatus itemStatus1 = new ItemStatus();
1077 itemStatus1.setCodeValue(fieldValue);
1078 itemPojo.setItemStatus(itemStatus1);
1079 }
1080 } else if (docField.equalsIgnoreCase(ENUMERATION)) {
1081 if (itemPojo.getEnumeration() == null) {
1082 itemPojo.setEnumeration(fieldValue);
1083 }
1084 } else if (docField.equalsIgnoreCase(CHRONOLOGY)) {
1085 if (itemPojo.getChronology() == null) {
1086 itemPojo.setChronology(fieldValue);
1087 }
1088 } else if (docField.equalsIgnoreCase(VENDOR_LINE_ITEM_IDENTIFIER)) {
1089 if (itemPojo.getVendorLineItemIdentifier() == null) {
1090 itemPojo.setVendorLineItemIdentifier(fieldValue);
1091 }
1092 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_CODE) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_PUBLIC_DISPLAY) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_NOTE)) {
1093 DonorInfo donorInfo = null;
1094 if (itemPojo.getDonorInfo().size() > 0) {
1095 for (DonorInfo donorInfo1 : itemPojo.getDonorInfo()) {
1096 buildDonorInfo(docField, fieldValue, itemPojo, donorInfo1, true);
1097 }
1098 } else {
1099 donorInfo = new DonorInfo();
1100 buildDonorInfo(docField, fieldValue, itemPojo, donorInfo, true);
1101 }
1102 }
1103
1104 }
1105
1106
1107 public String getItemHoldingsDataMappingValue(Map<String, String> itemDocFields) {
1108
1109 StringBuilder itemDataValue = new StringBuilder();
1110
1111
1112 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER) && getHoldingsCallNumber() != null) {
1113 itemDataValue.append(getHoldingsCallNumber());
1114 }
1115
1116 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX) && getHoldingsCallNumberPrefix() != null) {
1117 itemDataValue.append(getHoldingsCallNumberPrefix());
1118 }
1119 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE) && getHoldingsCallNumberType() != null) {
1120 itemDataValue.append(getHoldingsCallNumberType());
1121 }
1122
1123 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER) && getHoldingsCopyNumber() != null) {
1124 itemDataValue.append(getHoldingsCopyNumber());
1125 }
1126
1127 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1) && getHoldingsLocationLevel1() != null) {
1128 itemDataValue.append(getHoldingsLocationLevel1());
1129 }
1130 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2) && getHoldingsLocationLevel2() != null) {
1131 itemDataValue.append(getHoldingsLocationLevel2());
1132 }
1133 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3) && getHoldingsLocationLevel3() != null) {
1134 itemDataValue.append(getHoldingsLocationLevel3());
1135 }
1136 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4) && getHoldingsLocationLevel4() != null) {
1137 itemDataValue.append(getHoldingsLocationLevel4());
1138 }
1139 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5) && getHoldingsLocationLevel5() != null) {
1140 itemDataValue.append(getHoldingsLocationLevel5());
1141
1142 }
1143 return itemDataValue.toString();
1144 }
1145
1146
1147 public String getHoldingsCallNumber() {
1148 return holdingsCallNumber;
1149 }
1150
1151 public void setHoldingsCallNumber(String holdingsCallNumber) {
1152 this.holdingsCallNumber = holdingsCallNumber;
1153 }
1154
1155 public String getHoldingsCallNumberType() {
1156 return holdingsCallNumberType;
1157 }
1158
1159 public void setHoldingsCallNumberType(String holdingsCallNumberType) {
1160 this.holdingsCallNumberType = holdingsCallNumberType;
1161 }
1162
1163 public String getHoldingsCopyNumber() {
1164 return holdingsCopyNumber;
1165 }
1166
1167 public void setHoldingsCopyNumber(String holdingsCopyNumber) {
1168 this.holdingsCopyNumber = holdingsCopyNumber;
1169 }
1170
1171 public String getHoldingsCallNumberPrefix() {
1172 return holdingsCallNumberPrefix;
1173 }
1174
1175 public void setHoldingsCallNumberPrefix(String holdingsCallNumberPrefix) {
1176 this.holdingsCallNumberPrefix = holdingsCallNumberPrefix;
1177 }
1178
1179 public String getHoldingsLocationLevel1() {
1180 return holdingsLocationLevel1;
1181 }
1182
1183 public void setHoldingsLocationLevel1(String holdingsLocationLevel1) {
1184 this.holdingsLocationLevel1 = holdingsLocationLevel1;
1185 }
1186
1187 public String getHoldingsLocationLevel2() {
1188 return holdingsLocationLevel2;
1189 }
1190
1191 public void setHoldingsLocationLevel2(String holdingsLocationLevel2) {
1192 this.holdingsLocationLevel2 = holdingsLocationLevel2;
1193 }
1194
1195 public String getHoldingsLocationLevel3() {
1196 return holdingsLocationLevel3;
1197 }
1198
1199 public void setHoldingsLocationLevel3(String holdingsLocationLevel3) {
1200 this.holdingsLocationLevel3 = holdingsLocationLevel3;
1201 }
1202
1203 public String getHoldingsLocationLevel4() {
1204 return holdingsLocationLevel4;
1205 }
1206
1207 public void setHoldingsLocationLevel4(String holdingsLocationLevel4) {
1208 this.holdingsLocationLevel4 = holdingsLocationLevel4;
1209 }
1210
1211 public String getHoldingsLocationLevel5() {
1212 return holdingsLocationLevel5;
1213 }
1214
1215 public void setHoldingsLocationLevel5(String holdingsLocationLevel5) {
1216 this.holdingsLocationLevel5 = holdingsLocationLevel5;
1217 }
1218 }