View Javadoc
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  
23  
24  /**
25   * <p>Java class for item complex type.
26   * <p/>
27   * <p>The following schema fragment specifies the expected content contained within this class.
28   * <p/>
29   * <pre>
30   * &lt;complexType name="item">
31   *   &lt;complexContent>
32   *     &lt;extension base="{}docstoreDocument">
33   *       &lt;sequence>
34   *         &lt;element name="callNumberType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
35   *         &lt;element name="callNumberPrefix" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
36   *         &lt;element name="itemStatus" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
37   *         &lt;element name="volumeNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
38   *         &lt;element name="itemType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
39   *         &lt;element name="locationName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
40   *         &lt;element name="chronology" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
41   *         &lt;element name="enumeration" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
42   *         &lt;element name="copyNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
43   *         &lt;element name="barcode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
44   *         &lt;element name="shelvingOrder" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
45   *         &lt;element name="location" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
46   *         &lt;element name="callNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
47   *         &lt;element name="holding" type="{}holdings" minOccurs="0"/>
48   *       &lt;/sequence>
49   *     &lt;/extension>
50   *   &lt;/complexContent>
51   * &lt;/complexType>
52   * </pre>
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 LOCATION = "LOCATION";
83      public static final String SHELVING_ORDER = "SHELVINGORDER";
84      public static final String ITEM_BARCODE = "ITEMBARCODE";
85      public static final String COPY_NUMBER = "COPYNUMBER";
86      public static final String ENUMERATION = "ENUMERATION";
87      public static final String CHRONOLOGY = "CHRONOLOGY";
88      public static final String ITEM_TYPE = "ITEMTYPE";
89      public static final String VOLUME_NUMBER = "VOLUMENUMBER";
90      public static final String ITEM_STATUS = "ITEMSTATUS";
91      public static final String ITEMIDENTIFIER = "ITEMIDENTIFIER";
92      public static final String DESTINATION_FIELD_ITEM_ITEM_BARCODE = "Item Barcode";
93      public static final String DESTINATION_FIELD_CALL_NUMBER = "Call Number";
94      public static final String DESTINATION_FIELD_COPY_NUMBER = "Copy Number";
95      public static final String DESTINATION_FIELD_CALL_NUMBER_TYPE = "Call Number Type";
96      public static final String DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX = "Call Number Prefix";
97      public static final String DESTINATION_ITEM_TYPE = "Item Type";
98      public static final String DESTINATION_ITEM_STATUS = "Item Status";
99      public static final String LCC = "LCC";
100     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER = "Holdings Call Number";
101     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE = "Holdings Call Number Type";
102     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER = "Holdings Copy Number";
103     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX = "Holdings Call Number Prefix";
104     public static final String DESTINATION_FIELD_LOCATION_LEVEL_1 = "Location Level1";
105     public static final String DESTINATION_FIELD_LOCATION_LEVEL_2 = "Location Level2";
106     public static final String DESTINATION_FIELD_LOCATION_LEVEL_3 = "Location Level3";
107     public static final String DESTINATION_FIELD_LOCATION_LEVEL_4 = "Location Level4";
108     public static final String DESTINATION_FIELD_LOCATION_LEVEL_5 = "Location Level5";
109     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1 = "Holdings Location Level1";
110     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2 = "Holdings Location Level2";
111     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3 = "Holdings Location Level3";
112     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4 = "Holdings Location Level4";
113     public static final String DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5 = "Holdings Location Level5";
114     protected String callNumberType;
115     protected String callNumberPrefix;
116     protected String itemStatus;
117     protected String volumeNumber;
118     protected String itemType;
119     protected String locationName;
120     protected String chronology;
121     protected String enumeration;
122     protected String copyNumber;
123     protected String barcode;
124     protected String shelvingOrder;
125     protected String location;
126     protected String callNumber;
127     @XmlElement(name = "holdingsDoc")
128     protected Holdings holding;
129     @XmlElement(name = "holdingsDocs")
130     protected List<Holdings> holdings;
131     protected boolean isAnalytic = false;
132     @XmlTransient
133     protected String locationLevel1;
134     @XmlTransient
135     protected String locationLevel2;
136     @XmlTransient
137     protected String locationLevel3;
138     @XmlTransient
139     protected String locationLevel4;
140     @XmlTransient
141     protected String locationLevel5;
142 
143     @XmlTransient
144     protected String level1Location;
145     @XmlTransient
146     protected String level2Location;
147     @XmlTransient
148     protected String level3Location;
149     @XmlTransient
150     protected String level4Location;
151     @XmlTransient
152     protected String level5Location;
153 
154     public String getLevel1Location() {
155         return level1Location;
156     }
157 
158     public void setLevel1Location(String level1Location) {
159         this.level1Location = level1Location;
160     }
161 
162     public String getLevel5Location() {
163         return level5Location;
164     }
165 
166     public void setLevel5Location(String level5Location) {
167         this.level5Location = level5Location;
168     }
169 
170     public String getLevel4Location() {
171         return level4Location;
172     }
173 
174     public void setLevel4Location(String level4Location) {
175         this.level4Location = level4Location;
176     }
177 
178     public String getLevel3Location() {
179         return level3Location;
180     }
181 
182     public void setLevel3Location(String level3Location) {
183         this.level3Location = level3Location;
184     }
185 
186     public String getLevel2Location() {
187         return level2Location;
188     }
189 
190     public void setLevel2Location(String level2Location) {
191         this.level2Location = level2Location;
192     }
193 
194     public Item() {
195         category = DocCategory.WORK.getCode();
196         type = DocType.ITEM.getCode();
197         format = DocFormat.OLEML.getCode();
198     }
199 
200     public String getLocationLevel1() {
201         return locationLevel1;
202     }
203 
204     public void setLocationLevel1(String locationLevel1) {
205         this.locationLevel1 = locationLevel1;
206     }
207 
208     public String getLocationLevel2() {
209         return locationLevel2;
210     }
211 
212     public void setLocationLevel2(String locationLevel2) {
213         this.locationLevel2 = locationLevel2;
214     }
215 
216     public String getLocationLevel3() {
217         return locationLevel3;
218     }
219 
220     public void setLocationLevel3(String locationLevel3) {
221         this.locationLevel3 = locationLevel3;
222     }
223 
224     public String getLocationLevel4() {
225         return locationLevel4;
226     }
227 
228     public void setLocationLevel4(String locationLevel4) {
229         this.locationLevel4 = locationLevel4;
230     }
231 
232     public String getLocationLevel5() {
233 
234         return locationLevel5;
235     }
236 
237     public void setLocationLevel5(String locationLevel5) {
238         this.locationLevel5 = locationLevel5;
239     }
240 
241     /**
242      * Gets the value of the callNumberType property.
243      *
244      * @return possible object is
245      *         {@link String }
246      */
247     public String getCallNumberType() {
248         return callNumberType;
249     }
250 
251     /**
252      * Sets the value of the callNumberType property.
253      *
254      * @param value allowed object is
255      *              {@link String }
256      */
257     public void setCallNumberType(String value) {
258         this.callNumberType = value;
259     }
260 
261     /**
262      * Gets the value of the callNumberPrefix property.
263      *
264      * @return possible object is
265      *         {@link String }
266      */
267     public String getCallNumberPrefix() {
268         return callNumberPrefix;
269     }
270 
271     /**
272      * Sets the value of the callNumberPrefix property.
273      *
274      * @param value allowed object is
275      *              {@link String }
276      */
277     public void setCallNumberPrefix(String value) {
278         this.callNumberPrefix = value;
279     }
280 
281     /**
282      * Gets the value of the itemStatus property.
283      *
284      * @return possible object is
285      *         {@link String }
286      */
287     public String getItemStatus() {
288         return itemStatus;
289     }
290 
291     /**
292      * Sets the value of the itemStatus property.
293      *
294      * @param value allowed object is
295      *              {@link String }
296      */
297     public void setItemStatus(String value) {
298         this.itemStatus = value;
299     }
300 
301     /**
302      * Gets the value of the volumeNumber property.
303      *
304      * @return possible object is
305      *         {@link String }
306      */
307     public String getVolumeNumber() {
308         return volumeNumber;
309     }
310 
311     /**
312      * Sets the value of the volumeNumber property.
313      *
314      * @param value allowed object is
315      *              {@link String }
316      */
317     public void setVolumeNumber(String value) {
318         this.volumeNumber = value;
319     }
320 
321     /**
322      * Gets the value of the itemType property.
323      *
324      * @return possible object is
325      *         {@link String }
326      */
327     public String getItemType() {
328         return itemType;
329     }
330 
331     /**
332      * Sets the value of the itemType property.
333      *
334      * @param value allowed object is
335      *              {@link String }
336      */
337     public void setItemType(String value) {
338         this.itemType = value;
339     }
340 
341     /**
342      * Gets the value of the locationName property.
343      *
344      * @return possible object is
345      *         {@link String }
346      */
347     public String getLocationName() {
348         return locationName;
349     }
350 
351     /**
352      * Sets the value of the locationName property.
353      *
354      * @param value allowed object is
355      *              {@link String }
356      */
357     public void setLocationName(String value) {
358         this.locationName = value;
359     }
360 
361     /**
362      * Gets the value of the chronology property.
363      *
364      * @return possible object is
365      *         {@link String }
366      */
367     public String getChronology() {
368         return chronology;
369     }
370 
371     /**
372      * Sets the value of the chronology property.
373      *
374      * @param value allowed object is
375      *              {@link String }
376      */
377     public void setChronology(String value) {
378         this.chronology = value;
379     }
380 
381     /**
382      * Gets the value of the enumeration property.
383      *
384      * @return possible object is
385      *         {@link String }
386      */
387     public String getEnumeration() {
388         return enumeration;
389     }
390 
391     /**
392      * bib.java
393      * Sets the value of the enumeration property.
394      *
395      * @param value allowed object is
396      *              {@link String }
397      */
398     public void setEnumeration(String value) {
399         this.enumeration = value;
400     }
401 
402     /**
403      * Gets the value of the copyNumber property.
404      *
405      * @return possible object is
406      *         {@link String }
407      */
408     public String getCopyNumber() {
409         return copyNumber;
410     }
411 
412     /**
413      * Sets the value of the copyNumber property.
414      *
415      * @param value allowed object is
416      *              {@link String }
417      */
418     public void setCopyNumber(String value) {
419         this.copyNumber = value;
420     }
421 
422     /**
423      * Gets the value of the barcode property.
424      *
425      * @return possible object is
426      *         {@link String }
427      */
428     public String getBarcode() {
429         return barcode;
430     }
431 
432     /**
433      * Sets the value of the barcode property.
434      *
435      * @param value allowed object is
436      *              {@link String }
437      */
438     public void setBarcode(String value) {
439         this.barcode = value;
440     }
441 
442     /**
443      * Gets the value of the shelvingOrder property.
444      *
445      * @return possible object is
446      *         {@link String }
447      */
448     public String getShelvingOrder() {
449         return shelvingOrder;
450     }
451 
452     /**
453      * Sets the value of the shelvingOrder property.
454      *
455      * @param value allowed object is
456      *              {@link String }
457      */
458     public void setShelvingOrder(String value) {
459         this.shelvingOrder = value;
460     }
461 
462     /**
463      * Gets the value of the location property.
464      *
465      * @return possible object is
466      *         {@link String }
467      */
468     public String getLocation() {
469         return location;
470     }
471 
472     /**
473      * Sets the value of the location property.
474      *
475      * @param value allowed object is
476      *              {@link String }
477      */
478     public void setLocation(String value) {
479         this.location = value;
480     }
481 
482     /**
483      * Gets the value of the callNumber property.
484      *
485      * @return possible object is
486      *         {@link String }
487      */
488     public String getCallNumber() {
489         return callNumber;
490     }
491 
492     /**
493      * Sets the value of the callNumber property.
494      *
495      * @param value allowed object is
496      *              {@link String }
497      */
498     public void setCallNumber(String value) {
499         this.callNumber = value;
500     }
501 
502     /**
503      * Gets the value of the holding property.
504      *
505      * @return possible object is
506      *         {@link Holdings }
507      */
508     public Holdings getHolding() {
509         return holding;
510     }
511 
512     /**
513      * Sets the value of the holding property.
514      *
515      * @param value allowed object is
516      *              {@link Holdings }
517      */
518     public void setHolding(Holdings value) {
519         this.holding = value;
520     }
521 
522     public boolean isAnalytic() {
523         return isAnalytic;
524     }
525 
526     public void setAnalytic(boolean analytic) {
527         isAnalytic = analytic;
528     }
529 
530     public List<Holdings> getHoldings() {
531         return holdings;
532     }
533 
534     public void setHoldings(List<Holdings> holdings) {
535         this.holdings = holdings;
536     }
537 
538     @Override
539     public String serialize(Object object) {
540         String result = null;
541         StringWriter sw = new StringWriter();
542         Item item = (Item) object;
543         try {
544             JAXBContext jaxbContext = JAXBContext.newInstance(Item.class);
545             Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
546             jaxbMarshaller.marshal(item, sw);
547             result = sw.toString();
548         } catch (Exception e) {
549             LOG.error("Exception ", e);
550         }
551         return result;
552     }
553 
554     @Override
555     public Object deserialize(String content) {
556 
557         JAXBElement<Item> itemElement = null;
558         try {
559             JAXBContext jaxbContext = JAXBContext.newInstance(Item.class);
560             Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
561             ByteArrayInputStream input = new ByteArrayInputStream(content.getBytes("UTF-8"));
562             itemElement = jaxbUnmarshaller.unmarshal(new StreamSource(input), Item.class);
563         } catch (Exception e) {
564             LOG.error("Exception ", e);
565         }
566         return itemElement.getValue();
567     }
568 
569     @Override
570     public Object deserializeContent(Object object) {
571 
572 
573         return null;  //To change body of implemented methods use File | Settings | File Templates.
574     }
575 
576     @Override
577     public Object deserializeContent(String content) {
578         return null;  //To change body of implemented methods use File | Settings | File Templates.
579     }
580 
581     @Override
582     public String serializeContent(Object object) {
583         if (object == null) {
584             object = getContentObject();
585         }
586         LocationLevel locationLevel1 = new LocationLevel();
587         LocationLevel locationLevel2 = new LocationLevel();
588         LocationLevel locationLevel3 = new LocationLevel();
589         LocationLevel locationLevel4 = new LocationLevel();
590         LocationLevel locationLevel5 = new LocationLevel();
591 
592         locationLevel1.setName(getLocationLevel1());
593         locationLevel2.setName(getLocationLevel2());
594         locationLevel3.setName(getLocationLevel3());
595         locationLevel4.setName(getLocationLevel4());
596         locationLevel5.setName(getLocationLevel5());
597         locationLevel1.setLocationLevel(locationLevel2);
598         locationLevel2.setLocationLevel(locationLevel3);
599         locationLevel3.setLocationLevel(locationLevel4);
600         locationLevel4.setLocationLevel(locationLevel5);
601         Location locationPojo = new Location();
602         locationPojo.setLocationLevel(locationLevel1);
603         org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) object;
604         itemPojo.setLocation(locationPojo);
605         ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
606         String itemXml = itemOlemlRecordProcessor.toXML(itemPojo);
607         return itemXml;
608     }
609 
610     public void serializeContent() {
611         if (contentObject == null) {
612             return;
613         }
614         Location locationPojo = buildLocationObj();
615         org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) contentObject;
616         itemPojo.setLocation(locationPojo);
617         ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
618         content = itemOlemlRecordProcessor.toXML(itemPojo);
619     }
620 
621     public void setField(String docField, String fieldValue) {
622         org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) getContentObject();
623 
624 
625         if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_ITEM_BARCODE)) {
626             if (itemPojo.getAccessInformation() == null) {
627                 AccessInformation accessInformation = new AccessInformation();
628                 itemPojo.setAccessInformation(accessInformation);
629             }
630             itemPojo.getAccessInformation().setBarcode(fieldValue);
631         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) {
632 
633             buildItemCallNumber(itemPojo);
634             itemPojo.getCallNumber().setNumber(fieldValue);
635             String callNumberType = itemPojo.getCallNumber().getShelvingScheme().getCodeValue();
636             if(StringUtils.isEmpty(callNumberType)) {
637                 itemPojo.getCallNumber().getShelvingScheme().setCodeValue(LCC);
638             }
639         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE)) {
640             buildItemCallNumber(itemPojo);
641             itemPojo.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
642 
643         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) {
644             buildItemCallNumber(itemPojo);
645             itemPojo.getCallNumber().setPrefix(fieldValue);
646         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) {
647             itemPojo.setCopyNumber(fieldValue);
648         } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_TYPE)) {
649             ItemType itemType1 = new ItemType();
650             itemType1.setCodeValue(fieldValue);
651             itemPojo.setItemType(itemType1);
652         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER)) {
653 //            setCallNumber(fieldValue);
654 //            if (StringUtils.isNotEmpty(fieldValue)) {
655 //                setShelvingScheme(fieldValue);
656 //            } else {
657 //                setShelvingScheme(LCC);
658 //            }
659         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) {
660             setLocationLevel1(fieldValue);
661         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) {
662             setLocationLevel2(fieldValue);
663         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) {
664             setLocationLevel3(fieldValue);
665         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) {
666             setLocationLevel4(fieldValue);
667         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) {
668             setLocationLevel5(fieldValue);
669         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE)) {
670 //            buildItemCallNumber(itemPojo);
671 //            itemPojo.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
672         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1)) {
673 //            setLocationLevel1(fieldValue);
674         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2)) {
675 //            setLocationLevel2(fieldValue);
676         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3)) {
677 //            setLocationLevel3(fieldValue);
678         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4)) {
679 //            setLocationLevel4(fieldValue);
680         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5)) {
681 //            setLocationLevel5(fieldValue);
682         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER)) {
683 //            itemPojo.setCopyNumber(fieldValue);
684         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX)) {
685 //            buildItemCallNumber(itemPojo);
686 //            itemPojo.getCallNumber().setPrefix(fieldValue);
687         } else if (docField.equalsIgnoreCase(DESTINATION_ITEM_STATUS)) {
688             ItemStatus itemStatus1 = new ItemStatus();
689             itemStatus1.setCodeValue(fieldValue);
690             itemPojo.setItemStatus(itemStatus1);
691         }
692 
693     }
694 
695     private void buildItemCallNumber(org.kuali.ole.docstore.common.document.content.instance.Item itemPojo) {
696         if (itemPojo.getCallNumber() == null) {
697             CallNumber callNumberPojo = new CallNumber();
698             ShelvingOrder shelvingOrder1 = new ShelvingOrder();
699             ShelvingScheme shelvingScheme1 = new ShelvingScheme();
700             callNumberPojo.setShelvingScheme(shelvingScheme1);
701             callNumberPojo.setShelvingOrder(shelvingOrder1);
702             itemPojo.setCallNumber(callNumberPojo);
703         }
704     }
705 
706     public Object getContentObject() {
707         if (contentObject == null) {
708             contentObject = new org.kuali.ole.docstore.common.document.content.instance.Item();
709         }
710         return contentObject;
711     }
712 
713 
714     public  Location buildLocationObj() {
715 
716         LocationLevel locationLevel1 = new LocationLevel();
717         locationLevel1.setName(getLocationLevel1());
718         locationLevel1.setLevel(getLevel1Location());
719         LocationLevel locationLevel2 = new LocationLevel();
720         locationLevel2.setName(getLocationLevel2());
721         locationLevel2.setLevel(getLevel2Location());
722         LocationLevel locationLevel3 = new LocationLevel();
723         locationLevel3.setName(getLocationLevel3());
724         locationLevel3.setLevel(getLevel3Location());
725         LocationLevel locationLevel4 = new LocationLevel();
726         locationLevel4.setName(getLocationLevel4());
727         locationLevel4.setLevel(getLevel4Location());
728         LocationLevel locationLevel5 = new LocationLevel();
729         locationLevel5.setName(getLocationLevel5());
730         locationLevel5.setLevel(getLevel5Location());
731 
732         List<LocationLevel> locationLevels = new ArrayList<>();
733 
734         if (StringUtils.isNotEmpty(locationLevel1.getName())) {
735             locationLevels.add(locationLevel1);
736         }
737         if (StringUtils.isNotEmpty(locationLevel2.getName())) {
738             locationLevels.add(locationLevel2);
739         }
740         if (StringUtils.isNotEmpty(locationLevel3.getName())) {
741             locationLevels.add(locationLevel3);
742         }
743         if (StringUtils.isNotEmpty(locationLevel4.getName())) {
744             locationLevels.add(locationLevel4);
745         }
746         if (StringUtils.isNotEmpty(locationLevel5.getName())) {
747             locationLevels.add(locationLevel5);
748         }
749 
750         int locationLevelSize = locationLevels.size();
751 
752         for (int i = 0; i < locationLevelSize; i++) {
753             if ((locationLevelSize - 1) != i) {
754                 locationLevels.get(i).setLocationLevel(locationLevels.get(i + 1));
755             }
756         }
757 
758         Location locationPojo = new Location();
759         if (locationLevels.size() > 0) {
760             locationPojo.setLocationLevel(locationLevels.get(0));
761         }
762 
763         return locationPojo;
764     }
765 
766 
767     @Override
768     public int compareTo(Item o) {
769         return this.getSortedValue().compareTo(o.getSortedValue());
770     }
771 
772 
773     public void setItem(Item itemIncoming) throws ConversionException {
774         ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
775         org.kuali.ole.docstore.common.document.content.instance.Item incomingItemContent = itemOlemlRecordProcessor.fromXML(itemIncoming.getContent());
776         org.kuali.ole.docstore.common.document.content.instance.Item existingItemContent = itemOlemlRecordProcessor.fromXML(this.getContent());
777 
778         this.setId(existingItemContent.getItemIdentifier());
779 
780         if (StringUtils.isNotBlank(itemIncoming.getUpdatedBy())) {
781             this.updatedBy = itemIncoming.getUpdatedBy();
782         } else {
783             this.updatedBy = "UNKNOWN";
784         }
785         if (incomingItemContent.getLocation() != null) {
786             existingItemContent.setLocation(incomingItemContent.getLocation());
787         }
788         if (incomingItemContent.getCallNumber() != null) {
789             existingItemContent.setCallNumber(incomingItemContent.getCallNumber());
790         }
791         if (StringUtils.isNotBlank(incomingItemContent.getChronology())) {
792             existingItemContent.setChronology(incomingItemContent.getChronology());
793         }
794         if (StringUtils.isNotBlank(incomingItemContent.getEnumeration())) {
795             existingItemContent.setEnumeration(incomingItemContent.getEnumeration());
796         }
797         if (StringUtils.isNotBlank(incomingItemContent.getCopyNumber())) {
798             existingItemContent.setCopyNumber(incomingItemContent.getCopyNumber());
799         }
800         if (incomingItemContent.getItemStatus() != null) {
801             existingItemContent.setItemStatus(incomingItemContent.getItemStatus());
802         }
803         if (incomingItemContent.getItemType() != null) {
804             existingItemContent.setItemType(incomingItemContent.getItemType());
805         }
806         if (StringUtils.isNotBlank(incomingItemContent.getBarcodeARSL())) {
807             existingItemContent.setBarcodeARSL(incomingItemContent.getBarcodeARSL());
808         }
809         if (StringUtils.isNotBlank(incomingItemContent.getVolumeNumber())) {
810             existingItemContent.setVolumeNumber(incomingItemContent.getVolumeNumber());
811         }
812         if (StringUtils.isNotBlank(incomingItemContent.getCheckinNote())) {
813             existingItemContent.setCheckinNote(incomingItemContent.getCheckinNote());
814         }
815         if (StringUtils.isNotBlank(incomingItemContent.getCurrentBorrower())) {
816             existingItemContent.setCurrentBorrower(incomingItemContent.getCurrentBorrower());
817         }
818         if (StringUtils.isNotBlank(incomingItemContent.getClaimsReturnedFlagCreateDate())) {
819             existingItemContent.setClaimsReturnedFlagCreateDate(incomingItemContent.getClaimsReturnedFlagCreateDate());
820         }
821         if (StringUtils.isNotBlank(incomingItemContent.getAnalytic())) {
822             existingItemContent.setAnalytic(incomingItemContent.getAnalytic());
823         }
824         if (StringUtils.isNotBlank(incomingItemContent.getDueDateTime())) {
825             existingItemContent.setDueDateTime(incomingItemContent.getDueDateTime());
826         }
827         if (StringUtils.isNotBlank(incomingItemContent.getDamagedItemNote())) {
828             existingItemContent.setDamagedItemNote(incomingItemContent.getDamagedItemNote());
829         }
830         if (StringUtils.isNotBlank(incomingItemContent.getItemStatusEffectiveDate())) {
831             existingItemContent.setItemStatusEffectiveDate(incomingItemContent.getItemStatusEffectiveDate());
832         }
833         if (StringUtils.isNotBlank(incomingItemContent.getMissingPieceEffectiveDate())) {
834             existingItemContent.setMissingPieceEffectiveDate(incomingItemContent.getMissingPieceEffectiveDate());
835         }
836         if (StringUtils.isNotBlank(incomingItemContent.getClaimsReturnedNote())) {
837             existingItemContent.setClaimsReturnedNote(incomingItemContent.getClaimsReturnedNote());
838         }
839         if (StringUtils.isNotBlank(incomingItemContent.getProxyBorrower())) {
840             existingItemContent.setProxyBorrower(incomingItemContent.getProxyBorrower());
841         }
842         if (StringUtils.isNotBlank(incomingItemContent.getMissingPieceFlagNote())) {
843             existingItemContent.setMissingPieceFlagNote(incomingItemContent.getMissingPieceFlagNote());
844         }
845         if (StringUtils.isNotBlank(incomingItemContent.getMissingPiecesCount())) {
846             existingItemContent.setMissingPiecesCount(incomingItemContent.getMissingPiecesCount());
847         }
848         if (incomingItemContent.getAccessInformation() != null) {
849             if(StringUtils.isNotBlank(incomingItemContent.getAccessInformation().getBarcode())) {
850                 existingItemContent.getAccessInformation().setBarcode(incomingItemContent.getAccessInformation().getBarcode());
851             }
852             if(incomingItemContent.getAccessInformation().getUri()!=null){
853                 existingItemContent.getAccessInformation().setUri(incomingItemContent.getAccessInformation().getUri());
854             }
855         }
856         if (incomingItemContent.getTemporaryItemType() != null) {
857             existingItemContent.setTemporaryItemType(incomingItemContent.getTemporaryItemType());
858         }
859         if (incomingItemContent.getStatisticalSearchingCode() != null) {
860             existingItemContent.setStatisticalSearchingCode(incomingItemContent.getStatisticalSearchingCode());
861         }
862         if (incomingItemContent.getNumberOfCirculations() != null) {
863             existingItemContent.setNumberOfCirculations(incomingItemContent.getNumberOfCirculations());
864         }
865         if (incomingItemContent.getDonorInfo() != null) {
866             existingItemContent.setDonorInfo(incomingItemContent.getDonorInfo());
867         }
868         if (incomingItemContent.getHighDensityStorage() != null) {
869             existingItemContent.setHighDensityStorage(incomingItemContent.getHighDensityStorage());
870         }
871         if (incomingItemContent.getNote() != null) {
872             existingItemContent.setNote(incomingItemContent.getNote());
873         }
874         if (incomingItemContent.getFormerIdentifier() != null) {
875             existingItemContent.setFormerIdentifier(incomingItemContent.getFormerIdentifier());
876         }
877         if (StringUtils.isNotBlank(incomingItemContent.getVolumeNumberLabel())) {
878             existingItemContent.setVolumeNumberLabel(incomingItemContent.getVolumeNumberLabel());
879         }
880         if (StringUtils.isNotBlank(incomingItemContent.getVendorLineItemIdentifier())) {
881             existingItemContent.setVendorLineItemIdentifier(incomingItemContent.getVendorLineItemIdentifier());
882         }
883         if (StringUtils.isNotBlank(incomingItemContent.getPurchaseOrderLineItemIdentifier())) {
884             existingItemContent.setPurchaseOrderLineItemIdentifier(incomingItemContent.getPurchaseOrderLineItemIdentifier());
885         }
886         if (StringUtils.isNotBlank(incomingItemContent.getResourceIdentifier())) {
887             existingItemContent.setResourceIdentifier(incomingItemContent.getResourceIdentifier());
888         }
889         if (incomingItemContent.isStaffOnlyFlag() != existingItemContent.isStaffOnlyFlag()) {
890             existingItemContent.setStaffOnlyFlag(incomingItemContent.isStaffOnlyFlag());
891             this.setStaffOnly(incomingItemContent.isStaffOnlyFlag());
892 
893         }
894         this.setContent(itemOlemlRecordProcessor.toXML(existingItemContent));
895     }
896 
897 
898 }