001package org.kuali.ole.docstore.common.document; 002 003 004import org.apache.commons.lang3.StringUtils; 005import org.apache.log4j.Logger; 006import org.kuali.ole.docstore.common.document.content.enums.DocCategory; 007import org.kuali.ole.docstore.common.document.content.enums.DocFormat; 008import org.kuali.ole.docstore.common.document.content.enums.DocType; 009import org.kuali.ole.docstore.common.document.content.instance.*; 010import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor; 011import org.kuali.ole.docstore.common.document.factory.JAXBContextFactory; 012 013import javax.xml.bind.Marshaller; 014import javax.xml.bind.Unmarshaller; 015import javax.xml.bind.annotation.*; 016import javax.xml.transform.stream.StreamSource; 017import java.io.ByteArrayInputStream; 018import java.io.StringWriter; 019import java.util.ArrayList; 020import java.util.List; 021import java.util.Map; 022 023 024/** 025 * <p>Java class for holdings complex type. 026 * <p/> 027 * <p>The following schema fragment specifies the expected content contained within this class. 028 * <p/> 029 * <pre> 030 * <complexType name="holdings"> 031 * <complexContent> 032 * <extension base="{}docstoreDocument"> 033 * <sequence> 034 * <element name="copyNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 035 * <element name="locationName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 036 * <element name="shelvingOrder" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 037 * <element name="callNumberPrefix" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 038 * <element name="callNumberType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 039 * <element name="callNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 040 * <element name="holdingsType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 041 * <element name="bib" type="{}bib" minOccurs="0"/> 042 * </sequence> 043 * </extension> 044 * </complexContent> 045 * </complexType> 046 * </pre> 047 */ 048@XmlAccessorType(XmlAccessType.FIELD) 049@XmlType(name = "holdings", propOrder = { 050 "copyNumber", 051 "locationName", 052 "shelvingOrder", 053 "callNumberPrefix", 054 "callNumberType", 055 "callNumber", 056 "holdingsType", 057 "bib", 058 "isBoundWithBib", 059 "bibs", 060 "isSeries" 061}) 062@XmlRootElement 063 064public class Holdings 065 extends DocstoreDocument implements Comparable<Holdings> { 066 private static final Logger LOG = Logger.getLogger(Holdings.class); 067 068 public static final String LOCATION_NAME = "LOCATIONNAME"; 069 public static final String LOCATION_LEVEL1 = "LOCATIONLEVEL1"; 070 public static final String LOCATION_LEVEL2 = "LOCATIONLEVEL2"; 071 public static final String LOCATION_LEVEL3 = "LOCATIONLEVEL3"; 072 public static final String LOCATION_LEVEL4 = "LOCATIONLEVEL4"; 073 public static final String LOCATION_LEVEL5 = "LOCATIONLEVEL5"; 074 public static final String CALL_NUMBER = "CALLNUMBER"; 075 public static final String CALLNUMBER_PREFIX = "CALLNUMBERPREFIX"; 076 public static final String CALLNUMBER_TYPE = "CALLNUMBERTYPE"; 077 public static final String COPY_NUMBER = "COPYNUMBER"; 078 public static final String BIB_TITLE = "BIBTITLE"; 079 public static final String HOLDINGSIDENTIFIER = "HOLDINGSIDENTIFIER"; 080 public static final String DESTINATION_FIELD_CALL_NUMBER = "Call Number"; 081 public static final String DESTINATION_FIELD_HOLDING_CALL_NUMBER_TYPE = "Call Number Type"; 082 public static final String DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX = "Call Number Prefix"; 083 public static final String DESTINATION_FIELD_LOCATION_LEVEL_1 = "Location Level1"; 084 public static final String DESTINATION_FIELD_LOCATION_LEVEL_2 = "Location Level2"; 085 public static final String DESTINATION_FIELD_LOCATION_LEVEL_3 = "Location Level3"; 086 public static final String DESTINATION_FIELD_LOCATION_LEVEL_4 = "Location Level4"; 087 public static final String DESTINATION_FIELD_LOCATION_LEVEL_5 = "Location Level5"; 088 public static final String DESTINATION_FIELD_COPY_NUMBER = "Copy Number"; 089 public static final String DESTINATION_FIELD_PLATFORM = "Platform"; 090 protected String copyNumber; 091 protected String locationName; 092 protected String shelvingOrder; 093 protected String callNumberPrefix; 094 protected String callNumberType; 095 protected String callNumber; 096 protected String holdingsType; 097 @XmlTransient 098 protected String locationLevel1; 099 @XmlTransient 100 protected String locationLevel2; 101 @XmlTransient 102 protected String locationLevel3; 103 @XmlTransient 104 protected String locationLevel4; 105 @XmlTransient 106 protected String locationLevel5; 107 108 @XmlTransient 109 protected String level1Location; 110 @XmlTransient 111 protected String level2Location; 112 @XmlTransient 113 protected String level3Location; 114 @XmlTransient 115 protected String level4Location; 116 @XmlTransient 117 protected String level5Location; 118 @XmlElement(name = "bibDoc") 119 protected Bib bib; 120 protected boolean isBoundWithBib; 121 @XmlElement(name = "bibDocs") 122 protected Bibs bibs; 123 protected boolean isSeries = false; 124 125 @XmlTransient 126 protected boolean dataMappingFlag; 127 128 public boolean isDataMappingFlag() { 129 return dataMappingFlag; 130 } 131 132 public void setDataMappingFlag(boolean dataMappingFlag) { 133 this.dataMappingFlag = dataMappingFlag; 134 } 135 136 public Holdings() { 137 category = DocCategory.WORK.getCode(); 138 type = DocType.HOLDINGS.getCode(); 139 format = DocFormat.OLEML.getCode(); 140 } 141 142 public OleHoldings getContentObject() { 143 if (contentObject == null) { 144 contentObject = new OleHoldings(); 145 ((OleHoldings) contentObject).setHoldingsType(getHoldingsType()); 146 if (content != null) { 147 HoldingOlemlRecordProcessor recordProcessor = new HoldingOlemlRecordProcessor(); 148 contentObject = recordProcessor.fromXML(content); 149 } 150 } 151 152 return (OleHoldings) contentObject; 153 } 154 155 public String getLevel1Location() { 156 return level1Location; 157 } 158 159 public void setLevel1Location(String level1Location) { 160 this.level1Location = level1Location; 161 } 162 163 public String getLevel2Location() { 164 return level2Location; 165 } 166 167 public void setLevel2Location(String level2Location) { 168 this.level2Location = level2Location; 169 } 170 171 public String getLevel3Location() { 172 return level3Location; 173 } 174 175 public void setLevel3Location(String level3Location) { 176 this.level3Location = level3Location; 177 } 178 179 public String getLevel4Location() { 180 return level4Location; 181 } 182 183 public void setLevel4Location(String level4Location) { 184 this.level4Location = level4Location; 185 } 186 187 public String getLevel5Location() { 188 return level5Location; 189 } 190 191 public void setLevel5Location(String level5Location) { 192 this.level5Location = level5Location; 193 } 194 195 public String getLocationLevel5() { 196 return locationLevel5; 197 } 198 199 public void setLocationLevel5(String locationLevel5) { 200 this.locationLevel5 = locationLevel5; 201 } 202 203 public String getLocationLevel4() { 204 return locationLevel4; 205 } 206 207 public void setLocationLevel4(String locationLevel4) { 208 this.locationLevel4 = locationLevel4; 209 } 210 211 public String getLocationLevel3() { 212 return locationLevel3; 213 } 214 215 public void setLocationLevel3(String locationLevel3) { 216 this.locationLevel3 = locationLevel3; 217 } 218 219 public String getLocationLevel2() { 220 return locationLevel2; 221 } 222 223 public void setLocationLevel2(String locationLevel2) { 224 this.locationLevel2 = locationLevel2; 225 } 226 227 public String getLocationLevel1() { 228 return locationLevel1; 229 } 230 231 public void setLocationLevel1(String locationLevel1) { 232 this.locationLevel1 = locationLevel1; 233 } 234 235 /** 236 * Gets the value of the copyNumber property. 237 * 238 * @return possible object is 239 * {@link String } 240 */ 241 public String getCopyNumber() { 242 return copyNumber; 243 } 244 245 /** 246 * Sets the value of the copyNumber property. 247 * 248 * @param value allowed object is 249 * {@link String } 250 */ 251 public void setCopyNumber(String value) { 252 this.copyNumber = value; 253 } 254 255 /** 256 * Gets the value of the locationName property. 257 * 258 * @return possible object is 259 * {@link String } 260 */ 261 public String getLocationName() { 262 return locationName; 263 } 264 265 /** 266 * Sets the value of the locationName property. 267 * 268 * @param value allowed object is 269 * {@link String } 270 */ 271 public void setLocationName(String value) { 272 this.locationName = value; 273 } 274 275 /** 276 * Gets the value of the shelvingOrder property. 277 * 278 * @return possible object is 279 * {@link String } 280 */ 281 public String getShelvingOrder() { 282 return shelvingOrder; 283 } 284 285 /** 286 * Sets the value of the shelvingOrder property. 287 * 288 * @param value allowed object is 289 * {@link String } 290 */ 291 public void setShelvingOrder(String value) { 292 this.shelvingOrder = value; 293 } 294 295 /** 296 * Gets the value of the callNumberPrefix property. 297 * 298 * @return possible object is 299 * {@link String } 300 */ 301 public String getCallNumberPrefix() { 302 return callNumberPrefix; 303 } 304 305 /** 306 * Sets the value of the callNumberPrefix property. 307 * 308 * @param value allowed object is 309 * {@link String } 310 */ 311 public void setCallNumberPrefix(String value) { 312 this.callNumberPrefix = value; 313 } 314 315 /** 316 * Gets the value of the callNumberType property. 317 * 318 * @return possible object is 319 * {@link String } 320 */ 321 public String getCallNumberType() { 322 return callNumberType; 323 } 324 325 /** 326 * Sets the value of the callNumberType property. 327 * 328 * @param value allowed object is 329 * {@link String } 330 */ 331 public void setCallNumberType(String value) { 332 this.callNumberType = value; 333 } 334 335 /** 336 * Gets the value of the callNumber property. 337 * 338 * @return possible object is 339 * {@link String } 340 */ 341 public String getCallNumber() { 342 return callNumber; 343 } 344 345 /** 346 * Sets the value of the callNumber property. 347 * 348 * @param value allowed object is 349 * {@link String } 350 */ 351 public void setCallNumber(String value) { 352 this.callNumber = value; 353 } 354 355 /** 356 * Gets the value of the holdingsType property. 357 * 358 * @return possible object is 359 * {@link String } 360 */ 361 public String getHoldingsType() { 362 return holdingsType; 363 } 364 365 /** 366 * Sets the value of the holdingsType property. 367 * 368 * @param value allowed object is 369 * {@link String } 370 */ 371 public void setHoldingsType(String value) { 372 this.holdingsType = value; 373 } 374 375 /** 376 * Gets the value of the bib property. 377 * 378 * @return possible object is 379 * {@link Bib } 380 */ 381 public Bib getBib() { 382 return bib; 383 } 384 385 /** 386 * Sets the value of the bib property. 387 * 388 * @param value allowed object is 389 * {@link Bib } 390 */ 391 public void setBib(Bib value) { 392 this.bib = value; 393 } 394 395 public boolean isBoundWithBib() { 396 return isBoundWithBib; 397 } 398 399 public void setBoundWithBib(boolean boundWithBib) { 400 isBoundWithBib = boundWithBib; 401 } 402 403 public Bibs getBibs() { 404 return bibs; 405 } 406 407 public void setBibs(Bibs bibs) { 408 this.bibs = bibs; 409 } 410 411 public boolean isSeries() { 412 return isSeries; 413 } 414 415 public void setSeries(boolean series) { 416 isSeries = series; 417 } 418 419 @Override 420 public String serialize(Object object) { 421 String result = null; 422 Holdings holdings = (Holdings) object; 423 try { 424 StringWriter sw = new StringWriter(); 425 Marshaller jaxbMarshaller = JAXBContextFactory.getInstance().getMarshaller(Holdings.class); 426 synchronized (jaxbMarshaller) { 427 jaxbMarshaller.marshal(holdings, sw); 428 } 429 result = sw.toString(); 430 } catch (Exception e) { 431 LOG.error("Exception ", e); 432 } 433 return result; 434 } 435 436 @Override 437 public Object deserialize(String content) { 438 Holdings holdings = new Holdings(); 439 try { 440 Unmarshaller unmarshaller = JAXBContextFactory.getInstance().getUnMarshaller(Holdings.class); 441 ByteArrayInputStream input = new ByteArrayInputStream(content.getBytes("UTF-8")); 442 synchronized (unmarshaller) { 443 holdings = unmarshaller.unmarshal(new StreamSource(input), Holdings.class).getValue(); 444 } 445 } catch (Exception e) { 446 LOG.error("Exception ", e); 447 } 448 return holdings; 449 } 450 451 public Object deserializeContent(Object object) { 452 return null; //To change body of implemented methods use File | Settings | File Templates. 453 } 454 455 @Override 456 public Object deserializeContent(String content) { 457 HoldingOlemlRecordProcessor recordProcessor = new HoldingOlemlRecordProcessor(); 458 OleHoldings oleHoldings = recordProcessor.fromXML(content); 459 return oleHoldings; 460 } 461 462 @Override 463 public String serializeContent(Object object) { 464 OleHoldings oleHoldings = (OleHoldings) object; 465 HoldingOlemlRecordProcessor recordProcessor = new HoldingOlemlRecordProcessor(); 466 String content = recordProcessor.toXML(oleHoldings); 467 return content; 468 } 469 470 public void serializeContent() { 471 if (contentObject == null) { 472 return; 473 } 474 475 OleHoldings oleHoldings = (OleHoldings) contentObject; 476 Location locationPojo = buildLocationObj(); 477 478 oleHoldings.setLocation(locationPojo); 479 HoldingOlemlRecordProcessor recordProcessor = new HoldingOlemlRecordProcessor(); 480 content = recordProcessor.toXML(oleHoldings); 481 } 482 483 public void setField(String docField, String fieldValue) { 484 485 OleHoldings oleHoldings = getContentObject(); 486 buildItemCallNumber(oleHoldings); 487 488 489 if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) { 490 oleHoldings.getCallNumber().setNumber(fieldValue); 491 String callNumberType = oleHoldings.getCallNumber().getShelvingScheme().getCodeValue(); 492 if (StringUtils.isEmpty(callNumberType) || callNumberType.equals(NO_INFO_CALL_NUMBER_TYPE_CODE)) { 493 oleHoldings.getCallNumber().getShelvingScheme().setCodeValue("NONE"); 494 } 495 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_HOLDING_CALL_NUMBER_TYPE)) { 496 setDataMappingFlag(true); 497 oleHoldings.getCallNumber().getShelvingScheme().setCodeValue(fieldValue); 498 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) { 499 oleHoldings.getCallNumber().setPrefix(fieldValue); 500 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) { 501 setLocationLevel1(fieldValue); 502 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) { 503 setLocationLevel2(fieldValue); 504 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) { 505 setLocationLevel3(fieldValue); 506 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) { 507 setLocationLevel4(fieldValue); 508 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) { 509 setLocationLevel5(fieldValue); 510 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) { 511 oleHoldings.setCopyNumber(fieldValue); 512 } 513 } 514 515 516 public void setDefaultField(String docField, String fieldValue) { 517 518 OleHoldings oleHoldings = getContentObject(); 519 buildItemCallNumber(oleHoldings); 520 521 522 if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER)) { 523 if (oleHoldings.getCallNumber().getNumber() == null) { 524 oleHoldings.getCallNumber().setNumber(fieldValue); 525 String callNumberType = oleHoldings.getCallNumber().getShelvingScheme().getCodeValue(); 526 if (StringUtils.isEmpty(callNumberType) || callNumberType.equals(NO_INFO_CALL_NUMBER_TYPE_CODE)) { 527 oleHoldings.getCallNumber().getShelvingScheme().setCodeValue("NONE"); 528 } 529 } 530 531 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_HOLDING_CALL_NUMBER_TYPE)) { 532 533 if (oleHoldings.getCallNumber().getShelvingScheme().getCodeValue() == null || !isDataMappingFlag()) { 534 oleHoldings.getCallNumber().getShelvingScheme().setCodeValue(fieldValue); 535 } 536 537 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)) { 538 if (oleHoldings.getCallNumber().getPrefix() == null) { 539 oleHoldings.getCallNumber().setPrefix(fieldValue); 540 } 541 542 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_1)) { 543 if (getLocationLevel1() == null) { 544 setLocationLevel1(fieldValue); 545 } 546 547 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_2)) { 548 if (getLocationLevel2() == null) { 549 setLocationLevel2(fieldValue); 550 } 551 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_3)) { 552 if (getLocationLevel3() == null) { 553 setLocationLevel3(fieldValue); 554 } 555 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_4)) { 556 if (getLocationLevel4() == null) { 557 setLocationLevel4(fieldValue); 558 } 559 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_LOCATION_LEVEL_5)) { 560 if (getLocationLevel5() == null) { 561 setLocationLevel5(fieldValue); 562 } 563 } else if (docField.equalsIgnoreCase(DESTINATION_FIELD_COPY_NUMBER)) { 564 if (oleHoldings.getCopyNumber() == null) { 565 oleHoldings.setCopyNumber(fieldValue); 566 } 567 568 } 569 } 570 571 public void buildItemCallNumber(OleHoldings oleHoldings) { 572 if (oleHoldings.getCallNumber() == null) { 573 CallNumber callNumberPojo = new CallNumber(); 574 ShelvingOrder shelvingOrder1 = new ShelvingOrder(); 575 ShelvingScheme shelvingScheme1 = new ShelvingScheme(); 576 callNumberPojo.setShelvingScheme(shelvingScheme1); 577 callNumberPojo.setShelvingOrder(shelvingOrder1); 578 oleHoldings.setCallNumber(callNumberPojo); 579 } else { 580 if (oleHoldings.getCallNumber().getShelvingOrder() == null) { 581 ShelvingOrder shelvingOrder1 = new ShelvingOrder(); 582 oleHoldings.getCallNumber().setShelvingOrder(shelvingOrder1); 583 } 584 if (oleHoldings.getCallNumber().getShelvingScheme() == null) { 585 ShelvingScheme shelvingScheme1 = new ShelvingScheme(); 586 oleHoldings.getCallNumber().setShelvingScheme(shelvingScheme1); 587 } 588 } 589 } 590 591 public Location buildLocationObj() { 592 593 LocationLevel locationLevel1 = new LocationLevel(); 594 locationLevel1.setName(getLocationLevel1()); 595 locationLevel1.setLevel(getLevel1Location()); 596 LocationLevel locationLevel2 = new LocationLevel(); 597 locationLevel2.setName(getLocationLevel2()); 598 locationLevel2.setLevel(getLevel2Location()); 599 LocationLevel locationLevel3 = new LocationLevel(); 600 locationLevel3.setName(getLocationLevel3()); 601 locationLevel3.setLevel(getLevel3Location()); 602 LocationLevel locationLevel4 = new LocationLevel(); 603 locationLevel4.setName(getLocationLevel4()); 604 locationLevel4.setLevel(getLevel4Location()); 605 LocationLevel locationLevel5 = new LocationLevel(); 606 locationLevel5.setName(getLocationLevel5()); 607 locationLevel5.setLevel(getLevel5Location()); 608 609 List<LocationLevel> locationLevels = new ArrayList<>(); 610 611 if (StringUtils.isNotEmpty(locationLevel1.getName())) { 612 locationLevels.add(locationLevel1); 613 } 614 if (StringUtils.isNotEmpty(locationLevel2.getName())) { 615 locationLevels.add(locationLevel2); 616 } 617 if (StringUtils.isNotEmpty(locationLevel3.getName())) { 618 locationLevels.add(locationLevel3); 619 } 620 if (StringUtils.isNotEmpty(locationLevel4.getName())) { 621 locationLevels.add(locationLevel4); 622 } 623 if (StringUtils.isNotEmpty(locationLevel5.getName())) { 624 locationLevels.add(locationLevel5); 625 } 626 627 int locationLevelSize = locationLevels.size(); 628 629 for (int i = 0; i < locationLevelSize; i++) { 630 if ((locationLevelSize - 1) != i) { 631 locationLevels.get(i).setLocationLevel(locationLevels.get(i + 1)); 632 } 633 } 634 635 Location locationPojo = new Location(); 636 if (locationLevels.size() > 0) { 637 locationPojo.setLocationLevel(locationLevels.get(0)); 638 } 639 640 return locationPojo; 641 } 642 643 644 public String getHoldingsDataMappingValue(Map<String, String> holdingsDocFields) { 645 646 OleHoldings oleHoldings = (OleHoldings) contentObject; 647 648 StringBuilder holdingsDataValue = new StringBuilder(); 649 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER) && oleHoldings.getCallNumber().getNumber() != null) { 650 holdingsDataValue.append(oleHoldings.getCallNumber().getNumber()); 651 } 652 653 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX) && oleHoldings.getCallNumber().getPrefix() != null) { 654 holdingsDataValue.append(oleHoldings.getCallNumber().getPrefix()); 655 } 656 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_TYPE) && oleHoldings.getCallNumber().getType() != null) { 657 holdingsDataValue.append(oleHoldings.getCallNumber().getType()); 658 } 659 660 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER) && oleHoldings.getCopyNumber() != null) { 661 holdingsDataValue.append(oleHoldings.getCopyNumber()); 662 } 663 664 buildLocationLevels(oleHoldings); 665 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_1) && getLocationLevel1() != null) { 666 holdingsDataValue.append(getLocationLevel1()); 667 } 668 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_2) && getLocationLevel2() != null) { 669 holdingsDataValue.append(getLocationLevel2()); 670 } 671 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_3) && getLocationLevel3() != null) { 672 holdingsDataValue.append(getLocationLevel3()); 673 } 674 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_4) && getLocationLevel4() != null) { 675 holdingsDataValue.append(getLocationLevel4()); 676 } 677 if (holdingsDocFields.containsKey(Item.DESTINATION_FIELD_ITEM_HOLDINGS_LOCATION_LEVEL_5) && getLocationLevel5() != null) { 678 holdingsDataValue.append(getLocationLevel5()); 679 680 } 681 return holdingsDataValue.toString(); 682 } 683 684 private void buildLocationLevels(OleHoldings oleHoldings) { 685 if (oleHoldings != null) { 686 if (oleHoldings.getLocation() != null) { 687 LocationLevel locationLevel = oleHoldings.getLocation().getLocationLevel(); 688 setLocationLevel1(getLocationLevelName(locationLevel, level1Location)); 689 setLocationLevel2(getLocationLevelName(locationLevel, level2Location)); 690 setLocationLevel3(getLocationLevelName(locationLevel, level3Location)); 691 setLocationLevel4(getLocationLevelName(locationLevel, level4Location)); 692 setLocationLevel5(getLocationLevelName(locationLevel, level5Location)); 693 } 694 } 695 } 696 697 698 private String getLocationLevelName(LocationLevel locationLevel, String level) { 699 if (locationLevel == null || org.apache.commons.lang.StringUtils.isEmpty(locationLevel.getLevel())) return null; 700 if (locationLevel.getLevel().toUpperCase().startsWith(level)) return locationLevel.getName(); 701 return getLocationLevelName(locationLevel.getLocationLevel(), level); 702 } 703 704 @Override 705 public int compareTo(Holdings o) { 706 return this.getSortedValue().compareTo(o.getSortedValue()); 707 } 708}