View Javadoc
1   package org.kuali.ole.docstore.common.document;
2   
3   
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.HoldingOlemlRecordProcessor;
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   * <p>Java class for holdings complex type.
27   * <p/>
28   * <p>The following schema fragment specifies the expected content contained within this class.
29   * <p/>
30   * <pre>
31   * &lt;complexType name="holdings">
32   *   &lt;complexContent>
33   *     &lt;extension base="{}docstoreDocument">
34   *       &lt;sequence>
35   *         &lt;element name="copyNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
36   *         &lt;element name="locationName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
37   *         &lt;element name="shelvingOrder" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
38   *         &lt;element name="callNumberPrefix" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
39   *         &lt;element name="callNumberType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
40   *         &lt;element name="callNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
41   *         &lt;element name="holdingsType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
42   *         &lt;element name="bib" type="{}bib" minOccurs="0"/>
43   *       &lt;/sequence>
44   *     &lt;/extension>
45   *   &lt;/complexContent>
46   * &lt;/complexType>
47   * </pre>
48   */
49  @XmlAccessorType(XmlAccessType.FIELD)
50  @XmlType(name = "holdings", propOrder = {
51          "copyNumber",
52          "locationName",
53          "shelvingOrder",
54          "callNumberPrefix",
55          "callNumberType",
56          "callNumber",
57          "holdingsType",
58          "bib",
59          "isBoundWithBib",
60          "bibs",
61          "isSeries"
62  })
63  @XmlRootElement
64  
65  public class Holdings
66          extends DocstoreDocument implements Comparable<Holdings> {
67      private static final Logger LOG = Logger.getLogger(Holdings.class);
68  
69      public static final String LOCATION_NAME = "LOCATIONNAME";
70      public static final String LOCATION_LEVEL1 = "LOCATIONLEVEL1";
71      public static final String LOCATION_LEVEL2 = "LOCATIONLEVEL2";
72      public static final String LOCATION_LEVEL3 = "LOCATIONLEVEL3";
73      public static final String LOCATION_LEVEL4 = "LOCATIONLEVEL4";
74      public static final String LOCATION_LEVEL5 = "LOCATIONLEVEL5";
75      public static final String CALL_NUMBER = "CALLNUMBER";
76      public static final String CALLNUMBER_PREFIX = "CALLNUMBERPREFIX";
77      public static final String CALLNUMBER_TYPE = "CALLNUMBERTYPE";
78      public static final String COPY_NUMBER = "COPYNUMBER";
79      public static final String BIB_TITLE = "BIBTITLE";
80      public static final String HOLDINGSIDENTIFIER = "HOLDINGSIDENTIFIER";
81      public static final String DESTINATION_FIELD_CALL_NUMBER = "Call Number";
82      public static final String LCC = "LCC";
83      public static final String DESTINATION_FIELD_HOLDING_CALL_NUMBER_TYPE = "Call Number Type";
84      public static final String DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX = "Call Number Prefix";
85      public static final String DESTINATION_FIELD_LOCATION_LEVEL_1 = "Location Level1";
86      public static final String DESTINATION_FIELD_LOCATION_LEVEL_2 = "Location Level2";
87      public static final String DESTINATION_FIELD_LOCATION_LEVEL_3 = "Location Level3";
88      public static final String DESTINATION_FIELD_LOCATION_LEVEL_4 = "Location Level4";
89      public static final String DESTINATION_FIELD_LOCATION_LEVEL_5 = "Location Level5";
90      public static final String DESTINATION_FIELD_COPY_NUMBER = "Copy Number";
91      public static final String DESTINATION_FIELD_PLATFORM = "Platform";
92      protected String copyNumber;
93      protected String locationName;
94      protected String shelvingOrder;
95      protected String callNumberPrefix;
96      protected String callNumberType;
97      protected String callNumber;
98      protected String holdingsType;
99      @XmlTransient
100     protected String locationLevel1;
101     @XmlTransient
102     protected String locationLevel2;
103     @XmlTransient
104     protected String locationLevel3;
105     @XmlTransient
106     protected String locationLevel4;
107     @XmlTransient
108     protected String locationLevel5;
109 
110     @XmlTransient
111     protected String level1Location;
112     @XmlTransient
113     protected String level2Location;
114     @XmlTransient
115     protected String level3Location;
116     @XmlTransient
117     protected String level4Location;
118     @XmlTransient
119     protected String level5Location;
120     @XmlElement(name = "bibDoc")
121     protected Bib bib;
122     protected boolean isBoundWithBib;
123     @XmlElement(name = "bibDocs")
124     protected Bibs bibs;
125     protected boolean isSeries = false;
126 
127     public Holdings() {
128         category = DocCategory.WORK.getCode();
129         type = DocType.HOLDINGS.getCode();
130         format = DocFormat.OLEML.getCode();
131     }
132 
133     public OleHoldings getContentObject() {
134         if (contentObject == null) {
135             contentObject = new OleHoldings();
136             ((OleHoldings) contentObject).setHoldingsType(getHoldingsType());
137             if (content != null) {
138                 HoldingOlemlRecordProcessor recordProcessor = new HoldingOlemlRecordProcessor();
139                 contentObject = recordProcessor.fromXML(content);
140             }
141         }
142 
143         return (OleHoldings) contentObject;
144     }
145 
146     public String getLevel1Location() {
147         return level1Location;
148     }
149 
150     public void setLevel1Location(String level1Location) {
151         this.level1Location = level1Location;
152     }
153 
154     public String getLevel2Location() {
155         return level2Location;
156     }
157 
158     public void setLevel2Location(String level2Location) {
159         this.level2Location = level2Location;
160     }
161 
162     public String getLevel3Location() {
163         return level3Location;
164     }
165 
166     public void setLevel3Location(String level3Location) {
167         this.level3Location = level3Location;
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 getLevel5Location() {
179         return level5Location;
180     }
181 
182     public void setLevel5Location(String level5Location) {
183         this.level5Location = level5Location;
184     }
185 
186     public String getLocationLevel5() {
187         return locationLevel5;
188     }
189 
190     public void setLocationLevel5(String locationLevel5) {
191         this.locationLevel5 = locationLevel5;
192     }
193 
194     public String getLocationLevel4() {
195         return locationLevel4;
196     }
197 
198     public void setLocationLevel4(String locationLevel4) {
199         this.locationLevel4 = locationLevel4;
200     }
201 
202     public String getLocationLevel3() {
203         return locationLevel3;
204     }
205 
206     public void setLocationLevel3(String locationLevel3) {
207         this.locationLevel3 = locationLevel3;
208     }
209 
210     public String getLocationLevel2() {
211         return locationLevel2;
212     }
213 
214     public void setLocationLevel2(String locationLevel2) {
215         this.locationLevel2 = locationLevel2;
216     }
217 
218     public String getLocationLevel1() {
219         return locationLevel1;
220     }
221 
222     public void setLocationLevel1(String locationLevel1) {
223         this.locationLevel1 = locationLevel1;
224     }
225 
226     /**
227      * Gets the value of the copyNumber property.
228      *
229      * @return possible object is
230      * {@link String }
231      */
232     public String getCopyNumber() {
233         return copyNumber;
234     }
235 
236     /**
237      * Sets the value of the copyNumber property.
238      *
239      * @param value allowed object is
240      *              {@link String }
241      */
242     public void setCopyNumber(String value) {
243         this.copyNumber = value;
244     }
245 
246     /**
247      * Gets the value of the locationName property.
248      *
249      * @return possible object is
250      * {@link String }
251      */
252     public String getLocationName() {
253         return locationName;
254     }
255 
256     /**
257      * Sets the value of the locationName property.
258      *
259      * @param value allowed object is
260      *              {@link String }
261      */
262     public void setLocationName(String value) {
263         this.locationName = value;
264     }
265 
266     /**
267      * Gets the value of the shelvingOrder property.
268      *
269      * @return possible object is
270      * {@link String }
271      */
272     public String getShelvingOrder() {
273         return shelvingOrder;
274     }
275 
276     /**
277      * Sets the value of the shelvingOrder property.
278      *
279      * @param value allowed object is
280      *              {@link String }
281      */
282     public void setShelvingOrder(String value) {
283         this.shelvingOrder = value;
284     }
285 
286     /**
287      * Gets the value of the callNumberPrefix property.
288      *
289      * @return possible object is
290      * {@link String }
291      */
292     public String getCallNumberPrefix() {
293         return callNumberPrefix;
294     }
295 
296     /**
297      * Sets the value of the callNumberPrefix property.
298      *
299      * @param value allowed object is
300      *              {@link String }
301      */
302     public void setCallNumberPrefix(String value) {
303         this.callNumberPrefix = value;
304     }
305 
306     /**
307      * Gets the value of the callNumberType property.
308      *
309      * @return possible object is
310      * {@link String }
311      */
312     public String getCallNumberType() {
313         return callNumberType;
314     }
315 
316     /**
317      * Sets the value of the callNumberType property.
318      *
319      * @param value allowed object is
320      *              {@link String }
321      */
322     public void setCallNumberType(String value) {
323         this.callNumberType = value;
324     }
325 
326     /**
327      * Gets the value of the callNumber property.
328      *
329      * @return possible object is
330      * {@link String }
331      */
332     public String getCallNumber() {
333         return callNumber;
334     }
335 
336     /**
337      * Sets the value of the callNumber property.
338      *
339      * @param value allowed object is
340      *              {@link String }
341      */
342     public void setCallNumber(String value) {
343         this.callNumber = value;
344     }
345 
346     /**
347      * Gets the value of the holdingsType property.
348      *
349      * @return possible object is
350      * {@link String }
351      */
352     public String getHoldingsType() {
353         return holdingsType;
354     }
355 
356     /**
357      * Sets the value of the holdingsType property.
358      *
359      * @param value allowed object is
360      *              {@link String }
361      */
362     public void setHoldingsType(String value) {
363         this.holdingsType = value;
364     }
365 
366     /**
367      * Gets the value of the bib property.
368      *
369      * @return possible object is
370      * {@link Bib }
371      */
372     public Bib getBib() {
373         return bib;
374     }
375 
376     /**
377      * Sets the value of the bib property.
378      *
379      * @param value allowed object is
380      *              {@link Bib }
381      */
382     public void setBib(Bib value) {
383         this.bib = value;
384     }
385 
386     public boolean isBoundWithBib() {
387         return isBoundWithBib;
388     }
389 
390     public void setBoundWithBib(boolean boundWithBib) {
391         isBoundWithBib = boundWithBib;
392     }
393 
394     public Bibs getBibs() {
395         return bibs;
396     }
397 
398     public void setBibs(Bibs bibs) {
399         this.bibs = bibs;
400     }
401 
402     public boolean isSeries() {
403         return isSeries;
404     }
405 
406     public void setSeries(boolean series) {
407         isSeries = series;
408     }
409 
410     @Override
411     public String serialize(Object object) {
412         String result = null;
413         StringWriter sw = new StringWriter();
414         Holdings holdings = (Holdings) object;
415         try {
416             JAXBContext jaxbContext = JAXBContext.newInstance(Holdings.class);
417             Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
418             jaxbMarshaller.marshal(holdings, sw);
419             result = sw.toString();
420         } catch (Exception e) {
421             LOG.error("Exception ", e);
422         }
423         return result;
424     }
425 
426     @Override
427     public Object deserialize(String content) {
428 
429         JAXBElement<Holdings> holdingsElement = null;
430         try {
431             JAXBContext jaxbContext = JAXBContext.newInstance(Holdings.class);
432             Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
433             ByteArrayInputStream input = new ByteArrayInputStream(content.getBytes("UTF-8"));
434             holdingsElement = jaxbUnmarshaller.unmarshal(new StreamSource(input), Holdings.class);
435         } catch (Exception e) {
436             e.printStackTrace();
437         }
438         return holdingsElement.getValue();
439     }
440 
441     public Object deserializeContent(Object object) {
442         return null;  //To change body of implemented methods use File | Settings | File Templates.
443     }
444 
445     @Override
446     public Object deserializeContent(String content) {
447         HoldingOlemlRecordProcessor recordProcessor = new HoldingOlemlRecordProcessor();
448         OleHoldings oleHoldings = recordProcessor.fromXML(content);
449         return oleHoldings;
450     }
451 
452     @Override
453     public String serializeContent(Object object) {
454         OleHoldings oleHoldings = (OleHoldings) object;
455         HoldingOlemlRecordProcessor recordProcessor = new HoldingOlemlRecordProcessor();
456         String content = recordProcessor.toXML(oleHoldings);
457         return content;
458     }
459 
460     public void serializeContent() {
461         if (contentObject == null) {
462             return;
463         }
464 
465         OleHoldings oleHoldings = (OleHoldings) contentObject;
466         Location locationPojo = buildLocationObj();
467 
468         oleHoldings.setLocation(locationPojo);
469         HoldingOlemlRecordProcessor recordProcessor = new HoldingOlemlRecordProcessor();
470         content = recordProcessor.toXML(oleHoldings);
471     }
472 
473     public void setField(String docField, String fieldValue) {
474 
475         OleHoldings oleHoldings = getContentObject();
476         buildItemCallNumber(oleHoldings);
477 
478 
479         if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) {
480             oleHoldings.getCallNumber().setNumber(fieldValue);
481             String callNumberType = oleHoldings.getCallNumber().getShelvingScheme().getCodeValue();
482             if (StringUtils.isEmpty(callNumberType) || callNumberType.equals(NO_INFO_CALL_NUMBER_TYPE_CODE)) {
483                 oleHoldings.getCallNumber().getShelvingScheme().setCodeValue(LCC);
484             }
485         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_HOLDING_CALL_NUMBER_TYPE)) {
486             oleHoldings.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
487         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) {
488             oleHoldings.getCallNumber().setPrefix(fieldValue);
489         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) {
490             setLocationLevel1(fieldValue);
491         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) {
492             setLocationLevel2(fieldValue);
493         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) {
494             setLocationLevel3(fieldValue);
495         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) {
496             setLocationLevel4(fieldValue);
497         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) {
498             setLocationLevel5(fieldValue);
499         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) {
500             oleHoldings.setCopyNumber(fieldValue);
501         }
502     }
503 
504 
505     public void setDefaultField(String docField, String fieldValue) {
506 
507         OleHoldings oleHoldings = getContentObject();
508         buildItemCallNumber(oleHoldings);
509 
510 
511         if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) {
512             if (oleHoldings.getCallNumber().getNumber() == null) {
513                 oleHoldings.getCallNumber().setNumber(fieldValue);
514             }
515 
516         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_HOLDING_CALL_NUMBER_TYPE)) {
517 
518             if (oleHoldings.getCallNumber().getShelvingScheme().getCodeValue() == null) {
519                 oleHoldings.getCallNumber().getShelvingScheme().setCodeValue(fieldValue);
520             }
521 
522         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) {
523             if (oleHoldings.getCallNumber().getPrefix() == null) {
524                 oleHoldings.getCallNumber().setPrefix(fieldValue);
525             }
526 
527         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) {
528             if (getLocationLevel1() == null) {
529                 setLocationLevel1(fieldValue);
530             }
531 
532         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) {
533             if (getLocationLevel2() == null) {
534                 setLocationLevel2(fieldValue);
535             }
536         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) {
537             if (getLocationLevel3() == null) {
538                 setLocationLevel3(fieldValue);
539             }
540         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) {
541             if (getLocationLevel4() == null) {
542                 setLocationLevel4(fieldValue);
543             }
544         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) {
545             if (getLocationLevel5() == null) {
546                 setLocationLevel5(fieldValue);
547             }
548         } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) {
549             if (oleHoldings.getCopyNumber() == null) {
550                 oleHoldings.setCopyNumber(fieldValue);
551             }
552 
553         }
554     }
555 
556     public void buildItemCallNumber(OleHoldings oleHoldings) {
557         if (oleHoldings.getCallNumber() == null) {
558             CallNumber callNumberPojo = new CallNumber();
559             ShelvingOrder shelvingOrder1 = new ShelvingOrder();
560             ShelvingScheme shelvingScheme1 = new ShelvingScheme();
561             callNumberPojo.setShelvingScheme(shelvingScheme1);
562             callNumberPojo.setShelvingOrder(shelvingOrder1);
563             oleHoldings.setCallNumber(callNumberPojo);
564         } else {
565             if (oleHoldings.getCallNumber().getShelvingOrder() == null) {
566                 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
567                 oleHoldings.getCallNumber().setShelvingOrder(shelvingOrder1);
568             }
569             if (oleHoldings.getCallNumber().getShelvingScheme() == null) {
570                 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
571                 oleHoldings.getCallNumber().setShelvingScheme(shelvingScheme1);
572             }
573         }
574     }
575 
576     public Location buildLocationObj() {
577 
578         LocationLevel locationLevel1 = new LocationLevel();
579         locationLevel1.setName(getLocationLevel1());
580         locationLevel1.setLevel(getLevel1Location());
581         LocationLevel locationLevel2 = new LocationLevel();
582         locationLevel2.setName(getLocationLevel2());
583         locationLevel2.setLevel(getLevel2Location());
584         LocationLevel locationLevel3 = new LocationLevel();
585         locationLevel3.setName(getLocationLevel3());
586         locationLevel3.setLevel(getLevel3Location());
587         LocationLevel locationLevel4 = new LocationLevel();
588         locationLevel4.setName(getLocationLevel4());
589         locationLevel4.setLevel(getLevel4Location());
590         LocationLevel locationLevel5 = new LocationLevel();
591         locationLevel5.setName(getLocationLevel5());
592         locationLevel5.setLevel(getLevel5Location());
593 
594         List<LocationLevel> locationLevels = new ArrayList<>();
595 
596         if (StringUtils.isNotEmpty(locationLevel1.getName())) {
597             locationLevels.add(locationLevel1);
598         }
599         if (StringUtils.isNotEmpty(locationLevel2.getName())) {
600             locationLevels.add(locationLevel2);
601         }
602         if (StringUtils.isNotEmpty(locationLevel3.getName())) {
603             locationLevels.add(locationLevel3);
604         }
605         if (StringUtils.isNotEmpty(locationLevel4.getName())) {
606             locationLevels.add(locationLevel4);
607         }
608         if (StringUtils.isNotEmpty(locationLevel5.getName())) {
609             locationLevels.add(locationLevel5);
610         }
611 
612         int locationLevelSize = locationLevels.size();
613 
614         for (int i = 0; i < locationLevelSize; i++) {
615             if ((locationLevelSize - 1) != i) {
616                 locationLevels.get(i).setLocationLevel(locationLevels.get(i + 1));
617             }
618         }
619 
620         Location locationPojo = new Location();
621         if (locationLevels.size() > 0) {
622             locationPojo.setLocationLevel(locationLevels.get(0));
623         }
624 
625         return locationPojo;
626     }
627 
628 
629     public String getHoldingsDataMappingValue(Map<String, String> holdingsDocFields) {
630 
631         OleHoldings oleHoldings = (OleHoldings) contentObject;
632 
633         StringBuilder holdingsDataValue = new StringBuilder();
634         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER) && oleHoldings.getCallNumber().getNumber() != null) {
635             holdingsDataValue.append(oleHoldings.getCallNumber().getNumber());
636         }
637 
638         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX) && oleHoldings.getCallNumber().getPrefix() != null) {
639             holdingsDataValue.append(oleHoldings.getCallNumber().getPrefix());
640         }
641         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE) && oleHoldings.getCallNumber().getType() != null) {
642             holdingsDataValue.append(oleHoldings.getCallNumber().getType());
643         }
644 
645         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER) && oleHoldings.getCopyNumber() != null) {
646             holdingsDataValue.append(oleHoldings.getCopyNumber());
647         }
648 
649         buildLocationLevels(oleHoldings);
650         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1) && getLocationLevel1() != null) {
651             holdingsDataValue.append(getLocationLevel1());
652         }
653         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2) && getLocationLevel2() != null) {
654             holdingsDataValue.append(getLocationLevel2());
655         }
656         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3) && getLocationLevel3() != null) {
657             holdingsDataValue.append(getLocationLevel3());
658         }
659         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4) && getLocationLevel4() != null) {
660             holdingsDataValue.append(getLocationLevel4());
661         }
662         if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5) && getLocationLevel5() != null) {
663             holdingsDataValue.append(getLocationLevel5());
664 
665         }
666         return holdingsDataValue.toString();
667     }
668 
669     private void buildLocationLevels(OleHoldings oleHoldings) {
670         if (oleHoldings != null) {
671             if (oleHoldings.getLocation() != null) {
672                 LocationLevel locationLevel = oleHoldings.getLocation().getLocationLevel();
673                 setLocationLevel1(getLocationLevelName(locationLevel, level1Location));
674                 setLocationLevel2(getLocationLevelName(locationLevel, level2Location));
675                 setLocationLevel3(getLocationLevelName(locationLevel, level3Location));
676                 setLocationLevel4(getLocationLevelName(locationLevel, level4Location));
677                 setLocationLevel5(getLocationLevelName(locationLevel, level5Location));
678             }
679         }
680     }
681 
682 
683     private String getLocationLevelName(LocationLevel locationLevel, String level) {
684         if (locationLevel == null || org.apache.commons.lang.StringUtils.isEmpty(locationLevel.getLevel())) return null;
685         if (locationLevel.getLevel().toUpperCase().startsWith(level)) return locationLevel.getName();
686         return getLocationLevelName(locationLevel.getLocationLevel(), level);
687     }
688 
689     @Override
690     public int compareTo(Holdings o) {
691         return this.getSortedValue().compareTo(o.getSortedValue());
692     }
693 }