View Javadoc
1   package org.kuali.ole.docstore.engine.service.index.solr;
2   
3   import java.io.IOException;
4   import java.util.ArrayList;
5   import java.util.Date;
6   import java.util.List;
7   
8   import org.apache.commons.collections.CollectionUtils;
9   import org.apache.commons.lang.StringUtils;
10  import org.apache.solr.client.solrj.SolrQuery;
11  import org.apache.solr.client.solrj.SolrServer;
12  import org.apache.solr.client.solrj.SolrServerException;
13  import org.apache.solr.client.solrj.response.QueryResponse;
14  import org.apache.solr.client.solrj.response.UpdateResponse;
15  import org.apache.solr.common.SolrDocument;
16  import org.apache.solr.common.SolrDocumentList;
17  import org.apache.solr.common.SolrInputDocument;
18  import org.apache.solr.common.SolrInputField;
19  import org.kuali.ole.docstore.common.document.*;
20  import org.kuali.ole.docstore.common.document.HoldingsTree;
21  import org.kuali.ole.docstore.common.document.Item;
22  import org.kuali.ole.docstore.common.document.content.instance.*;
23  import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
24  import org.kuali.ole.docstore.common.exception.DocstoreIndexException;
25  import org.kuali.ole.docstore.common.service.DocstoreService;
26  import org.kuali.ole.docstore.discovery.service.SolrServerManager;
27  import org.kuali.ole.docstore.engine.service.DocstoreServiceImpl;
28  import org.kuali.ole.docstore.indexer.solr.DocumentLocalId;
29  import org.kuali.ole.docstore.model.enums.DocCategory;
30  import org.kuali.ole.docstore.model.enums.DocFormat;
31  import org.kuali.ole.docstore.model.enums.DocType;
32  import org.kuali.ole.docstore.utility.XMLUtility;
33  import org.slf4j.Logger;
34  import org.slf4j.LoggerFactory;
35  
36  /**
37   * Created with IntelliJ IDEA.
38   * User: sambasivam
39   * Date: 12/17/13
40   * Time: 4:59 PM
41   * To change this template use File | Settings | File Templates.
42   */
43  public class HoldingsOlemlIndexer extends DocstoreSolrIndexService implements HoldingsConstants {
44  
45      private static final Logger LOG = LoggerFactory.getLogger(HoldingsOlemlIndexer.class);
46      private static HoldingsOlemlIndexer holdingsOlemlIndexer = null;
47  
48      private HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor();
49  
50      public static XMLUtility xmlUtility = new XMLUtility();
51  
52      public static HoldingsOlemlIndexer getInstance() {
53          if (holdingsOlemlIndexer == null) {
54              holdingsOlemlIndexer = new HoldingsOlemlIndexer();
55          }
56          return holdingsOlemlIndexer;
57      }
58  
59      protected void buildSolrInputDocument(Object object, List<SolrInputDocument> solrInputDocuments) {
60          Holdings holdings = (Holdings) object;
61  
62          SolrInputDocument solrDocForHolding = getSolrInputFieldsForHoldings(holdings);
63  
64          Date date = new Date();
65          solrDocForHolding.addField(DATE_ENTERED, date);
66          solrDocForHolding.addField(CREATED_BY, holdings.getCreatedBy());
67  
68          solrDocForHolding.addField(BIB_IDENTIFIER, holdings.getBib().getId());
69  
70          List<SolrDocument> solrBibDocs = getSolrDocumentBySolrId(holdings.getBib().getId());
71  
72          if(solrBibDocs != null && solrBibDocs.size() > 0) {
73              SolrDocument bibSolrDoc = solrBibDocs.get(0);
74              addBibInfoForHoldingsOrItems(solrDocForHolding, bibSolrDoc);
75  
76              //add holdings to bib
77              addInstIdToBib(holdings.getId(), solrInputDocuments, bibSolrDoc);
78          }
79  
80          solrInputDocuments.add(solrDocForHolding);
81      }
82  
83      @Override
84      public void createTree(Object object) {
85          List<SolrInputDocument> solrInputDocuments = new ArrayList<>();
86  
87          HoldingsTree holdingsTree = (HoldingsTree) object;
88          String bibId = holdingsTree.getHoldings().getBib().getId();
89  
90          SolrInputDocument holdingsSolrInputDoc = getSolrInputFieldsForHoldings(holdingsTree.getHoldings());
91  
92          Date date = new Date();
93          holdingsSolrInputDoc.addField(CREATED_BY, holdingsTree.getHoldings().getUpdatedBy());
94          holdingsSolrInputDoc.addField(DATE_ENTERED, date);
95  
96          holdingsSolrInputDoc.addField(BIB_IDENTIFIER, bibId);
97  
98          List<org.kuali.ole.docstore.common.document.Item>  itemDocuments = holdingsTree.getItems();
99          List<String> itemIds = new ArrayList<>();
100 
101         holdingsSolrInputDoc.addField(ITEM_IDENTIFIER, itemIds);
102         solrInputDocuments.add(holdingsSolrInputDoc);
103         List<SolrDocument> solrBibDocs = getSolrDocumentBySolrId(bibId);
104 
105         if(solrBibDocs != null && solrBibDocs.size() > 0) {
106             SolrDocument bibSolrDoc = solrBibDocs.get(0);
107             addBibInfoForHoldingsOrItems(holdingsSolrInputDoc, bibSolrDoc);
108 
109             //add holdings to bib
110             addInstIdToBib(holdingsTree.getHoldings().getId(), solrInputDocuments, bibSolrDoc);
111         }
112 
113         ItemOlemlIndexer itemOlemlIndexer = ItemOlemlIndexer.getInstance();
114         for(org.kuali.ole.docstore.common.document.Item itemDocument : itemDocuments) {
115             itemIds.add(itemDocument.getId());
116             SolrInputDocument itemSolrInputDoc = itemOlemlIndexer.getSolrInputFieldsForItem(itemDocument);
117 
118             itemSolrInputDoc.addField(HOLDINGS_IDENTIFIER, holdingsTree.getHoldings().getId());
119             itemSolrInputDoc.addField(BIB_IDENTIFIER, bibId);
120 
121             addBibInfoForHoldingsOrItems(itemSolrInputDoc, holdingsSolrInputDoc);
122             addHoldingsInfoToItem(itemSolrInputDoc, holdingsSolrInputDoc);
123             solrInputDocuments.add(itemSolrInputDoc);
124         }
125 
126         indexSolrDocuments(solrInputDocuments, true);
127     }
128 
129     protected SolrInputDocument getSolrInputFieldsForHoldings(Holdings holdings,SolrInputDocument solrDocForHolding) {
130         OleHoldings oleHoldings = null;
131         if(StringUtils.isNotEmpty(holdings.getContent())) {
132             oleHoldings = holdingOlemlRecordProcessor.fromXML(holdings.getContent());
133 //            solrDocForHolding.addField(ALL_TEXT, xmlUtility.getAllContentText(holdings.getContent()));
134 
135         } else if(holdings.getContentObject() != null) {
136             oleHoldings = holdings.getContentObject();
137 //            solrDocForHolding.addField(ALL_TEXT, xmlUtility.getAllContentText(holdingOlemlRecordProcessor.toXML(oleHoldings)));
138 
139         }
140 
141         setCommonFields(holdings, solrDocForHolding);
142         solrDocForHolding.addField(ALL_TEXT, getAllTextValueForHoldings(oleHoldings));
143         solrDocForHolding.addField(RECEIPT_STATUS_SEARCH, oleHoldings.getReceiptStatus());
144         solrDocForHolding.addField(RECEIPT_STATUS_DISPLAY, oleHoldings.getReceiptStatus());
145 
146         if (oleHoldings.getCopyNumber() != null) {
147             solrDocForHolding.addField(COPY_NUMBER_SEARCH, oleHoldings.getCopyNumber());
148             solrDocForHolding.addField(COPY_NUMBER_LABEL_SEARCH, oleHoldings.getCopyNumber());
149             solrDocForHolding.addField(COPY_NUMBER_DISPLAY, oleHoldings.getCopyNumber());
150             solrDocForHolding.addField(COPY_NUMBER_LABEL_DISPLAY, oleHoldings.getCopyNumber());
151         }
152         if (oleHoldings.getCallNumber() != null) {
153             solrDocForHolding.addField(CALL_NUMBER_TYPE_SEARCH, oleHoldings.getCallNumber().getType());
154             solrDocForHolding.addField(CALL_NUMBER_SEARCH, oleHoldings.getCallNumber().getNumber());
155             solrDocForHolding.addField(ITEM_PART_SEARCH, oleHoldings.getCallNumber().getItemPart());
156             solrDocForHolding.addField(CALL_NUMBER_PREFIX_SEARCH, oleHoldings.getCallNumber().getPrefix());
157             solrDocForHolding.addField(CLASSIFICATION_PART_SEARCH, oleHoldings.getCallNumber().getClassificationPart());
158 
159             solrDocForHolding.addField(ITEM_PART_DISPLAY, oleHoldings.getCallNumber().getItemPart());
160             solrDocForHolding.addField(CALL_NUMBER_TYPE_DISPLAY, oleHoldings.getCallNumber().getType());
161             solrDocForHolding.addField(CALL_NUMBER_DISPLAY, oleHoldings.getCallNumber().getNumber());
162             solrDocForHolding.addField(CALL_NUMBER_PREFIX_DISPLAY, oleHoldings.getCallNumber().getPrefix());
163             solrDocForHolding.addField(CLASSIFICATION_PART_DISPLAY, oleHoldings.getCallNumber().getClassificationPart());
164             String shelvingSchemeCodeValue = "";
165             if (oleHoldings.getCallNumber().getShelvingScheme() != null) {
166                 shelvingSchemeCodeValue = oleHoldings.getCallNumber().getShelvingScheme().getCodeValue();
167                 solrDocForHolding.addField(SHELVING_SCHEME_VALUE_SEARCH, oleHoldings.getCallNumber().getShelvingScheme().getFullValue());
168                 solrDocForHolding.addField(SHELVING_SCHEME_CODE_SEARCH, oleHoldings.getCallNumber().getShelvingScheme().getCodeValue());
169                 solrDocForHolding.addField(SHELVING_SCHEME_VALUE_DISPLAY, oleHoldings.getCallNumber().getShelvingScheme().getFullValue());
170                 solrDocForHolding.addField(SHELVING_SCHEME_CODE_DISPLAY, oleHoldings.getCallNumber().getShelvingScheme().getCodeValue());
171             }
172             String shelvingOrder = null;
173             if (oleHoldings.getCallNumber().getShelvingOrder() != null && StringUtils.isNotEmpty(oleHoldings.getCallNumber().getShelvingOrder().getFullValue())) {
174                 shelvingOrder = oleHoldings.getCallNumber().getShelvingOrder().getFullValue();
175             } else {
176                 if (StringUtils.isNotEmpty(oleHoldings.getCallNumber().getNumber()) && oleHoldings.getCallNumber().getNumber().trim().length() > 0) {
177                     shelvingOrder = buildSortableCallNumber(oleHoldings.getCallNumber().getNumber(), shelvingSchemeCodeValue);
178                 }
179             }
180             if (StringUtils.isNotEmpty(shelvingOrder)) {
181                 shelvingOrder = shelvingOrder.replaceAll(" ", "-");
182                 solrDocForHolding.addField(SHELVING_ORDER_SORT, shelvingOrder + holdings.getId());
183                 solrDocForHolding.addField(SHELVING_ORDER_SEARCH, shelvingOrder);
184                 solrDocForHolding.addField(SHELVING_ORDER_DISPLAY, shelvingOrder);
185             }
186         }
187         if (oleHoldings != null && oleHoldings.getLocation() != null &&
188                 oleHoldings.getLocation().getLocationLevel() != null) {
189             StringBuffer locationName = new StringBuffer();
190             StringBuffer locationLevel = new StringBuffer();
191             Location location = oleHoldings.getLocation();
192             buildLocationNameAndLocationLevel(location, locationName, locationLevel);
193             solrDocForHolding.addField(LOCATION_LEVEL_SEARCH, locationName.toString());
194             solrDocForHolding.addField(LOCATION_LEVEL_NAME_SEARCH, locationLevel.toString());
195             solrDocForHolding.addField(LOCATION_LEVEL_DISPLAY, locationName.toString());
196             solrDocForHolding.addField(LOCATION_LEVEL_NAME_DISPLAY, locationLevel.toString());
197             solrDocForHolding.addField(LOCATION_LEVEL_SORT, locationName.toString());
198         }
199         if(holdings.getHoldingsType().equalsIgnoreCase(PHoldings.PRINT)) {
200             solrDocForHolding.addField(DOC_TYPE, DocType.HOLDINGS.getCode());
201             indexPHoldingsInformation(oleHoldings, solrDocForHolding);
202         }
203         else {
204             solrDocForHolding.addField(DOC_TYPE, DocType.EHOLDINGS.getCode());
205             indexEHoldingsInfomation(oleHoldings, solrDocForHolding);
206         }
207         return solrDocForHolding;
208     }
209 
210     protected SolrInputDocument getSolrInputFieldsForHoldings(Holdings holdings) {
211         SolrInputDocument solrDocForHolding = new SolrInputDocument();
212         getSolrInputFieldsForHoldings(holdings,solrDocForHolding);
213         return solrDocForHolding;
214     }
215 
216     private void indexEHoldingsInfomation(OleHoldings oleHoldings, SolrInputDocument solrDocForHolding) {
217 
218         for (Note holdingNote : oleHoldings.getNote()) {
219             solrDocForHolding.addField(HOLDING_NOTE_SEARCH, holdingNote.getValue());
220             solrDocForHolding.addField(HOLDING_NOTE_DISPLAY, holdingNote.getValue());
221         }
222         solrDocForHolding.addField(ACCESS_STATUS_DISPLAY, oleHoldings.getAccessStatus());
223         solrDocForHolding.addField(ACCESS_STATUS_SEARCH, oleHoldings.getAccessStatus());
224         //solrDocForHolding.addField(ACCESS_STATUS_SEARCH, oleHoldings.getAccessStatus());
225         for (DonorInfo donorInfo : oleHoldings.getDonorInfo()) {
226             solrDocForHolding.addField(DONOR_CODE_SEARCH, donorInfo.getDonorCode());
227             solrDocForHolding.addField(DONOR_CODE_DISPLAY, donorInfo.getDonorCode());
228             solrDocForHolding.addField(DONOR_PUBLIC_DISPLAY, donorInfo.getDonorPublicDisplay());
229             solrDocForHolding.addField(DONOR_PUBLIC_SEARCH, donorInfo.getDonorPublicDisplay());
230             solrDocForHolding.addField(DONOR_NOTE_DISPLAY, donorInfo.getDonorNote());
231             solrDocForHolding.addField(DONOR_NOTE_SEARCH, donorInfo.getDonorNote());
232         }
233         if (oleHoldings.getStatisticalSearchingCode() != null) {
234             solrDocForHolding.addField(STATISTICAL_SEARCHING_CODE_VALUE_SEARCH, oleHoldings.getStatisticalSearchingCode().getFullValue());
235             solrDocForHolding.addField(STATISTICAL_SEARCHING_CODE_VALUE_DISPLAY, oleHoldings.getStatisticalSearchingCode().getCodeValue());
236         }
237 
238        /* solrDocForHolding.addField(PUBLISHER_SEARCH, oleHoldings.getPublisher());*/
239         solrDocForHolding.addField(E_PUBLISHER_DISPLAY, oleHoldings.getPublisher());
240         solrDocForHolding.addField(E_PUBLISHER_SEARCH, oleHoldings.getPublisher());
241 
242         solrDocForHolding.addField(IMPRINT_SEARCH, oleHoldings.getImprint());
243         solrDocForHolding.addField(IMPRINT_DISPLAY, oleHoldings.getImprint());
244 
245         if (oleHoldings.getPlatform() != null) {
246             solrDocForHolding.addField(ADMIN_URL_DISPLAY, oleHoldings.getPlatform().getAdminUrl());
247             solrDocForHolding.addField(ADMIN_URL_SEARCH, oleHoldings.getPlatform().getAdminUrl());
248             solrDocForHolding.addField(PLATFORM_DISPLAY, oleHoldings.getPlatform().getPlatformName());
249             solrDocForHolding.addField(ADMIN_USERNAME_DISPLAY, oleHoldings.getPlatform().getAdminUserName());
250             solrDocForHolding.addField(ADMIN_USERNAME_SEARCH, oleHoldings.getPlatform().getAdminUserName());
251             solrDocForHolding.addField(ADMIN_PASSWORD_DISPLAY, oleHoldings.getPlatform().getAdminPassword());
252             solrDocForHolding.addField(ADMIN_PASSWORD_SEARCH, oleHoldings.getPlatform().getAdminPassword());
253         }
254         /*if (oleHoldings.getHoldingsAccessInformation() != null) {
255             solrDocForHolding.addField(AUTHENTICATION_SEARCH, oleHoldings.getHoldingsAccessInformation().getAuthenticationType());
256             solrDocForHolding.addField(AUTHENTICATION_DISPLAY, oleHoldings.getHoldingsAccessInformation().getAuthenticationType());
257             solrDocForHolding.addField(PROXIED_SEARCH, oleHoldings.getHoldingsAccessInformation().getProxiedResource());
258             solrDocForHolding.addField(PROXIED_DISPLAY, oleHoldings.getHoldingsAccessInformation().getProxiedResource());
259             solrDocForHolding.addField(NUMBER_OF_SIMULTANEOUS_USERS_SEARCH, oleHoldings.getHoldingsAccessInformation().getNumberOfSimultaneousUser());
260             solrDocForHolding.addField(NUMBER_OF_SIMULTANEOUS_USERS_DISPLAY, oleHoldings.getHoldingsAccessInformation().getNumberOfSimultaneousUser());
261             solrDocForHolding.addField(ACCESS_LOCATION_SEARCH, oleHoldings.getHoldingsAccessInformation().getAccessLocation());
262             solrDocForHolding.addField(ACCESS_LOCATION_DISPLAY, oleHoldings.getHoldingsAccessInformation().getAccessLocation());
263         }*/
264         solrDocForHolding.addField(PUBLIC_NOTE_DISPLAY, oleHoldings.getDonorPublicDisplay());
265 
266         if (oleHoldings.getLink() != null) {
267             for (Link link : oleHoldings.getLink()) {
268                 if(StringUtils.isNotEmpty(link.getUrl())){
269                     solrDocForHolding.addField(URL_DISPLAY, link.getUrl());
270                 }
271                 if(StringUtils.isNotEmpty(link.getUrl())){
272                     solrDocForHolding.addField(URL_SEARCH, link.getUrl());
273                 }
274                 if(StringUtils.isNotEmpty(link.getText())){
275                     solrDocForHolding.addField(LINK_TEXT_DISPLAY, link.getText());
276                 }
277                 if(StringUtils.isNotEmpty(link.getText())){
278                     solrDocForHolding.addField(LINK_TEXT_SEARCH, link.getText());
279                 }
280             }
281             /*solrDocForHolding.addField(URL_SEARCH, oleHoldings.getLink().getUrl());
282             solrDocForHolding.addField(LINK_TEXT_DISPLAY,oleHoldings.getLink().getText());
283             solrDocForHolding.addField(LINK_TEXT_SEARCH,oleHoldings.getLink().getText());*/
284         }
285 
286         if (oleHoldings.getSubscriptionStatus() != null) {
287             solrDocForHolding.addField(SUBSCRIPTION_DISPLAY, oleHoldings.getSubscriptionStatus());
288             solrDocForHolding.addField(SUBSCRIPTION_SEARCH, oleHoldings.getSubscriptionStatus());
289 
290         }
291         if (oleHoldings.getHoldingsAccessInformation() != null) {
292             solrDocForHolding.addField(ACCESS_USERNAME_DISPLAY, oleHoldings.getHoldingsAccessInformation().getAccessUsername());
293             solrDocForHolding.addField(ACCESS_USERNAME_SEARCH, oleHoldings.getHoldingsAccessInformation().getAccessUsername());
294             solrDocForHolding.addField(ACCESS_PASSWORD_DISPLAY, oleHoldings.getHoldingsAccessInformation().getAccessPassword());
295             solrDocForHolding.addField(ACCESS_PASSWORD_SEARCH, oleHoldings.getHoldingsAccessInformation().getAccessPassword());
296             solrDocForHolding.addField(AUTHENTICATION_DISPLAY, oleHoldings.getHoldingsAccessInformation().getAuthenticationType());
297             solrDocForHolding.addField(AUTHENTICATION_SEARCH, oleHoldings.getHoldingsAccessInformation().getAuthenticationType());
298             solrDocForHolding.addField(PROXIED_DISPLAY, oleHoldings.getHoldingsAccessInformation().getProxiedResource());
299             solrDocForHolding.addField(PROXIED_SEARCH, oleHoldings.getHoldingsAccessInformation().getProxiedResource());
300             solrDocForHolding.addField(NUMBER_OF_SIMULTANEOUS_USERS_DISPLAY, oleHoldings.getHoldingsAccessInformation().getNumberOfSimultaneousUser());
301             solrDocForHolding.addField(NUMBER_OF_SIMULTANEOUS_USERS_SEARCH, oleHoldings.getHoldingsAccessInformation().getNumberOfSimultaneousUser());
302             solrDocForHolding.addField(ACCESS_LOCATION_DISPLAY, oleHoldings.getHoldingsAccessInformation().getAccessLocation());
303             solrDocForHolding.addField(ACCESS_LOCATION_SEARCH, oleHoldings.getHoldingsAccessInformation().getAccessLocation());
304         }
305         if (oleHoldings.getLocalPersistentLink() != null) {
306             solrDocForHolding.addField(PERSIST_LINK_SEARCH, oleHoldings.getLocalPersistentLink());
307             solrDocForHolding.addField(PERSIST_LINK_DISPLAY, oleHoldings.getLocalPersistentLink());
308         }
309         if (oleHoldings.isInterLibraryLoanAllowed()) {
310             solrDocForHolding.addField(ILL_DISPLAY, oleHoldings.isInterLibraryLoanAllowed());
311             solrDocForHolding.addField(ILL_SEARCH, oleHoldings.isInterLibraryLoanAllowed());
312         }
313         if (oleHoldings.getExtentOfOwnership() != null && oleHoldings.getExtentOfOwnership().size() > 0) {
314             if (null != oleHoldings.getExtentOfOwnership().get(0).getCoverages() && null != oleHoldings.getExtentOfOwnership().get(0).getCoverages().getCoverage() && oleHoldings.getExtentOfOwnership().get(0).getCoverages().getCoverage().size() > 0) {
315                 List<Coverage> coverageList = oleHoldings.getExtentOfOwnership().get(0).getCoverages().getCoverage();
316                 for (Coverage coverage : coverageList) {
317                     if (StringUtils.isNotBlank(coverage.getCoverageStartDate()) || StringUtils.isNotBlank(coverage.getCoverageEndDate())) {
318                         solrDocForHolding.addField(E_INSTANCE_COVERAGE_DATE, coverage.getCoverageStartDate() + "-" + coverage.getCoverageEndDate());
319                     } else if (null != oleHoldings.getExtentOfOwnership().get(0).getPerpetualAccesses() && null != oleHoldings.getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess() && oleHoldings.getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess().size() > 0) {
320                         List<PerpetualAccess> perpetualAccessList = oleHoldings.getExtentOfOwnership().get(0).getPerpetualAccesses().getPerpetualAccess();
321                         for (PerpetualAccess perpetualAccess : perpetualAccessList) {
322                             if (StringUtils.isNotBlank(perpetualAccess.getPerpetualAccessStartDate()) || StringUtils.isNotBlank(perpetualAccess.getPerpetualAccessEndDate())) {
323                                 solrDocForHolding.addField(E_INSTANCE_PERPETUAL_ACCESS_DATE, perpetualAccess.getPerpetualAccessStartDate() + "-" + perpetualAccess.getPerpetualAccessEndDate());
324                             }
325                         }
326                     }
327                 }
328             }
329         }
330 
331     }
332 
333     private void indexPHoldingsInformation(OleHoldings oleHoldings, SolrInputDocument solrDocForHolding) {
334         for (Note holdingNote : oleHoldings.getNote()) {
335             solrDocForHolding.addField(HOLDING_NOTE_SEARCH, holdingNote.getValue());
336             solrDocForHolding.addField(HOLDING_NOTE_DISPLAY, holdingNote.getValue());
337         }
338         for (Uri uri : oleHoldings.getUri()) {
339             solrDocForHolding.addField(URI_SEARCH, uri.getValue());
340             solrDocForHolding.addField(URI_DISPLAY, uri.getValue());
341         }
342         if (oleHoldings.getExtentOfOwnership() != null && oleHoldings.getExtentOfOwnership().size()>0) {
343             List<ExtentOfOwnership> extentOfOwnershipList = new ArrayList<ExtentOfOwnership>();
344             for (int extentOfOwnership = 0; extentOfOwnership<oleHoldings.getExtentOfOwnership().size();extentOfOwnership++) {
345                 extentOfOwnershipList.add(oleHoldings.getExtentOfOwnership().get(extentOfOwnership));
346             }
347             for (ExtentOfOwnership extentOfOwnership :extentOfOwnershipList) {
348                 for (int note = 0; note<extentOfOwnership.getNote().size(); note++) {
349                     solrDocForHolding.addField(EXTENT_OF_OWNERSHIP_NOTE_VALUE_DISPLAY,extentOfOwnership.getNote().get(note).getValue());
350                     solrDocForHolding.addField(EXTENT_OF_OWNERSHIP_NOTE_TYPE_DISPLAY,extentOfOwnership.getNote().get(note).getType());
351                 }
352                 solrDocForHolding.addField(EXTENT_OF_OWNERSHIP_TYPE_DISPLAY, extentOfOwnership.getType());
353             }
354         }
355         if (oleHoldings.getHoldingsAccessInformation() != null) {
356             solrDocForHolding.addField(AUTHENTICATION_DISPLAY, oleHoldings.getHoldingsAccessInformation().getAuthenticationType());
357             solrDocForHolding.addField(PROXIED_DISPLAY, oleHoldings.getHoldingsAccessInformation().getProxiedResource());
358             solrDocForHolding.addField(NUMBER_OF_SIMULTANEOUS_USERS_DISPLAY, oleHoldings.getHoldingsAccessInformation().getNumberOfSimultaneousUser());
359             solrDocForHolding.addField(ACCESS_LOCATION_DISPLAY, oleHoldings.getHoldingsAccessInformation().getAccessLocation());
360         }
361     }
362 
363     protected void setCommonFields(Holdings holdings, SolrInputDocument solrDocForHolding) {
364 
365         solrDocForHolding.addField(DOC_CATEGORY, DocCategory.WORK.getCode());
366         solrDocForHolding.addField(DOC_FORMAT, DocFormat.OLEML.getCode());
367         solrDocForHolding.addField(LOCALID_SEARCH, DocumentLocalId.getDocumentId(holdings.getId()));
368         solrDocForHolding.addField(LOCALID_DISPLAY, DocumentLocalId.getDocumentIdDisplay(holdings.getId()));
369         solrDocForHolding.addField(ID, holdings.getId());
370         solrDocForHolding.addField(HOLDINGS_IDENTIFIER, holdings.getId());
371         solrDocForHolding.addField(UNIQUE_ID, holdings.getId());
372         solrDocForHolding.addField(STAFF_ONLY_FLAG, holdings.isStaffOnly());
373         solrDocForHolding.addField(IS_SERIES, holdings.isSeries());
374 
375 
376     }
377 
378 
379     /*protected void updateRecordInSolr(Object object, List<SolrInputDocument> solrInputDocuments) {
380         Holdings holdings = (Holdings) object;
381         OleHoldings oleHoldings = holdingOlemlRecordProcessor.fromXML(holdings.getContent());
382         List<SolrDocument> solrDocumentList = getSolrDocumentBySolrId(holdings.getId());
383         SolrDocument holdingsSolrDocument = solrDocumentList.get(0);
384         if (holdingsSolrDocument != null) {
385 //            holdings.setCreatedBy((String) holdingsSolrDocument.getFieldValue(DATE_ENTERED));
386 //            holdings.setCreatedOn((String) holdingsSolrDocument.getFieldValue(CREATED_BY));
387 
388             oleHoldings.setHoldingsIdentifier(holdings.getId());
389             Object itemIdentifier = holdingsSolrDocument.getFieldValue(ITEM_IDENTIFIER);
390             List<String> reId = new ArrayList<String>();
391             if (holdingsSolrDocument.getFieldValue(BIB_IDENTIFIER) != null && holdingsSolrDocument
392                     .getFieldValue(BIB_IDENTIFIER) instanceof List) {
393                 List<String> idList = (List<String>) holdingsSolrDocument.getFieldValue(BIB_IDENTIFIER);
394                 for (String bibId : idList) {
395                     reId.add(bibId);
396                 }
397             } else if (holdingsSolrDocument.getFieldValue(BIB_IDENTIFIER) != null && holdingsSolrDocument
398                     .getFieldValue(BIB_IDENTIFIER) instanceof String) {
399                 reId.add((String) holdingsSolrDocument.getFieldValue(BIB_IDENTIFIER));
400             }
401 
402             SolrInputDocument solrDocForHolding = getSolrInputFieldsForHoldings(holdings);
403 
404             addBibInfoForHoldingsOrItems(solrDocForHolding, holdingsSolrDocument);
405 
406             List<String> itemIds = new ArrayList<String>();
407             if(itemIdentifier != null) {
408                 if(itemIdentifier instanceof String) {
409                     itemIds.add((String) itemIdentifier);
410                 }
411                 else {
412                     itemIds.addAll((List<String>) itemIdentifier);
413                 }
414             }
415 
416             for (String itemId : itemIds) {
417 
418                 List<SolrDocument> itemDocumentList = getSolrDocumentBySolrId(itemId);
419                 SolrDocument itemSolrDocument = itemDocumentList.get(0);
420                 SolrInputDocument itemSolrInputDocument = new SolrInputDocument();
421                 buildSolrInputDocFromSolrDoc(itemSolrDocument, itemSolrInputDocument);
422                 removeFieldFromSolrInputDocument(itemSolrInputDocument);
423                 addBibInfoForHoldingsOrItems(itemSolrInputDocument, solrDocForHolding);
424                 addHoldingsInfoToItem(itemSolrInputDocument, solrDocForHolding);
425                 solrInputDocuments.add(itemSolrInputDocument);
426             }
427         }
428     }*/
429 
430     protected void updateRecordInSolr(Object object, List<SolrInputDocument> solrInputDocuments) {
431         LOG.info("HoldingsOlemlIndexer class");
432         Holdings holdings = (Holdings) object;
433         List<SolrDocument> solrDocumentList = getSolrDocumentBySolrId(holdings.getId());
434         SolrDocument holdingsSolrDocument = solrDocumentList.get(0);
435 
436         if (holdingsSolrDocument != null) {
437             Object itemIdentifier = holdingsSolrDocument.getFieldValue(ITEM_IDENTIFIER);
438             SolrInputDocument solrDocForHolding = getSolrInputFieldsForHoldings(holdings);
439             addBibInfoForHoldingsOrItems(solrDocForHolding, holdingsSolrDocument);
440 
441             DocstoreService docstoreService = new DocstoreServiceImpl();
442             HoldingsTree holdingsTree = docstoreService.retrieveHoldingsTree(holdings.getId());
443             ItemOlemlIndexer itemOlemlIndexer = ItemOlemlIndexer.getInstance();
444             for (Item item : holdingsTree.getItems()) {
445                 itemOlemlIndexer.updateRecordInSolrForItem(item, solrInputDocuments, solrDocForHolding);
446             }
447 
448             solrDocForHolding.addField(BIB_IDENTIFIER, holdings.getBib().getId());
449             solrDocForHolding.addField(ITEM_IDENTIFIER, itemIdentifier);
450             Date date = new Date();
451             solrDocForHolding.addField(UPDATED_BY, holdings.getUpdatedBy());
452             solrDocForHolding.addField(DATE_UPDATED, date);
453             solrInputDocuments.add(solrDocForHolding);
454         }
455     }
456 
457     protected void processHoldingSolrDocumentForUpdate(Object object, List<SolrInputDocument> solrInputDocuments, SolrInputDocument solrDocForHolding) {
458         LOG.info("HoldingsOlemlIndexer class");
459         Holdings holdings = (Holdings) object;
460         List<SolrDocument> solrDocumentList = getSolrDocumentBySolrId(holdings.getId());
461         if (CollectionUtils.isNotEmpty(solrDocumentList)) {
462             SolrDocument holdingsSolrDocument = solrDocumentList.get(0);
463 
464             if (holdingsSolrDocument != null) {
465                 Object itemIdentifier = holdingsSolrDocument.getFieldValue(ITEM_IDENTIFIER);
466                 solrDocForHolding = getSolrInputFieldsForHoldings(holdings, solrDocForHolding);
467                 addBibInfoForHoldingsOrItems(solrDocForHolding, holdingsSolrDocument);
468 
469                 DocstoreService docstoreService = new DocstoreServiceImpl();
470                 HoldingsTree holdingsTree = docstoreService.retrieveHoldingsTree(holdings.getId());
471                 ItemOlemlIndexer itemOlemlIndexer = ItemOlemlIndexer.getInstance();
472                 for (Item item : holdingsTree.getItems()) {
473                     itemOlemlIndexer.updateRecordInSolrForItem(item, solrInputDocuments, solrDocForHolding);
474                 }
475 
476                 solrDocForHolding.addField(BIB_IDENTIFIER, holdings.getBib().getId());
477                 solrDocForHolding.addField(ITEM_IDENTIFIER, itemIdentifier);
478                 Date date = new Date();
479                 solrDocForHolding.addField(UPDATED_BY, holdings.getUpdatedBy());
480                 solrDocForHolding.addField(DATE_UPDATED, date);
481                 solrInputDocuments.add(solrDocForHolding);
482             }
483         }
484     }
485 
486     /**
487      * Cheking all input document and modifying if it contains record to be mofiied
488      * other wise get it from solar and modify and add it to  input documents
489      *
490      * @param solrServer
491      * @param id
492      * @param solrInputDocumentList
493      * @throws IOException
494      * @throws SolrServerException
495      */
496     protected void processRecord(SolrServer solrServer, String id, List<SolrInputDocument> solrInputDocumentList) throws IOException, SolrServerException {
497         // To find document exists in   incoming
498         boolean isDocumentExists = false;
499         SolrInputDocument solrInputDocumentExists = null;
500         for (SolrInputDocument solrInputDocument : solrInputDocumentList) {
501             List<String> ids = new ArrayList<>();
502             SolrInputField docType = solrInputDocument.get("DocType");
503             if (docType.getValue().equals("bibliographic")) {
504                 SolrInputField holdingsIds = solrInputDocument.get(HOLDINGS_IDENTIFIER);
505                 Object object = holdingsIds.getValue();
506                 if (object instanceof List) {
507                     ids.addAll((List) object);
508                 } else {
509                     ids.add((String) object);
510                 }
511                 for (Object holdingsId : ids) {
512                     if (holdingsId.equals(id)) {
513                         solrInputDocumentExists = solrInputDocument;
514                         isDocumentExists = true;
515                         break;
516                     }
517                 }
518             }
519         }
520         if (!isDocumentExists) {
521             processingDocument(solrServer, id, solrInputDocumentList);
522         } else {
523             solrInputDocumentExists.getFieldValues(HOLDINGS_IDENTIFIER).remove(id);
524         }
525     }
526 
527     /**
528      *  Processing document
529      * @param solrServer
530      * @param id
531      * @param solrInputDocumentList
532      * @throws SolrServerException
533      */
534     private void processingDocument(SolrServer solrServer, String id, List<SolrInputDocument> solrInputDocumentList) throws SolrServerException {
535         String query = "holdingsIdentifier:" + id + " AND " + "(DocType:bibliographic)";
536         SolrQuery solrQuery = new SolrQuery();
537         solrQuery.setQuery(query);
538         QueryResponse response = solrServer.query(solrQuery);
539         List<SolrDocument> solrDocumentList = response.getResults();
540         for (SolrDocument bibSolrDocument : solrDocumentList) {
541             List<String> instanceIdentifierList = new ArrayList<String>();
542             Object instanceIdentifier = bibSolrDocument.getFieldValue("holdingsIdentifier");
543             if (instanceIdentifier instanceof List) {
544                 instanceIdentifierList = (List<String>) bibSolrDocument.getFieldValue("holdingsIdentifier");
545                 if (instanceIdentifierList.contains(id)) {
546                     instanceIdentifierList.remove(id);
547                     bibSolrDocument.setField("holdingsIdentifier", instanceIdentifierList);
548                 }
549             } else if (instanceIdentifier instanceof String) {
550                 String instId = (String) instanceIdentifier;
551                 if (instId.equalsIgnoreCase(id)) {
552                     bibSolrDocument.removeFields("holdingsIdentifier");
553                 }
554             }
555             solrInputDocumentList.add(new BibMarcIndexer().buildSolrInputDocFromSolrDoc(bibSolrDocument));
556         }
557     }
558 
559     /**
560      * Deleting records and processing records to commit
561      * @param solrServer
562      * @param id
563      * @throws IOException
564      * @throws SolrServerException
565      */
566     protected void deleteRecordInSolr(SolrServer solrServer, String id) throws IOException, SolrServerException {
567         List<SolrInputDocument> solrInputDocumentList = new ArrayList<SolrInputDocument>();
568         String query = "(holdingsIdentifier:" + id + " AND DocFormat:oleml)";
569         UpdateResponse updateResponse = solrServer.deleteByQuery(query);
570         query = "(id:" + id + " AND DocType:holdings)";
571         solrServer.deleteByQuery(query);
572         processingDocument(solrServer, id, solrInputDocumentList);
573         indexSolrDocuments(solrInputDocumentList, true);
574     }
575 
576 
577 
578     public List<SolrDocument> getSolrDocumentBySolrId(String uniqueId) {
579         QueryResponse response = null;
580         String result = null;
581         try {
582             String args = "(" + BibConstants.UNIQUE_ID + ":" + uniqueId + ")";
583             SolrServer solr = SolrServerManager.getInstance().getSolrServer();
584             SolrQuery query = new SolrQuery();
585             query.setQuery(args);
586             response = solr.query(query);
587         } catch (Exception e) {
588             LOG.info("Exception :", e);
589             throw new DocstoreIndexException(e.getMessage());
590         }
591         return response.getResults();
592     }
593 
594 
595     protected void modifySolrDocForDestination(String destinationBibId, List<String> holdingsIds, List<SolrInputDocument> solrInputDocumentListFinal) {
596 
597         SolrDocument destBibSolrDocument = getSolrDocumentByUUID(destinationBibId);
598         destBibSolrDocument.addField("holdingsIdentifier", holdingsIds);
599         SolrInputDocument solrInputDocument = new SolrInputDocument();
600         buildSolrInputDocFromSolrDoc(destBibSolrDocument, solrInputDocument);
601         solrInputDocumentListFinal.add(solrInputDocument);
602 
603     }
604 
605     protected void modifySolrDocForSource(List<String> holdingsIds, String bibId, List<SolrInputDocument> solrInputDocumentList) {
606         String sourceBibIdentifier = "";
607         SolrDocumentList solrDocumentList = getSolrDocumentByUUIDs(holdingsIds);
608         for (SolrDocument holdingsSolrDocument : solrDocumentList) {
609             sourceBibIdentifier = (String) holdingsSolrDocument.getFieldValue("bibIdentifier");
610             String sourceHoldingsIdentifier = (String) holdingsSolrDocument.getFieldValue("id");
611             removeHoldingsInSourceBib(sourceBibIdentifier, sourceHoldingsIdentifier ,solrInputDocumentList);
612 
613             Object object = holdingsSolrDocument.getFieldValue("itemIdentifier");
614             //Bib can have more than one item identifier. If there is one item identifier solr will return item identifier string. If there are more than one item identifier solr returns
615             //list of item identifiers
616             if (object instanceof String) {
617                 String itemIdentifier = (String) object;
618                 SolrDocument itemSolrDocument = getSolrDocumentByUUID(itemIdentifier);
619                 itemSolrDocument.setField("bibIdentifier", bibId);
620                 SolrInputDocument solrInputDocument = new SolrInputDocument();
621                 buildSolrInputDocFromSolrDoc(itemSolrDocument, solrInputDocument);
622                 solrInputDocumentList.add(solrInputDocument);
623             } else if (object instanceof List) {
624                 List<String> itemIdentifierList = (List<String>) object;
625                 SolrDocumentList itemSolrDocumentList = getSolrDocumentByUUIDs(itemIdentifierList);
626                 for (SolrDocument itemSolrDocument : itemSolrDocumentList) {
627                     itemSolrDocument.setField("bibIdentifier", bibId);
628                     SolrInputDocument solrInputDocument = new SolrInputDocument();
629                     buildSolrInputDocFromSolrDoc(itemSolrDocument, solrInputDocument);
630                     solrInputDocumentList.add(solrInputDocument);
631                 }
632             }
633 
634             holdingsSolrDocument.setField("bibIdentifier", bibId);
635             SolrInputDocument solrInputDocument = new SolrInputDocument();
636             buildSolrInputDocFromSolrDoc(holdingsSolrDocument, solrInputDocument);
637             solrInputDocumentList.add(solrInputDocument);
638         }
639 
640     }
641 
642     private void removeHoldingsInSourceBib(String bibIdentifier,String holdingsId ,List<SolrInputDocument> solrInputDocumentList) {
643         SolrDocument solrDocument = getSolrDocumentByUUID(bibIdentifier);
644         Object field = solrDocument.getFieldValue("holdingsIdentifier");
645         List bibIdentifierList = null;
646         if (field instanceof String) {
647             String holdingsIdentifier = (String) solrDocument.getFieldValue("holdingsIdentifier");
648             bibIdentifierList = new ArrayList<>();
649             bibIdentifierList.add(holdingsIdentifier);
650 
651         } else if (field instanceof List) {
652             bibIdentifierList = (List) solrDocument.getFieldValue("holdingsIdentifier");
653         }
654         bibIdentifierList.remove(holdingsId);
655         solrDocument.setField("holdingsIdentifier", bibIdentifierList);
656 
657         SolrInputDocument solrInputDocument = new SolrInputDocument();
658         buildSolrInputDocFromSolrDoc(solrDocument, solrInputDocument);
659         solrInputDocumentList.add(solrInputDocument);
660 
661     }
662 
663     public void addInstIdToBib(String holdingsId, List<SolrInputDocument> solrInputDocuments, SolrDocument bibSolrDoc) {
664         if (bibSolrDoc.getFieldValue("holdingsIdentifier") != null) {
665             if (bibSolrDoc.getFieldValue("holdingsIdentifier") instanceof List) {
666                 List instIdList = (List) bibSolrDoc.getFieldValue("holdingsIdentifier");
667                 instIdList.add(holdingsId);
668                 bibSolrDoc.setField("holdingsIdentifier", instIdList);
669             } else if (bibSolrDoc.getFieldValue("holdingsIdentifier") instanceof String) {
670                 String instId = (String) bibSolrDoc.getFieldValue("holdingsIdentifier");
671                 List<String> instIdList = new ArrayList<String>();
672                 instIdList.add(instId);
673                 instIdList.add(holdingsId);
674                 bibSolrDoc.setField("holdingsIdentifier", instIdList);
675             }
676         } else {
677             bibSolrDoc.setField("holdingsIdentifier", holdingsId);
678         }
679         solrInputDocuments.add(buildSolrInputDocFromSolrDoc(bibSolrDoc));
680 
681     }
682 
683     public String getAllTextValueForHoldings(OleHoldings oleHoldings) {
684         StringBuffer sb = new StringBuffer();
685         String holdingsIdentifier = oleHoldings.getHoldingsIdentifier();
686         String accessStatus = oleHoldings.getAccessStatus();
687         String copyNumber = oleHoldings.getCopyNumber();
688         String donorNote = oleHoldings.getDonorNote();
689         String donorPublicDisplay = oleHoldings.getDonorPublicDisplay();
690         String eResourceId = oleHoldings.getEResourceId();
691         String holdingsType = oleHoldings.getHoldingsType();
692         String imprint = oleHoldings.getImprint();
693         String localPersistentLink = oleHoldings.getLocalPersistentLink();
694         String primary = oleHoldings.getPrimary();
695         String publisher = oleHoldings.getPublisher();
696         String receiptStatus = oleHoldings.getReceiptStatus();
697         String statusDate = oleHoldings.getStatusDate();
698         String subscriptionStatus = oleHoldings.getSubscriptionStatus();
699 
700 
701         appendData(sb, holdingsIdentifier);
702         appendData(sb, accessStatus);
703         appendData(sb, copyNumber);
704         appendData(sb, donorNote);
705         appendData(sb, donorPublicDisplay);
706         appendData(sb, eResourceId);
707         appendData(sb, holdingsType);
708         appendData(sb, imprint);
709         appendData(sb, localPersistentLink);
710         appendData(sb, primary);
711         appendData(sb, publisher);
712         appendData(sb, receiptStatus);
713         appendData(sb, statusDate);
714         appendData(sb, subscriptionStatus);
715 
716         for (ExtentOfOwnership extentOfOwnership : oleHoldings.getExtentOfOwnership()) {
717             if (extentOfOwnership != null) {
718                 String textualHoldings = extentOfOwnership.getTextualHoldings();
719                 String type = extentOfOwnership.getType();
720                 appendData(sb, textualHoldings);
721                 appendData(sb, type);
722                 Coverages coverages = extentOfOwnership.getCoverages();
723                 PerpetualAccesses perpetualAccesses = extentOfOwnership.getPerpetualAccesses();
724                 if(coverages != null) {
725                     for (Coverage coverage : coverages.getCoverage()) {
726                         if (coverage != null) {
727                             String coverageEndDate = coverage.getCoverageEndDate();
728                             String coverageEndDateFormat = coverage.getCoverageEndDateFormat();
729                             String coverageEndDateString = coverage.getCoverageEndDateString();
730                             String coverageEndIssue = coverage.getCoverageEndIssue();
731                             String coverageEndVolume = coverage.getCoverageEndVolume();
732                             String coverageStartDate = coverage.getCoverageStartDate();
733                             String coverageStartVolume = coverage.getCoverageStartVolume();
734                             String coverageStartIssue = coverage.getCoverageStartIssue();
735                             String coverageStartDateFormat = coverage.getCoverageStartDateFormat();
736                             String coverageStartDateString = coverage.getCoverageStartDateString();
737                             appendData(sb, coverageEndDate);
738                             appendData(sb, coverageEndDateFormat);
739                             appendData(sb, coverageEndDateString);
740                             appendData(sb, coverageEndIssue);
741                             appendData(sb, coverageEndVolume);
742                             appendData(sb, coverageStartDate);
743                             appendData(sb, coverageStartVolume);
744                             appendData(sb, coverageStartIssue);
745                             appendData(sb, coverageStartDateFormat);
746                             appendData(sb, coverageStartDateString);
747                         }
748 
749                     }
750 
751                 }
752                 if(perpetualAccesses != null) {
753                     for (PerpetualAccess perpetualAccess : perpetualAccesses.getPerpetualAccess()) {
754 
755                         if (perpetualAccess != null) {
756                             String perpetualAccessEndDate = perpetualAccess.getPerpetualAccessEndDate();
757                             String perpetualAccessEndDateFormat = perpetualAccess.getPerpetualAccessEndDateFormat();
758                             String perpetualAccessEndDateString = perpetualAccess.getPerpetualAccessEndDateString();
759                             String perpetualAccessEndIssue = perpetualAccess.getPerpetualAccessEndIssue();
760                             String perpetualAccessEndVolume = perpetualAccess.getPerpetualAccessEndVolume();
761                             String perpetualAccessStartDate = perpetualAccess.getPerpetualAccessStartDate();
762                             String perpetualAccessStartDateFormat = perpetualAccess.getPerpetualAccessStartDateFormat();
763                             String perpetualAccessStartDateString = perpetualAccess.getPerpetualAccessStartDateString();
764                             String perpetualAccessStartIssue = perpetualAccess.getPerpetualAccessStartIssue();
765                             String perpetualAccessStartVolume = perpetualAccess.getPerpetualAccessStartVolume();
766 
767                             appendData(sb, perpetualAccessEndDate);
768                             appendData(sb, perpetualAccessEndDateFormat);
769                             appendData(sb, perpetualAccessEndDateString);
770                             appendData(sb, perpetualAccessEndIssue);
771                             appendData(sb, perpetualAccessEndVolume);
772                             appendData(sb, perpetualAccessStartDate);
773                             appendData(sb, perpetualAccessStartDateFormat);
774                             appendData(sb, perpetualAccessStartDateString);
775                             appendData(sb, perpetualAccessStartIssue);
776                             appendData(sb, perpetualAccessStartVolume);
777                         }
778 
779                     }
780 
781                 }
782 
783                 for (Note note : extentOfOwnership.getNote()) {
784                     if (note != null) {
785                         String noteType = note.getType();
786                         String noteValue = note.getValue();
787                         appendData(sb, noteType);
788                         appendData(sb, noteValue);
789                     }
790                 }
791             }
792         }
793 
794         CallNumber callNumber = oleHoldings.getCallNumber();
795         if(callNumber != null) {
796             String number = callNumber.getNumber();
797             String prefix = callNumber.getPrefix();
798             String classificationPart = callNumber.getClassificationPart();
799             String itemPart = callNumber.getItemPart();
800             String type = callNumber.getType();
801             appendData(sb, number);
802             appendData(sb, prefix);
803             appendData(sb, classificationPart);
804             appendData(sb, itemPart);
805             appendData(sb, type);
806             if(callNumber.getShelvingScheme() != null) {
807                 ShelvingScheme shelvingScheme = callNumber.getShelvingScheme();
808                 String shelvingSchemeCodeValue = shelvingScheme.getCodeValue();
809                 String shelvingSchemeFullValue = shelvingScheme.getFullValue();
810                 appendData(sb, shelvingSchemeCodeValue);
811                 appendData(sb, shelvingSchemeFullValue);
812                 if(callNumber.getShelvingScheme().getTypeOrSource() != null) {
813                     String shelvingSchemePointer = shelvingScheme.getTypeOrSource().getPointer();
814                     String shelvingSchemeText = shelvingScheme.getTypeOrSource().getText();
815                     appendData(sb, shelvingSchemePointer);
816                     appendData(sb, shelvingSchemeText);
817                 }
818             }
819 
820             if(callNumber.getShelvingOrder() != null) {
821                 ShelvingOrder shelvingOrder = callNumber.getShelvingOrder();
822                 String shelvingOrderCodeValue = shelvingOrder.getCodeValue();
823                 String shelvingOrderFullValue = shelvingOrder.getFullValue();
824                 appendData(sb, shelvingOrderCodeValue);
825                 appendData(sb, shelvingOrderFullValue);
826                 if (callNumber.getShelvingOrder().getTypeOrSource() != null) {
827                     String shelvingOrderPointer = shelvingOrder.getTypeOrSource().getPointer();
828                     String shelvingOrderText = shelvingOrder.getTypeOrSource().getText();
829                     appendData(sb, shelvingOrderPointer);
830                     appendData(sb, shelvingOrderText);
831                 }
832 
833             }
834         }
835 
836         for (DonorInfo donorInfo : oleHoldings.getDonorInfo()) {
837             if(donorInfo != null) {
838                 String donorCode = donorInfo.getDonorCode();
839                 String donorInfoNote = donorInfo.getDonorNote();
840                 String donorInfoPublicDisplay = donorInfo.getDonorPublicDisplay();
841                 appendData(sb, donorCode);
842                 appendData(sb, donorInfoNote);
843                 appendData(sb, donorInfoPublicDisplay);
844             }
845         }
846 
847         HoldingsAccessInformation holdingsAccessInformation = oleHoldings.getHoldingsAccessInformation();
848         if(holdingsAccessInformation != null) {
849             String accessLocation = holdingsAccessInformation.getAccessLocation();
850             String accessPassword = holdingsAccessInformation.getAccessPassword();
851             String accessUsername = holdingsAccessInformation.getAccessUsername();
852             String authenticationType = holdingsAccessInformation.getAuthenticationType();
853             String numberOfSimultaneousUser = holdingsAccessInformation.getNumberOfSimultaneousUser();
854             String proxiedResource = holdingsAccessInformation.getProxiedResource();
855             appendData(sb, accessLocation);
856             appendData(sb, accessPassword);
857             appendData(sb, accessUsername);
858             appendData(sb, authenticationType);
859             appendData(sb, numberOfSimultaneousUser);
860             appendData(sb, proxiedResource);
861         }
862 
863         for (Link link : oleHoldings.getLink()) {
864             if(link != null) {
865                 String text = link.getText();
866                 String url = link.getUrl();
867                 appendData(sb, text);
868                 appendData(sb, url);
869             }
870         }
871 
872         for (Note note : oleHoldings.getNote()) {
873             if(note != null) {
874                 String noteValue = note.getValue();
875                 String noteType = note.getType();
876                 appendData(sb, noteValue);
877                 appendData(sb, noteType);
878             }
879 
880         }
881         Platform platform = oleHoldings.getPlatform();
882         if(platform != null) {
883             String adminPassword = platform.getAdminPassword();
884             String adminUrl = platform.getAdminUrl();
885             String adminUserName = platform.getAdminUserName();
886             String platformName = platform.getPlatformName();
887             appendData(sb, adminPassword);
888             appendData(sb, adminUrl);
889             appendData(sb, adminUserName);
890             appendData(sb, platformName);
891         }
892 
893         StatisticalSearchingCode statisticalSearchingCode = oleHoldings.getStatisticalSearchingCode();
894         if(statisticalSearchingCode != null) {
895             String codeValue = statisticalSearchingCode.getCodeValue();
896             String fullValue = statisticalSearchingCode.getFullValue();
897             appendData(sb, codeValue);
898             appendData(sb, fullValue);
899             if(statisticalSearchingCode.getTypeOrSource() != null) {
900                 String text = statisticalSearchingCode.getTypeOrSource().getText();
901                 String pointer = statisticalSearchingCode.getTypeOrSource().getPointer();
902                 appendData(sb, text);
903                 appendData(sb, pointer);
904             }
905         }
906 
907         for (Uri uri : oleHoldings.getUri()) {
908             if(uri != null) {
909                 String value = uri.getValue();
910                 String resolvable = uri.getResolvable();
911                 appendData(sb, value);
912                 appendData(sb, resolvable);
913             }
914         }
915 
916         buildLocationNameAndLocationLevel(oleHoldings.getLocation(), sb, sb);
917         return sb.toString();
918     }
919 
920 }