001package org.kuali.ole.ingest.action; 002 003import org.kuali.ole.DataCarrierService; 004import org.kuali.ole.OLEConstants; 005import org.kuali.ole.OleHoldingsRecordHandler; 006import org.kuali.ole.OleItemRecordHandler; 007import org.kuali.ole.batch.bo.OLEBatchProcessProfileBo; 008import org.kuali.ole.docstore.common.client.DocstoreClientLocator; 009import org.kuali.ole.docstore.common.document.*; 010import org.kuali.ole.docstore.common.document.HoldingsTree; 011import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecord; 012import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecords; 013import org.kuali.ole.docstore.common.document.content.bib.marc.DataField; 014import org.kuali.ole.docstore.common.document.content.bib.marc.SubField; 015import org.kuali.ole.docstore.common.document.content.bib.marc.xstream.BibMarcRecordProcessor; 016import org.kuali.ole.docstore.common.document.content.enums.DocCategory; 017import org.kuali.ole.docstore.common.document.content.enums.DocFormat; 018import org.kuali.ole.docstore.common.document.content.enums.DocType; 019import org.kuali.ole.docstore.common.document.content.instance.*; 020import org.kuali.ole.docstore.common.document.content.instance.Item; 021import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor; 022import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor; 023import org.kuali.ole.docstore.model.xmlpojo.ingest.Response; 024import org.kuali.ole.docstore.model.xmlpojo.ingest.ResponseDocument; 025import org.kuali.ole.describe.service.DiscoveryHelperService; 026import org.kuali.ole.ingest.pojo.ProfileAttributeBo; 027import org.kuali.ole.pojo.OleBibRecord; 028import org.kuali.ole.pojo.OleOrderRecord; 029import org.kuali.ole.pojo.ProfileAttribute; 030import org.kuali.ole.pojo.edi.EDIOrder; 031import org.kuali.ole.pojo.edi.LineItemOrder; 032import org.kuali.ole.service.OleOrderRecordService; 033import org.kuali.ole.service.OleOverlayActionService; 034import org.kuali.ole.sys.context.SpringContext; 035import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 036import org.kuali.rice.krms.api.engine.ExecutionEnvironment; 037import org.kuali.rice.krms.framework.engine.Action; 038 039import java.text.DateFormat; 040import java.text.SimpleDateFormat; 041import java.util.*; 042 043/** 044 * CreateBibAction is the action class for BatchIngest(Staff upload screen) which creates a bibliographic 045 * record in Docstore. 046 */ 047public class CreateBibAction implements Action { 048 private DiscoveryHelperService discoveryHelperService; 049 private OleOrderRecordService oleOrderRecordService; 050 private OleOverlayActionService oleOverlayActionService; 051 private OLEBatchProcessProfileBo oleBatchProcessProfileBo; 052 053 private DocstoreClientLocator docstoreClientLocator; 054 055 public DocstoreClientLocator getDocstoreClientLocator() { 056 057 if (docstoreClientLocator == null) { 058 docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class); 059 060 } 061 return docstoreClientLocator; 062 } 063 064 private List<ProfileAttribute> attributes = new ArrayList<ProfileAttribute>(); 065 066 public OLEBatchProcessProfileBo getOleBatchProcessProfileBo() { 067 return oleBatchProcessProfileBo; 068 } 069 070 public void setOleBatchProcessProfileBo(OLEBatchProcessProfileBo oleBatchProcessProfileBo) { 071 this.oleBatchProcessProfileBo = oleBatchProcessProfileBo; 072 } 073 074 /** 075 * This method takes the initial request when creating the BibAction. 076 * 077 * @param executionEnvironment 078 */ 079 @Override 080 public void execute(ExecutionEnvironment executionEnvironment) { 081 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE); 082 String ediXMLContent = (String) dataCarrierService.getData("ediXMLContent"); 083 if (ediXMLContent != null) { 084 executeForMarcEdi(executionEnvironment); 085 } else { 086 executeForMarc(executionEnvironment); 087 } 088 } 089 090 091 private List getBibInfo(String instanceUUID) { 092 return getDiscoveryHelperService().getBibInformationFromInsatnceId(instanceUUID); 093 } 094 095 public void executeForMarcEdi(ExecutionEnvironment executionEnvironment) { 096 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE); 097 List<ProfileAttributeBo> profileAttributes = (List<ProfileAttributeBo>) dataCarrierService.getData(OLEConstants.PROFILE_ATTRIBUTE_LIST); 098 BibMarcRecord bibMarcRecord = (BibMarcRecord) dataCarrierService.getData(OLEConstants.REQUEST_BIB_RECORD); 099 LineItemOrder lineItemOrder = (LineItemOrder) dataCarrierService.getData(OLEConstants.REQUEST_LINE_ITEM_ORDER_RECORD); 100 EDIOrder ediOrder = (EDIOrder) dataCarrierService.getData(OLEConstants.EDI_ORDER); 101 String profileName = (String) dataCarrierService.getData(OLEConstants.PROFILE_NM); 102 oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) dataCarrierService.getData(OLEConstants.BATCH_PROFILE_BO); 103 try { 104 // String Ndocst = docstoreHelperService.persistNewToDocstoreForIngest(lineItemOrder,bibliographicRecord, profileAttributes); 105 106 107 // BibMarcRecord bibMarcRecord = loanProcessor.getBibMarcRecord(oleLoanForm.getOleLoanFastAdd().getTitle(), oleLoanForm.getOleLoanFastAdd().getAuthor()); 108 109 List<BibMarcRecord> bibMarcRecordList = new ArrayList<>(); 110 bibMarcRecordList.add(bibMarcRecord); 111 BibMarcRecords bibMarcRecords = new BibMarcRecords(); 112 bibMarcRecords.setRecords(bibMarcRecordList); 113 BibMarcRecordProcessor bibMarcRecordProcessor = new BibMarcRecordProcessor(); 114 Bib bib = new BibMarc(); 115 bib.setCategory(DocCategory.WORK.getCode()); 116 bib.setType(DocType.BIB.getCode()); 117 bib.setFormat(DocFormat.MARC.getCode()); 118 bib.setContent(bibMarcRecordProcessor.toXml(bibMarcRecords)); 119 List<Item> oleItemList = new ArrayList<Item>(); 120 oleItemList.add(getOleItem(lineItemOrder, bibMarcRecord)); 121 List<org.kuali.ole.docstore.common.document.Item> itemXml = new ArrayList<org.kuali.ole.docstore.common.document.Item>(); 122 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor(); 123 for (Item item : oleItemList) { 124 org.kuali.ole.docstore.common.document.Item itemXmlContent = new ItemOleml(); 125 itemXmlContent.setContent(itemOlemlRecordProcessor.toXML(item)); 126 itemXml.add(itemXmlContent); 127 128 } 129 this.attributes = buildListOfProfileAttributes(profileAttributes); 130 OleHoldings oleHoldings = new OleHoldingsRecordHandler().getOleHoldings(bibMarcRecord, attributes); 131 Holdings holdings = new PHoldings(); 132 DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); 133 holdings.setCreatedOn(String.valueOf(dateFormat.format(new Date()))); 134 holdings.setLastUpdated(String.valueOf(dateFormat.format(new Date()))); 135 holdings.setPublic(false); 136 holdings.setFastAdd(false); 137 //holdings.setHarvestable("true"); 138 holdings.setStatus("n"); 139 140 141 Uri uri = new Uri(); 142 uri.setValue(""); 143 uri.setResolvable(null); 144 oleHoldings.getUri().add(uri); 145 Note note = new Note(); 146 note.setType(OLEConstants.NOTE_TYPE); 147 oleHoldings.getNote().add(note); 148 CallNumber callNumber = new CallNumber(); 149 ShelvingScheme shelvingScheme = new ShelvingScheme(); 150 ShelvingOrder shelvingOrder = new ShelvingOrder(); 151 callNumber.setType(""); 152 callNumber.setPrefix(""); 153 callNumber.setNumber(""); 154 shelvingScheme.setCodeValue(""); 155 shelvingOrder.setCodeValue(""); 156 callNumber.setShelvingScheme(shelvingScheme); 157 callNumber.setShelvingOrder(shelvingOrder); 158 oleHoldings.setCallNumber(callNumber); 159 if (oleHoldings.getLocation() == null) { 160 LocationLevel locationLevel = new LocationLevel(); 161 Location location = new Location(); 162 locationLevel.setLevel(""); 163 locationLevel.setName(""); 164 location.setPrimary(OLEConstants.TRUE); 165 location.setStatus(OLEConstants.PERMANENT); 166 location.setLocationLevel(locationLevel); 167 oleHoldings.setLocation(location); 168 } 169 170 HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor(); 171 holdings.setContent(holdingOlemlRecordProcessor.toXML(oleHoldings)); 172 HoldingsTree holdingsTree = new HoldingsTree(); 173 holdingsTree.setHoldings(holdings); 174 holdingsTree.getItems().addAll(itemXml); 175 BibTree bibTree = new BibTree(); 176 bibTree.setBib(bib); 177 bibTree.getHoldingsTrees().add(holdingsTree); 178 try { 179 getDocstoreClientLocator().getDocstoreClient().createBibTree(bibTree); 180 } catch (Exception ex) { 181 ex.printStackTrace(); 182 } 183 184 HashMap<String, Object> objects = new HashMap<String, Object>(); 185 objects.put(OLEConstants.MRC, bibMarcRecord); 186 objects.put(OLEConstants.EDI, lineItemOrder); 187 /*ResponseHandler responseHander = new ResponseHandler(); 188 Response response = responseHander.toObject(responseFromDocstore);*/ 189 BibTree bib_Tree=getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(bibTree.getBib().getId()); 190 if (bib_Tree==null) { 191 Thread.sleep(2000); 192 bib_Tree=getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(bibTree.getBib().getId()); 193 } 194 String holdingsUUID = bib_Tree.getHoldingsTrees().get(0).getHoldings().getId(); 195 //String instanceUUID = getUUID(response, OLEConstants.INSTANCE_DOC_TYPE); 196 if (null == holdingsUUID) { 197 throw new Exception("instance id returned from docstore is null"); 198 } 199 /*List bibInfo = getBibInfo(instanceUUID); 200 if (bibInfo.isEmpty()) { 201 Thread.sleep(2000); 202 bibInfo = getBibInfo(instanceUUID); 203 }*/ 204 OleBibRecord oleBibRecord = new OleBibRecord(); 205 //Map<String, List> bibFieldValues = (Map<String, List>) bibInfo.get(0); 206 //oleBibRecord.setBibAssociatedFieldsValueMap(bibFieldValues); 207 oleBibRecord.setBib(bib_Tree.getBib()); 208 oleBibRecord.setLinkedInstanceId(holdingsUUID); 209 // oleBibRecord.setBibUUID(getUUID(response, OLEConstants.BIB_DOC_TYPE)); 210 oleBibRecord.setBibUUID(bibTree.getBib().getId()); 211 executionEnvironment.getEngineResults().setAttribute(OLEConstants.BIB_CREATION_FLAG, true); 212 OleOrderRecord oleOrderRecord = oleOrderRecordService.fetchOleOrderRecordForMarcEdi(null, ediOrder, bibMarcRecord,0, null); 213 oleOverlayActionService.performOverlayLookupAction(profileName, objects, holdingsUUID, oleOrderRecord); 214 executionEnvironment.getEngineResults().setAttribute(OLEConstants.OLE_ORDER_RECORD, oleOrderRecord); 215 } catch (Exception e) { 216 e.printStackTrace(); 217 executionEnvironment.getEngineResults().setAttribute(OLEConstants.OLE_ORDER_RECORD, null); 218 } 219 } 220 221 222 public void executeForMarc(ExecutionEnvironment executionEnvironment) { 223 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE); 224 List<ProfileAttributeBo> profileAttributes = (List<ProfileAttributeBo>) dataCarrierService.getData(OLEConstants.PROFILE_ATTRIBUTE_LIST); 225 BibMarcRecord bibMarcRecord = (BibMarcRecord) dataCarrierService.getData(OLEConstants.REQUEST_BIB_RECORD); 226 //LineItemOrder lineItemOrder = (LineItemOrder) dataCarrierService.getData(OLEConstants.REQUEST_LINE_ITEM_ORDER_RECORD); 227 // EDIOrder ediOrder = (EDIOrder) dataCarrierService.getData(OLEConstants.EDI_ORDER); 228 String profileName = (String) dataCarrierService.getData(OLEConstants.PROFILE_NM); 229 oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) dataCarrierService.getData(OLEConstants.BATCH_PROFILE_BO); 230 231 try { 232 // String responseFromDocstore = docstoreHelperService.persistNewToDocstoreForIngest(bibliographicRecord, profileAttributes); 233 List<BibMarcRecord> bibMarcRecordList = new ArrayList<>(); 234 bibMarcRecordList.add(bibMarcRecord); 235 BibMarcRecords bibMarcRecords = new BibMarcRecords(); 236 bibMarcRecords.setRecords(bibMarcRecordList); 237 BibMarcRecordProcessor bibMarcRecordProcessor = new BibMarcRecordProcessor(); 238 239 240 Bib bib = new BibMarc(); 241 bib.setCategory(DocCategory.WORK.getCode()); 242 bib.setType(DocType.BIB.getCode()); 243 bib.setFormat(DocFormat.MARC.getCode()); 244 bib.setContent(bibMarcRecordProcessor.toXml(bibMarcRecords)); 245 246 List<Item> oleItemList = new ArrayList<Item>(); 247 oleItemList.add(getOleItem(bibMarcRecord)); 248 List<org.kuali.ole.docstore.common.document.Item> itemXml = new ArrayList<org.kuali.ole.docstore.common.document.Item>(); 249 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor(); 250 for (Item item : oleItemList) { 251 org.kuali.ole.docstore.common.document.Item itemXmlContent = new ItemOleml(); 252 itemXmlContent.setContent(itemOlemlRecordProcessor.toXML(item)); 253 itemXml.add(itemXmlContent); 254 255 } 256 257 this.attributes = buildListOfProfileAttributes(profileAttributes); 258 259 OleHoldings oleHoldings = new OleHoldingsRecordHandler().getOleHoldings(bibMarcRecord, attributes); 260 Holdings holdings = new PHoldings(); 261 262 DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); 263 holdings.setCreatedOn(String.valueOf(dateFormat.format(new Date()))); 264 holdings.setLastUpdated(String.valueOf(dateFormat.format(new Date()))); 265 holdings.setPublic(false); 266 holdings.setFastAdd(false); 267 // holdings.setHarvestable("true"); 268 holdings.setStatus("n"); // new Record 269 270 //List<Extension> extensionList = new ArrayList<Extension>(); 271 //extensionList.add(extension); 272 // oleHoldings.setExtension(extension); 273 oleHoldings.setPrimary(OLEConstants.TRUE); 274 //oleInstance.getOleHoldings().setReceiptStatus(""); 275 Uri uri = new Uri(); 276 uri.setValue(""); 277 uri.setResolvable(null); 278 oleHoldings.getUri().add(uri); 279 Note note = new Note(); 280 note.setType(OLEConstants.NOTE_TYPE); 281 oleHoldings.getNote().add(note); 282 CallNumber callNumber = new CallNumber(); 283 ShelvingScheme shelvingScheme = new ShelvingScheme(); 284 ShelvingOrder shelvingOrder = new ShelvingOrder(); 285 callNumber.setType(""); 286 callNumber.setPrefix(""); 287 callNumber.setNumber(""); 288 shelvingScheme.setCodeValue(""); 289 shelvingOrder.setCodeValue(""); 290 callNumber.setShelvingScheme(shelvingScheme); 291 callNumber.setShelvingOrder(shelvingOrder); 292 oleHoldings.setCallNumber(callNumber); 293 // List<Instance> oleInstanceList = new ArrayList<Instance>(); 294 //OleHoldings oleHoldings = oleInstance.getOleHoldings(); 295 if (oleHoldings.getLocation() == null) { 296 LocationLevel locationLevel = new LocationLevel(); 297 Location location = new Location(); 298 locationLevel.setLevel(""); 299 locationLevel.setName(""); 300 location.setPrimary(OLEConstants.TRUE); 301 location.setStatus(OLEConstants.PERMANENT); 302 location.setLocationLevel(locationLevel); 303 oleHoldings.setLocation(location); 304 } 305 306 307 HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor(); 308 holdings.setContent(holdingOlemlRecordProcessor.toXML(oleHoldings)); 309 310 HoldingsTree holdingsTree = new HoldingsTree(); 311 312 holdingsTree.setHoldings(holdings); 313 holdingsTree.getItems().addAll(itemXml); 314 315 316 BibTree bibTree = new BibTree(); 317 bibTree.setBib(bib); 318 bibTree.getHoldingsTrees().add(holdingsTree); 319 320 321 try { 322 getDocstoreClientLocator().getDocstoreClient().createBibTree(bibTree); 323 } catch (Exception ex) { 324 ex.printStackTrace(); 325 } 326 327 328 HashMap<String, Object> objects = new HashMap<String, Object>(); 329 objects.put(OLEConstants.MRC, bibMarcRecord); 330 // objects.put(OLEConstants.EDI,lineItemOrder); 331 /* ResponseHandler responseHander = new ResponseHandler(); 332 Response response = responseHander.toObject(responseFromDocstore);*/ 333 334 BibTree bib_Tree=getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(bibTree.getBib().getId()); 335 if (bib_Tree == null) { 336 Thread.sleep(2000); 337 bib_Tree=getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(bibTree.getBib().getId()); 338 } 339 String holdingsUUID = bib_Tree.getHoldingsTrees().get(0).getHoldings().getId(); 340 // String instanceUUID=getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(bibTree.getBib().getId()).getHoldingsTrees().get(0).getHoldings().getId(); 341 if (null == holdingsUUID) { 342 throw new Exception("instance id returned from docstore is null"); 343 } 344/* List bibInfo = getBibInfo(instanceUUID); 345 if (bibInfo.isEmpty()) { 346 Thread.sleep(2000); 347 bibInfo = getBibInfo(instanceUUID); 348 }*/ 349 OleBibRecord oleBibRecord = new OleBibRecord(); 350 //Map<String, List> bibFieldValues = (Map<String, List>) bibInfo.get(0); 351 //oleBibRecord.setBibAssociatedFieldsValueMap(bibFieldValues); 352 oleBibRecord.setBib(bib_Tree.getBib()); 353 oleBibRecord.setLinkedInstanceId(holdingsUUID); 354 oleBibRecord.setBibUUID(bibTree.getBib().getId()); 355 executionEnvironment.getEngineResults().setAttribute(OLEConstants.BIB_CREATION_FLAG, true); 356 OleOrderRecord oleOrderRecord = oleOrderRecordService.fetchOleOrderRecordForMarc(null,bibMarcRecord,0, null); 357 boolean validBFNFlag = (Boolean) (oleOrderRecord.getMessageMap().get("isValidBFN") == null ? true : oleOrderRecord.getMessageMap().get("isValidBFN")); 358 if (validBFNFlag) { 359 oleOverlayActionService.performOverlayLookupAction(profileName, objects, holdingsUUID, oleOrderRecord); 360 } 361 executionEnvironment.getEngineResults().setAttribute(OLEConstants.OLE_ORDER_RECORD, oleOrderRecord); 362 } catch (Exception e) { 363 e.printStackTrace(); 364 executionEnvironment.getEngineResults().setAttribute(OLEConstants.OLE_ORDER_RECORD, null); 365 } 366 } 367 368 /** 369 * This method simulate the executionEnvironment. 370 * 371 * @param executionEnvironment 372 */ 373 374 @Override 375 public void executeSimulation(ExecutionEnvironment executionEnvironment) { 376 execute(executionEnvironment); 377 } 378 379 /** 380 * This method gets the uuid based on docType 381 * 382 * @param response 383 * @param docType 384 * @return uuid 385 */ 386 private String getUUID(Response response, String docType) { 387 List<ResponseDocument> documents = response.getDocuments(); 388 return getUUID(documents, docType); 389 } 390 391 /** 392 * This method gets the uuid based on List of documents and docType. 393 * 394 * @param documents 395 * @param docType 396 * @return uuid 397 */ 398 private String getUUID(List<ResponseDocument> documents, String docType) { 399 for (Iterator<ResponseDocument> iterator = documents.iterator(); iterator.hasNext(); ) { 400 ResponseDocument responseDocument = iterator.next(); 401 if (responseDocument.getType().equals(docType)) { 402 return responseDocument.getUuid(); 403 } else { 404 return getUUID(responseDocument.getLinkedDocuments(), docType); 405 } 406 } 407 return null; 408 } 409 410 411 /** 412 * Sets the discoveryHelperService attribute value. 413 * 414 * @param discoveryHelperService .The discoveryHelperService to set. 415 */ 416 public void setDiscoveryHelperService(DiscoveryHelperService discoveryHelperService) { 417 this.discoveryHelperService = discoveryHelperService; 418 } 419 420 /** 421 * Gets the discoveryHelperService attribute. 422 * 423 * @return Returns discoveryHelperService. 424 */ 425 public DiscoveryHelperService getDiscoveryHelperService() { 426 return discoveryHelperService; 427 } 428 429 public OleOrderRecordService getOleOrderRecordService() { 430 return oleOrderRecordService; 431 } 432 433 public void setOleOrderRecordService(OleOrderRecordService oleOrderRecordService) { 434 this.oleOrderRecordService = oleOrderRecordService; 435 } 436 437 public OleOverlayActionService getOleOverlayActionService() { 438 return oleOverlayActionService; 439 } 440 441 public void setOleOverlayActionService(OleOverlayActionService oleOverlayActionService) { 442 this.oleOverlayActionService = oleOverlayActionService; 443 } 444 445 private List<ProfileAttribute> buildListOfProfileAttributes(List<ProfileAttributeBo> profileAttributes) { 446 for (Iterator iterator = profileAttributes.iterator(); iterator.hasNext(); ) { 447 ProfileAttributeBo profileAttributeBo = (ProfileAttributeBo) iterator.next(); 448 ProfileAttribute profileAttribute = new ProfileAttribute(); 449 profileAttribute.setAgendaName(profileAttributeBo.getAgendaName()); 450 profileAttribute.setAttributeName(profileAttributeBo.getAttributeName()); 451 profileAttribute.setAttributeValue(profileAttributeBo.getAttributeValue()); 452 profileAttribute.setSystemValue(profileAttributeBo.getSystemValue()); 453 attributes.add(profileAttribute); 454 } 455 return attributes; 456 } 457 458 public Item getOleItem(LineItemOrder lineItemOrder, BibMarcRecord bibliographicRecord) { 459 for (DataField dataField : bibliographicRecord.getDataFields()) { 460 if (dataField.getTag().equalsIgnoreCase(OLEConstants.DATA_FIELD_985)) { 461 List<SubField> subFieldList = dataField.getSubFields(); 462 SubField subField = new SubField(); 463 subField.setCode(OLEConstants.SUB_FIELD_A); 464 subField.setValue(OLEConstants.DEFAULT_LOCATION_LEVEL_INSTITUTION); 465 subFieldList.add(subField); 466 dataField.setSubFields(subFieldList); 467 } 468 } 469 return new OleItemRecordHandler().getOleItem(lineItemOrder, bibliographicRecord, attributes); 470 } 471 472 public Item getOleItem(BibMarcRecord bibliographicRecord) { 473 for (DataField dataField : bibliographicRecord.getDataFields()) { 474 if (dataField.getTag().equalsIgnoreCase(OLEConstants.DATA_FIELD_985)) { 475 List<SubField> subFieldList = dataField.getSubFields(); 476 SubField subField = new SubField(); 477 subField.setCode(OLEConstants.SUB_FIELD_A); 478 subField.setValue(OLEConstants.DEFAULT_LOCATION_LEVEL_INSTITUTION); 479 subFieldList.add(subField); 480 dataField.setSubFields(subFieldList); 481 } 482 } 483 return new OleItemRecordHandler().getOleItem(bibliographicRecord, attributes); 484 } 485 486}