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 DUE_DATE_TIME = "DUEDATETIME";
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 synchronized (jaxbMarshaller) {
592 jaxbMarshaller.marshal(item, sw);
593 }
594 result = sw.toString();
595 } catch (Exception e) {
596 LOG.error("Exception ", e);
597 }
598 return result;
599 }
600
601 @Override
602 public Object deserialize(String content) {
603 Item item = new Item();
604 try {
605 Unmarshaller unmarshaller = JAXBContextFactory.getInstance().getUnMarshaller(Item.class);
606 ByteArrayInputStream input = new ByteArrayInputStream(content.getBytes("UTF-8"));
607 synchronized (unmarshaller) {
608 item = unmarshaller.unmarshal(new StreamSource(input), Item.class).getValue();
609 }
610 } catch (Exception e) {
611 LOG.error("Exception ", e);
612 }
613 return item;
614 }
615
616 @Override
617 public Object deserializeContent(Object object) {
618
619
620 return null;
621 }
622
623 @Override
624 public Object deserializeContent(String content) {
625 return null;
626 }
627
628 @Override
629 public String serializeContent(Object object) {
630 if (object == null) {
631 object = getContentObject();
632 }
633 LocationLevel locationLevel1 = new LocationLevel();
634 LocationLevel locationLevel2 = new LocationLevel();
635 LocationLevel locationLevel3 = new LocationLevel();
636 LocationLevel locationLevel4 = new LocationLevel();
637 LocationLevel locationLevel5 = new LocationLevel();
638
639 locationLevel1.setName(getLocationLevel1());
640 locationLevel2.setName(getLocationLevel2());
641 locationLevel3.setName(getLocationLevel3());
642 locationLevel4.setName(getLocationLevel4());
643 locationLevel5.setName(getLocationLevel5());
644 locationLevel1.setLocationLevel(locationLevel2);
645 locationLevel2.setLocationLevel(locationLevel3);
646 locationLevel3.setLocationLevel(locationLevel4);
647 locationLevel4.setLocationLevel(locationLevel5);
648 Location locationPojo = new Location();
649 locationPojo.setLocationLevel(locationLevel1);
650 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) object;
651 itemPojo.setLocation(locationPojo);
652 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
653 String itemXml = itemOlemlRecordProcessor.toXML(itemPojo);
654 return itemXml;
655 }
656
657 public void serializeContent() {
658 if (contentObject == null) {
659 return;
660 }
661 Location locationPojo = buildLocationObj();
662 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) contentObject;
663 itemPojo.setLocation(locationPojo);
664 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
665 content = itemOlemlRecordProcessor.toXML(itemPojo);
666 }
667
668 public void setField(String docField, String fieldValue) {
669 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) getContentObject();
670
671
672 if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_ITEM_BARCODE)) {
673 if (itemPojo.getAccessInformation() == null) {
674 AccessInformation accessInformation = new AccessInformation();
675 itemPojo.setAccessInformation(accessInformation);
676 }
677 itemPojo.getAccessInformation().setBarcode(fieldValue);
678 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) {
679
680 buildItemCallNumber(itemPojo);
681 itemPojo.getCallNumber().setNumber(fieldValue);
682 String callNumberType = itemPojo.getCallNumber().getShelvingScheme().getCodeValue();
683 if(StringUtils.isEmpty(callNumberType) || callNumberType.equals(NO_INFO_CALL_NUMBER_TYPE_CODE)) {
684 itemPojo.getCallNumber().getShelvingScheme().setCodeValue("NONE");
685 }
686 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE)) {
687 buildItemCallNumber(itemPojo);
688 itemPojo.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
689 setDataMappingFlag(true);
690 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) {
691 buildItemCallNumber(itemPojo);
692 itemPojo.getCallNumber().setPrefix(fieldValue);
693 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) {
694 itemPojo.setCopyNumber(fieldValue);
695 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_TYPE)) {
696 ItemType itemType1 = new ItemType();
697 itemType1.setCodeValue(fieldValue);
698 itemPojo.setItemType(itemType1);
699 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER)) {
700 setHoldingsCallNumber(fieldValue);
701 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) {
702 setLocationLevel1(fieldValue);
703 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) {
704 setLocationLevel2(fieldValue);
705 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) {
706 setLocationLevel3(fieldValue);
707 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) {
708 setLocationLevel4(fieldValue);
709 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) {
710 setLocationLevel5(fieldValue);
711 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE)) {
712 setHoldingsCallNumberType(fieldValue);
713 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1)) {
714 setHoldingsLocationLevel1(fieldValue);
715 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2)) {
716 setHoldingsLocationLevel2(fieldValue);
717 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3)) {
718 setHoldingsLocationLevel3(fieldValue);
719 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4)) {
720 setHoldingsLocationLevel4(fieldValue);
721 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5)) {
722 setHoldingsLocationLevel5(fieldValue);
723 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER)) {
724 setHoldingsCopyNumber(fieldValue);
725 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX)) {
726 setHoldingsCallNumberPrefix(fieldValue);
727 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_STATUS)) {
728 ItemStatus itemStatus1 = new ItemStatus();
729 itemStatus1.setCodeValue(fieldValue);
730 itemPojo.setItemStatus(itemStatus1);
731 } else if (docField.equalsIgnoreCase(ENUMERATION)) {
732 itemPojo.setEnumeration(fieldValue);
733 } else if (docField.equalsIgnoreCase(CHRONOLOGY)) {
734 itemPojo.setChronology(fieldValue);
735 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_VENDOR_LINE_ITEM_IDENTIFIER)) {
736 itemPojo.setVendorLineItemIdentifier(fieldValue);
737 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_CODE) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_PUBLIC_DISPLAY) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_NOTE)) {
738 DonorInfo donorInfo = null;
739 if (itemPojo.getDonorInfo() != null && itemPojo.getDonorInfo().size() > 0) {
740 for (DonorInfo existingDonorInfo : itemPojo.getDonorInfo()) {
741 buildDonorInfo(docField, fieldValue, itemPojo, existingDonorInfo, false);
742 }
743 } else {
744 donorInfo = new DonorInfo();
745 buildDonorInfo(docField, fieldValue, itemPojo, donorInfo, false);
746 }
747 }
748 }
749
750 private void buildDonorInfo(String docField, String fieldValue, org.kuali.ole.docstore.common.document.content.instance.Item itemPojo, DonorInfo donorInfo, boolean isDefault) {
751 if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_CODE)) {
752 if (donorInfo.getDonorCode() == null) {
753 donorInfo.setDonorCode(fieldValue);
754 } else if (!isDefault) {
755 donorInfo.setDonorCode(fieldValue);
756 }
757 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_PUBLIC_DISPLAY)) {
758 if (donorInfo.getDonorPublicDisplay() == null) {
759 donorInfo.setDonorPublicDisplay(fieldValue);
760 } else if (!isDefault) {
761 donorInfo.setDonorPublicDisplay(fieldValue);
762 }
763 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_NOTE)) {
764 if (donorInfo.getDonorNote() == null) {
765 donorInfo.setDonorNote(fieldValue);
766 } else if (!isDefault) {
767 donorInfo.setDonorNote(fieldValue);
768 }
769 }
770 if (itemPojo.getDonorInfo() == null || itemPojo.getDonorInfo().size() == 0) {
771 itemPojo.getDonorInfo().add(donorInfo);
772 }
773 }
774
775 private void buildItemCallNumber(org.kuali.ole.docstore.common.document.content.instance.Item itemPojo) {
776 if (itemPojo.getCallNumber() == null) {
777 CallNumber callNumberPojo = new CallNumber();
778 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
779 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
780 callNumberPojo.setShelvingScheme(shelvingScheme1);
781 callNumberPojo.setShelvingOrder(shelvingOrder1);
782 itemPojo.setCallNumber(callNumberPojo);
783 } else {
784 if (itemPojo.getCallNumber().getShelvingOrder() == null) {
785 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
786 itemPojo.getCallNumber().setShelvingOrder(shelvingOrder1);
787 }
788 if (itemPojo.getCallNumber().getShelvingScheme() == null) {
789 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
790 itemPojo.getCallNumber().setShelvingScheme(shelvingScheme1);
791 }
792 }
793 }
794
795 public Object getContentObject() {
796 if (contentObject == null) {
797 contentObject = new org.kuali.ole.docstore.common.document.content.instance.Item();
798 if (content != null) {
799 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
800 contentObject = itemOlemlRecordProcessor.fromXML(content);
801 }
802 }
803 return contentObject;
804 }
805
806
807 public Location buildLocationObj() {
808
809 LocationLevel locationLevel1 = new LocationLevel();
810 locationLevel1.setName(getLocationLevel1());
811 locationLevel1.setLevel(getLevel1Location());
812 LocationLevel locationLevel2 = new LocationLevel();
813 locationLevel2.setName(getLocationLevel2());
814 locationLevel2.setLevel(getLevel2Location());
815 LocationLevel locationLevel3 = new LocationLevel();
816 locationLevel3.setName(getLocationLevel3());
817 locationLevel3.setLevel(getLevel3Location());
818 LocationLevel locationLevel4 = new LocationLevel();
819 locationLevel4.setName(getLocationLevel4());
820 locationLevel4.setLevel(getLevel4Location());
821 LocationLevel locationLevel5 = new LocationLevel();
822 locationLevel5.setName(getLocationLevel5());
823 locationLevel5.setLevel(getLevel5Location());
824
825 List<LocationLevel> locationLevels = new ArrayList<>();
826
827 if (StringUtils.isNotEmpty(locationLevel1.getName())) {
828 locationLevels.add(locationLevel1);
829 }
830 if (StringUtils.isNotEmpty(locationLevel2.getName())) {
831 locationLevels.add(locationLevel2);
832 }
833 if (StringUtils.isNotEmpty(locationLevel3.getName())) {
834 locationLevels.add(locationLevel3);
835 }
836 if (StringUtils.isNotEmpty(locationLevel4.getName())) {
837 locationLevels.add(locationLevel4);
838 }
839 if (StringUtils.isNotEmpty(locationLevel5.getName())) {
840 locationLevels.add(locationLevel5);
841 }
842
843 int locationLevelSize = locationLevels.size();
844
845 for (int i = 0; i < locationLevelSize; i++) {
846 if ((locationLevelSize - 1) != i) {
847 locationLevels.get(i).setLocationLevel(locationLevels.get(i + 1));
848 }
849 }
850
851 Location locationPojo = new Location();
852 if (locationLevels.size() > 0) {
853 locationPojo.setLocationLevel(locationLevels.get(0));
854 }
855
856 return locationPojo;
857 }
858
859
860 @Override
861 public int compareTo(Item o) {
862 return this.getSortedValue().compareTo(o.getSortedValue());
863 }
864
865
866 public void setItem(Item itemIncoming) throws ConversionException {
867 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
868 org.kuali.ole.docstore.common.document.content.instance.Item incomingItemContent = itemOlemlRecordProcessor.fromXML(itemIncoming.getContent());
869 org.kuali.ole.docstore.common.document.content.instance.Item existingItemContent = itemOlemlRecordProcessor.fromXML(this.getContent());
870
871 this.setId(existingItemContent.getItemIdentifier());
872
873 if (StringUtils.isNotBlank(itemIncoming.getUpdatedBy())) {
874 this.updatedBy = itemIncoming.getUpdatedBy();
875 } else {
876 this.updatedBy = "UNKNOWN";
877 }
878 if (incomingItemContent.getLocation() != null) {
879 existingItemContent.setLocation(incomingItemContent.getLocation());
880 }
881 if (incomingItemContent.getCallNumber() != null) {
882 existingItemContent.setCallNumber(incomingItemContent.getCallNumber());
883 }
884 if (StringUtils.isNotBlank(incomingItemContent.getChronology())) {
885 existingItemContent.setChronology(incomingItemContent.getChronology());
886 }
887 if (StringUtils.isNotBlank(incomingItemContent.getEnumeration())) {
888 existingItemContent.setEnumeration(incomingItemContent.getEnumeration());
889 }
890 if (StringUtils.isNotBlank(incomingItemContent.getCopyNumber())) {
891 existingItemContent.setCopyNumber(incomingItemContent.getCopyNumber());
892 }
893 if (incomingItemContent.getItemStatus() != null) {
894 existingItemContent.setItemStatus(incomingItemContent.getItemStatus());
895 }
896 if (incomingItemContent.getItemType() != null) {
897 existingItemContent.setItemType(incomingItemContent.getItemType());
898 }
899 if (StringUtils.isNotBlank(incomingItemContent.getBarcodeARSL())) {
900 existingItemContent.setBarcodeARSL(incomingItemContent.getBarcodeARSL());
901 }
902 if (StringUtils.isNotBlank(incomingItemContent.getVolumeNumber())) {
903 existingItemContent.setVolumeNumber(incomingItemContent.getVolumeNumber());
904 }
905 if (StringUtils.isNotBlank(incomingItemContent.getCheckinNote())) {
906 existingItemContent.setCheckinNote(incomingItemContent.getCheckinNote());
907 }
908 if (StringUtils.isNotBlank(incomingItemContent.getCurrentBorrower())) {
909 existingItemContent.setCurrentBorrower(incomingItemContent.getCurrentBorrower());
910 }
911 if (StringUtils.isNotBlank(incomingItemContent.getClaimsReturnedFlagCreateDate())) {
912 existingItemContent.setClaimsReturnedFlagCreateDate(incomingItemContent.getClaimsReturnedFlagCreateDate());
913 }
914 if (StringUtils.isNotBlank(incomingItemContent.getAnalytic())) {
915 existingItemContent.setAnalytic(incomingItemContent.getAnalytic());
916 }
917 if (StringUtils.isNotBlank(incomingItemContent.getDueDateTime())) {
918 existingItemContent.setDueDateTime(incomingItemContent.getDueDateTime());
919 }
920 if (StringUtils.isNotBlank(incomingItemContent.getDamagedItemNote())) {
921 existingItemContent.setDamagedItemNote(incomingItemContent.getDamagedItemNote());
922 }
923 if (StringUtils.isNotBlank(incomingItemContent.getItemStatusEffectiveDate())) {
924 existingItemContent.setItemStatusEffectiveDate(incomingItemContent.getItemStatusEffectiveDate());
925 }
926 if (StringUtils.isNotBlank(incomingItemContent.getMissingPieceEffectiveDate())) {
927 existingItemContent.setMissingPieceEffectiveDate(incomingItemContent.getMissingPieceEffectiveDate());
928 }
929 if (StringUtils.isNotBlank(incomingItemContent.getClaimsReturnedNote())) {
930 existingItemContent.setClaimsReturnedNote(incomingItemContent.getClaimsReturnedNote());
931 }
932 if (StringUtils.isNotBlank(incomingItemContent.getProxyBorrower())) {
933 existingItemContent.setProxyBorrower(incomingItemContent.getProxyBorrower());
934 }
935 if (StringUtils.isNotBlank(incomingItemContent.getMissingPieceFlagNote())) {
936 existingItemContent.setMissingPieceFlagNote(incomingItemContent.getMissingPieceFlagNote());
937 }
938 if (StringUtils.isNotBlank(incomingItemContent.getMissingPiecesCount())) {
939 existingItemContent.setMissingPiecesCount(incomingItemContent.getMissingPiecesCount());
940 }
941 if (incomingItemContent.getAccessInformation() != null) {
942 if(StringUtils.isNotBlank(incomingItemContent.getAccessInformation().getBarcode())) {
943 existingItemContent.getAccessInformation().setBarcode(incomingItemContent.getAccessInformation().getBarcode());
944 }
945 if(incomingItemContent.getAccessInformation().getUri()!=null){
946 existingItemContent.getAccessInformation().setUri(incomingItemContent.getAccessInformation().getUri());
947 }
948 }
949 if (incomingItemContent.getTemporaryItemType() != null) {
950 existingItemContent.setTemporaryItemType(incomingItemContent.getTemporaryItemType());
951 }
952 if (incomingItemContent.getStatisticalSearchingCode() != null) {
953 existingItemContent.setStatisticalSearchingCode(incomingItemContent.getStatisticalSearchingCode());
954 }
955 if (incomingItemContent.getNumberOfCirculations() != null) {
956 existingItemContent.setNumberOfCirculations(incomingItemContent.getNumberOfCirculations());
957 }
958 if (incomingItemContent.getDonorInfo() != null) {
959 existingItemContent.setDonorInfo(incomingItemContent.getDonorInfo());
960 }
961 if (incomingItemContent.getMissingPieceItemRecordList() != null) {
962 existingItemContent.setMissingPieceItemRecordList(incomingItemContent.getMissingPieceItemRecordList());
963 }
964 if(incomingItemContent.getItemClaimsReturnedRecords() != null){
965 existingItemContent.setItemClaimsReturnedRecords(incomingItemContent.getItemClaimsReturnedRecords());
966 }
967 if(incomingItemContent.getItemDamagedRecords() != null){
968 existingItemContent.setItemDamagedRecords(incomingItemContent.getItemDamagedRecords());
969 }
970 if (incomingItemContent.getHighDensityStorage() != null) {
971 existingItemContent.setHighDensityStorage(incomingItemContent.getHighDensityStorage());
972 }
973 if (incomingItemContent.getNote() != null) {
974 existingItemContent.setNote(incomingItemContent.getNote());
975 }
976 if (incomingItemContent.getFormerIdentifier() != null) {
977 existingItemContent.setFormerIdentifier(incomingItemContent.getFormerIdentifier());
978 }
979 if (StringUtils.isNotBlank(incomingItemContent.getVolumeNumberLabel())) {
980 existingItemContent.setVolumeNumberLabel(incomingItemContent.getVolumeNumberLabel());
981 }
982 if (StringUtils.isNotBlank(incomingItemContent.getVendorLineItemIdentifier())) {
983 existingItemContent.setVendorLineItemIdentifier(incomingItemContent.getVendorLineItemIdentifier());
984 }
985 if (StringUtils.isNotBlank(incomingItemContent.getPurchaseOrderLineItemIdentifier())) {
986 existingItemContent.setPurchaseOrderLineItemIdentifier(incomingItemContent.getPurchaseOrderLineItemIdentifier());
987 }
988 if (StringUtils.isNotBlank(incomingItemContent.getResourceIdentifier())) {
989 existingItemContent.setResourceIdentifier(incomingItemContent.getResourceIdentifier());
990 }
991 if (incomingItemContent.isStaffOnlyFlag() != existingItemContent.isStaffOnlyFlag()) {
992 existingItemContent.setStaffOnlyFlag(incomingItemContent.isStaffOnlyFlag());
993 this.setStaffOnly(incomingItemContent.isStaffOnlyFlag());
994
995 }
996 this.setContent(itemOlemlRecordProcessor.toXML(existingItemContent));
997 }
998
999
1000 public void setDefaultField(String docField, String fieldValue) {
1001
1002 org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) getContentObject();
1003
1004
1005 if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_ITEM_BARCODE)) {
1006 if (itemPojo.getAccessInformation() == null) {
1007 AccessInformation accessInformation = new AccessInformation();
1008 itemPojo.setAccessInformation(accessInformation);
1009 }
1010
1011 if (itemPojo.getAccessInformation().getBarcode() == null) {
1012 itemPojo.getAccessInformation().setBarcode(fieldValue);
1013 }
1014
1015 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) {
1016
1017 buildItemCallNumber(itemPojo);
1018 itemPojo.getCallNumber().setNumber(fieldValue);
1019 String callNumberType = itemPojo.getCallNumber().getShelvingScheme().getCodeValue();
1020 if(StringUtils.isEmpty(callNumberType)) {
1021 itemPojo.getCallNumber().getShelvingScheme().setCodeValue("NONE");
1022 }
1023 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE) ) {
1024 buildItemCallNumber(itemPojo);
1025 if (itemPojo.getCallNumber().getShelvingScheme().getCodeValue() == null || !isDataMappingFlag()) {
1026 itemPojo.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
1027 }
1028
1029 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) {
1030 buildItemCallNumber(itemPojo);
1031 if (itemPojo.getCallNumber().getPrefix() == null) {
1032 itemPojo.getCallNumber().setPrefix(fieldValue);
1033 }
1034
1035 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) {
1036 if (itemPojo.getCopyNumber() == null) {
1037 itemPojo.setCopyNumber(fieldValue);
1038 }
1039
1040 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_TYPE)) {
1041 ItemType itemType1 = new ItemType();
1042 itemType1.setCodeValue(fieldValue);
1043 itemPojo.setItemType(itemType1);
1044 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER)) {
1045 setHoldingsCallNumber(fieldValue);
1046
1047 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) {
1048 if (getLevel1Location() == null) {
1049 setLocationLevel1(fieldValue);
1050 }
1051
1052 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) {
1053 if (getLevel2Location() == null) {
1054 setLocationLevel2(fieldValue);
1055 }
1056 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) {
1057 if (getLevel3Location() == null) {
1058 setLocationLevel3(fieldValue);
1059 }
1060 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) {
1061 if (getLevel4Location() == null) {
1062 setLocationLevel4(fieldValue);
1063 }
1064 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) {
1065 if (getLevel5Location() == null) {
1066 setLocationLevel5(fieldValue);
1067 }
1068 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE)) {
1069 setHoldingsCallNumberType(fieldValue);
1070 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1)) {
1071 setHoldingsLocationLevel1(fieldValue);
1072 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2)) {
1073 setHoldingsLocationLevel2(fieldValue);
1074 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3)) {
1075 setHoldingsLocationLevel3(fieldValue);
1076 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4)) {
1077 setHoldingsLocationLevel4(fieldValue);
1078 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5)) {
1079 setHoldingsLocationLevel5(fieldValue);
1080 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER)) {
1081 setHoldingsCopyNumber(fieldValue);
1082 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX)) {
1083 setHoldingsCallNumberPrefix(fieldValue);
1084 } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_STATUS)) {
1085 if(itemPojo.getItemStatus() == null){
1086 ItemStatus itemStatus1 = new ItemStatus();
1087 itemStatus1.setCodeValue(fieldValue);
1088 itemPojo.setItemStatus(itemStatus1);
1089 }
1090 } else if (docField.equalsIgnoreCase(ENUMERATION)) {
1091 if (itemPojo.getEnumeration() == null) {
1092 itemPojo.setEnumeration(fieldValue);
1093 }
1094 } else if (docField.equalsIgnoreCase(CHRONOLOGY)) {
1095 if (itemPojo.getChronology() == null) {
1096 itemPojo.setChronology(fieldValue);
1097 }
1098 } else if (docField.equalsIgnoreCase(VENDOR_LINE_ITEM_IDENTIFIER)) {
1099 if (itemPojo.getVendorLineItemIdentifier() == null) {
1100 itemPojo.setVendorLineItemIdentifier(fieldValue);
1101 }
1102 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_CODE) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_PUBLIC_DISPLAY) || docField.equalsIgnoreCase(DESTINATION_FIELD_DONOR_NOTE)) {
1103 DonorInfo donorInfo = null;
1104 if (itemPojo.getDonorInfo().size() > 0) {
1105 for (DonorInfo donorInfo1 : itemPojo.getDonorInfo()) {
1106 buildDonorInfo(docField, fieldValue, itemPojo, donorInfo1, true);
1107 }
1108 } else {
1109 donorInfo = new DonorInfo();
1110 buildDonorInfo(docField, fieldValue, itemPojo, donorInfo, true);
1111 }
1112 }
1113
1114 }
1115
1116
1117 public String getItemHoldingsDataMappingValue(Map<String, String> itemDocFields) {
1118
1119 StringBuilder itemDataValue = new StringBuilder();
1120
1121
1122 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER) && getHoldingsCallNumber() != null) {
1123 itemDataValue.append(getHoldingsCallNumber());
1124 }
1125
1126 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX) && getHoldingsCallNumberPrefix() != null) {
1127 itemDataValue.append(getHoldingsCallNumberPrefix());
1128 }
1129 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE) && getHoldingsCallNumberType() != null) {
1130 itemDataValue.append(getHoldingsCallNumberType());
1131 }
1132
1133 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER) && getHoldingsCopyNumber() != null) {
1134 itemDataValue.append(getHoldingsCopyNumber());
1135 }
1136
1137 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1) && getHoldingsLocationLevel1() != null) {
1138 itemDataValue.append(getHoldingsLocationLevel1());
1139 }
1140 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2) && getHoldingsLocationLevel2() != null) {
1141 itemDataValue.append(getHoldingsLocationLevel2());
1142 }
1143 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3) && getHoldingsLocationLevel3() != null) {
1144 itemDataValue.append(getHoldingsLocationLevel3());
1145 }
1146 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4) && getHoldingsLocationLevel4() != null) {
1147 itemDataValue.append(getHoldingsLocationLevel4());
1148 }
1149 if (itemDocFields.containsKey(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5) && getHoldingsLocationLevel5() != null) {
1150 itemDataValue.append(getHoldingsLocationLevel5());
1151
1152 }
1153 return itemDataValue.toString();
1154 }
1155
1156
1157 public String getHoldingsCallNumber() {
1158 return holdingsCallNumber;
1159 }
1160
1161 public void setHoldingsCallNumber(String holdingsCallNumber) {
1162 this.holdingsCallNumber = holdingsCallNumber;
1163 }
1164
1165 public String getHoldingsCallNumberType() {
1166 return holdingsCallNumberType;
1167 }
1168
1169 public void setHoldingsCallNumberType(String holdingsCallNumberType) {
1170 this.holdingsCallNumberType = holdingsCallNumberType;
1171 }
1172
1173 public String getHoldingsCopyNumber() {
1174 return holdingsCopyNumber;
1175 }
1176
1177 public void setHoldingsCopyNumber(String holdingsCopyNumber) {
1178 this.holdingsCopyNumber = holdingsCopyNumber;
1179 }
1180
1181 public String getHoldingsCallNumberPrefix() {
1182 return holdingsCallNumberPrefix;
1183 }
1184
1185 public void setHoldingsCallNumberPrefix(String holdingsCallNumberPrefix) {
1186 this.holdingsCallNumberPrefix = holdingsCallNumberPrefix;
1187 }
1188
1189 public String getHoldingsLocationLevel1() {
1190 return holdingsLocationLevel1;
1191 }
1192
1193 public void setHoldingsLocationLevel1(String holdingsLocationLevel1) {
1194 this.holdingsLocationLevel1 = holdingsLocationLevel1;
1195 }
1196
1197 public String getHoldingsLocationLevel2() {
1198 return holdingsLocationLevel2;
1199 }
1200
1201 public void setHoldingsLocationLevel2(String holdingsLocationLevel2) {
1202 this.holdingsLocationLevel2 = holdingsLocationLevel2;
1203 }
1204
1205 public String getHoldingsLocationLevel3() {
1206 return holdingsLocationLevel3;
1207 }
1208
1209 public void setHoldingsLocationLevel3(String holdingsLocationLevel3) {
1210 this.holdingsLocationLevel3 = holdingsLocationLevel3;
1211 }
1212
1213 public String getHoldingsLocationLevel4() {
1214 return holdingsLocationLevel4;
1215 }
1216
1217 public void setHoldingsLocationLevel4(String holdingsLocationLevel4) {
1218 this.holdingsLocationLevel4 = holdingsLocationLevel4;
1219 }
1220
1221 public String getHoldingsLocationLevel5() {
1222 return holdingsLocationLevel5;
1223 }
1224
1225 public void setHoldingsLocationLevel5(String holdingsLocationLevel5) {
1226 this.holdingsLocationLevel5 = holdingsLocationLevel5;
1227 }
1228 }