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