001package org.kuali.ole.docstore.document.rdbms; 002 003import org.apache.commons.lang.StringUtils; 004import org.kuali.ole.DocumentUniqueIDPrefix; 005import org.kuali.ole.docstore.OleDocStoreException; 006import org.kuali.ole.docstore.common.document.content.instance.*; 007import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor; 008import org.kuali.ole.docstore.common.document.content.instance.xstream.InstanceOlemlRecordProcessor; 009import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor; 010import org.kuali.ole.docstore.discovery.service.QueryServiceImpl; 011 012import org.kuali.ole.docstore.model.enums.DocCategory; 013import org.kuali.ole.docstore.model.enums.DocFormat; 014import org.kuali.ole.docstore.model.enums.DocType; 015import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.*; 016import org.kuali.ole.docstore.model.xmlpojo.ingest.AdditionalAttributes; 017import org.kuali.ole.docstore.model.xmlpojo.ingest.Content; 018import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument; 019import org.kuali.ole.docstore.model.xmlpojo.ingest.ResponseDocument; 020import org.kuali.ole.docstore.common.document.content.instance.OleHoldings; 021import org.kuali.ole.docstore.common.document.content.instance.ShelvingScheme; 022import org.kuali.rice.krad.service.BusinessObjectService; 023import org.kuali.rice.krad.service.KRADServiceLocator; 024import org.slf4j.Logger; 025import org.slf4j.LoggerFactory; 026 027import javax.jcr.Node; 028import java.util.ArrayList; 029import java.util.HashMap; 030import java.util.List; 031import java.util.Map; 032 033/** 034 * Created with IntelliJ IDEA. 035 * User: Sreekanth 036 * Date: 7/1/13 037 * Time: 10:25 AM 038 * To change this template use File | Settings | File Templates. 039 */ 040public class RdbmsWorkItemDocumentManager extends RdbmsWorkInstanceDocumentManager { 041 042 private static RdbmsWorkItemDocumentManager ourInstanceRdbms = null; 043 private static final Logger LOG = LoggerFactory 044 .getLogger(RdbmsWorkItemDocumentManager.class); 045 private BusinessObjectService businessObjectService; 046 047 public static RdbmsWorkItemDocumentManager getInstance() { 048 if (null == ourInstanceRdbms) { 049 ourInstanceRdbms = new RdbmsWorkItemDocumentManager(); 050 } 051 return ourInstanceRdbms; 052 } 053 054 public BusinessObjectService getBusinessObjectService() { 055 if (null == businessObjectService) { 056 businessObjectService = KRADServiceLocator.getBusinessObjectService(); 057 } 058 return businessObjectService; 059 } 060 061 @Override 062 public void deleteDocs(RequestDocument requestDocument, Object object) { 063 064 ResponseDocument responseDocument = new ResponseDocument(); 065 BusinessObjectService businessObjectService = (BusinessObjectService) object; 066 //ItemRecord itemRecord = new ItemRecord(); 067 String itemId = DocumentUniqueIDPrefix.getDocumentId(requestDocument.getUuid()); 068 Map itemMap = new HashMap(); 069 itemMap.put("itemId", itemId); 070 List<ItemRecord> itemRecords = (List<ItemRecord>) businessObjectService.findMatching(ItemRecord.class, itemMap); 071 if (itemRecords != null && itemRecords.size() > 0) { 072 ItemRecord itemRecord = itemRecords.get(0); 073 if (itemRecord.getFormerIdentifierRecords() != null && itemRecord.getFormerIdentifierRecords().size() > 0) { 074 List<FormerIdentifierRecord> formerIdentifierRecords = itemRecord.getFormerIdentifierRecords(); 075 businessObjectService.delete(formerIdentifierRecords); 076 } 077 078 079 if (itemRecord.getItemNoteRecords() != null && itemRecord.getItemNoteRecords().size() > 0) { 080 List<ItemNoteRecord> itemNoteRecords = itemRecord.getItemNoteRecords(); 081 businessObjectService.delete(itemNoteRecords); 082 } 083 084 085 if (itemRecord.getLocationsCheckinCountRecords() != null && itemRecord.getLocationsCheckinCountRecords().size() > 0) { 086 List<LocationsCheckinCountRecord> locationsCheckinCountRecords = itemRecord.getLocationsCheckinCountRecords(); 087 businessObjectService.delete(locationsCheckinCountRecords); 088 } 089 itemRecord.setItemStatusId(null); 090 itemRecord.setItemTypeId(null); 091 itemRecord.setTempItemTypeId(null); 092 itemRecord.setStatisticalSearchId(null); 093 itemRecord.setHighDensityStorageId(null); 094 businessObjectService.delete(itemRecord); 095 buildResponseDocument(requestDocument, itemRecord, responseDocument); 096 } 097 098 } 099 100 @Override 101 public ResponseDocument checkoutContent(RequestDocument requestDocument, Object object) { 102 ResponseDocument responseDocument = new ResponseDocument(); 103 BusinessObjectService businessObjectService = (BusinessObjectService) object; 104 Map parentCriteria1 = new HashMap(); 105 parentCriteria1.put("itemId", DocumentUniqueIDPrefix.getDocumentId(requestDocument.getUuid())); 106 List<ItemRecord> itemRecordList = (List<ItemRecord>) getBusinessObjectService().findMatching(ItemRecord.class, parentCriteria1); 107 if (itemRecordList != null && itemRecordList.size() > 0) { 108 ItemRecord itemRecord = itemRecordList.get(0); 109 Item item = buildItemContent(itemRecord); 110 String content = new InstanceOlemlRecordProcessor().toXML(item); 111 AdditionalAttributes additionalAttributes = new AdditionalAttributes(); 112 113 /*if(additionalAttributes.getAttribute(AdditionalAttributes.STAFFONLYFLAG)!=null) { 114 String staffOnlyFlagNew=additionalAttributes.getAttribute(AdditionalAttributes.STAFFONLYFLAG); 115 itemRecord.setStaffOnlyFlag(staffOnlyFlagNew); 116 }*/ 117 118 if (itemRecord.getStaffOnlyFlag() != null) { 119 additionalAttributes.setAttribute(AdditionalAttributes.STAFFONLYFLAG, itemRecord.getStaffOnlyFlag().toString()); 120 } 121 Content contentObj = new Content(); 122 contentObj.setContent(content); 123 responseDocument.setUuid(requestDocument.getUuid()); 124 responseDocument.setCategory(requestDocument.getCategory()); 125 responseDocument.setType(requestDocument.getType()); 126 responseDocument.setFormat(requestDocument.getFormat()); 127 responseDocument.setContent(contentObj); 128 responseDocument.setAdditionalAttributes(additionalAttributes); 129 } else { 130 responseDocument.setStatus("Failed"); 131 responseDocument.setStatusMessage("Item does not exist."); 132 } 133 return responseDocument; 134 135 } 136 137 138 @Override 139 public void checkInContent(RequestDocument requestDocument, Object object, ResponseDocument respDoc) throws OleDocStoreException { 140 BusinessObjectService businessObjectService = (BusinessObjectService) object; 141 modifyContent(requestDocument, DocumentUniqueIDPrefix.getDocumentId(requestDocument.getId())); 142 AdditionalAttributes attributes = requestDocument.getAdditionalAttributes(); 143 List<ItemRecord> itemRecords = new ArrayList<ItemRecord>(); 144 String instanceId = ""; 145 Map parentCriteria1 = new HashMap(); 146 parentCriteria1.put("itemId", DocumentUniqueIDPrefix.getDocumentId(requestDocument.getId())); 147 ItemRecord itemRecord = getBusinessObjectService().findByPrimaryKey(ItemRecord.class, parentCriteria1); 148 Item item = new ItemOlemlRecordProcessor().fromXML(requestDocument.getContent().getContent()); 149 if (attributes != null) { 150 itemRecord.setStaffOnlyFlag(Boolean.valueOf(attributes.getAttribute(AdditionalAttributes.STAFFONLYFLAG))); 151 } 152 buildItemContentForCheckin(item, itemRecord); 153 requestDocument.setUuid(DocumentUniqueIDPrefix.getPrefixedId(itemRecord.getUniqueIdPrefix(), itemRecord.getItemId())); 154 respDoc.setAdditionalAttributes(attributes); 155 buildResponseDocument(requestDocument, itemRecord, respDoc); 156 } 157 158 @Override 159 public Node storeDocument(RequestDocument requestDocument, Object object, ResponseDocument responseDocument) 160 throws OleDocStoreException { 161 return null; 162 } 163 164 @Override 165 public void validateInput(RequestDocument requestDocument, Object object, List<String> valuesList) throws OleDocStoreException { 166 BusinessObjectService businessObjectService = (BusinessObjectService) object; 167 validateItem(requestDocument, businessObjectService, valuesList); 168 } 169 170 @Override 171 public ResponseDocument deleteVerify(RequestDocument requestDocument, Object object) throws Exception { 172 173 // BusinessObjectService businessObjectService = (BusinessObjectService) object; 174 LOG.debug("workItemDocumentManager deleteVerify method"); 175 //List<String> instanceIdentifierList = new ArrayList<String>(); 176 ResponseDocument responseDocument = new ResponseDocument(); 177 List<String> itemIdentifierList = new ArrayList<String>(); 178 itemIdentifierList.add(requestDocument.getUuid()); 179 boolean exists = checkInstancesOrItemsExistsInOLE(itemIdentifierList); 180 if (exists) { 181 responseDocument.setId(requestDocument.getId()); 182 responseDocument.setCategory(requestDocument.getCategory()); 183 responseDocument.setType(requestDocument.getType()); 184 responseDocument.setFormat(requestDocument.getFormat()); 185 responseDocument.setUuid(requestDocument.getUuid()); 186 responseDocument.setStatus("failure'"); 187 responseDocument.setStatusMessage("Instances or Items in use. So deletion cannot be done"); 188 return responseDocument; 189 } 190 else { 191 responseDocument.setUuid(requestDocument.getUuid()); 192 responseDocument.setId(requestDocument.getId()); 193 responseDocument.setCategory(requestDocument.getCategory()); 194 responseDocument.setType(requestDocument.getType()); 195 responseDocument.setFormat(requestDocument.getFormat()); 196 responseDocument.setStatus("success"); 197 responseDocument.setStatusMessage("success"); 198 } 199 200 /* int itemSize = 0; 201 String instanceIdentifier = ""; 202 Map itemMap = new HashMap(); 203 itemMap.put("itemId", DocumentUniqueIDPrefix.getDocumentId(requestDocument.getUuid())); 204 List<ItemRecord> itemRecords = (List<ItemRecord>) businessObjectService.findMatching(ItemRecord.class, itemMap); 205 if (itemRecords != null & itemRecords.size() == 1) { 206 instanceIdentifier = itemRecords.get(0).getHoldingsId(); 207 } 208 209 Map instanceMap = new HashMap(); 210 instanceMap.put("instanceId", instanceIdentifier); 211 itemRecords = (List<ItemRecord>) businessObjectService.findMatching(ItemRecord.class, instanceMap); 212 if (itemRecords != null) { 213 itemSize = itemRecords.size(); 214 } 215 216 if (StringUtils.isNotEmpty(instanceIdentifier)) { 217 String prefix = DocumentUniqueIDPrefix.getPrefix(DocCategory.WORK.getCode(), DocType.INSTANCE.getCode(), DocFormat.OLEML.getCode()); 218 requestDocument.setUuid(DocumentUniqueIDPrefix.getPrefixedId(prefix, instanceIdentifier)); 219 requestDocument.setCategory(DocCategory.WORK.getCode()); 220 requestDocument.setType(DocType.INSTANCE.getCode()); 221 requestDocument.setFormat(DocFormat.OLEML.getCode()); 222 responseDocument = RdbmsWorkInstanceDocumentManager.getInstance().deleteVerify(requestDocument, businessObjectService); 223 } else { 224 responseDocument.setUuid(requestDocument.getUuid()); 225 responseDocument.setId(requestDocument.getId()); 226 responseDocument.setCategory(requestDocument.getCategory()); 227 responseDocument.setType(requestDocument.getType()); 228 responseDocument.setFormat(requestDocument.getFormat()); 229 responseDocument.setStatus("success"); 230 responseDocument.setStatusMessage("success"); 231 } */ 232 233 return responseDocument; 234 } 235 236 public ResponseDocument buildResponseDocument(RequestDocument requestDocument, ItemRecord itemRecord, ResponseDocument responseDocument) { 237 responseDocument.setId(itemRecord.getItemId()); 238 responseDocument.setCategory(requestDocument.getCategory()); 239 responseDocument.setType(requestDocument.getType()); 240 responseDocument.setFormat(requestDocument.getFormat()); 241 responseDocument.setUuid(itemRecord.getItemId()); 242 // responseDocument.setId(itemRecord.getInstanceId()); 243 return responseDocument; 244 } 245 246 public void validateNewItem(RequestDocument linkedRequestDocument, BusinessObjectService businessObjectService, List<String> fieldValues, String id) throws OleDocStoreException { 247 try { 248 String itemContent = linkedRequestDocument.getContent().getContent(); 249 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor(); 250 Item item = itemOlemlRecordProcessor.fromXML(itemContent); 251 itemBarcodeValidation(item, fieldValues, null); 252 253 if (item.getCallNumber() != null) { 254 Map instanceMap = new HashMap(); 255 instanceMap.put("instanceId", DocumentUniqueIDPrefix.getDocumentId(id)); 256 List<InstanceRecord> instanceRecords = (List<InstanceRecord>) getBusinessObjectService().findMatching(InstanceRecord.class, instanceMap); 257 HoldingsRecord holdingsRecord = null; 258 if (instanceRecords != null && instanceRecords.size() > 0) { 259 List<HoldingsRecord> holdingsRecords = instanceRecords.get(0).getHoldingsRecords(); 260 if (holdingsRecords != null && holdingsRecords.size() > 0) { 261 holdingsRecord = holdingsRecords.get(0); 262 getHoldingsContentNValidateItem(holdingsRecord, item, getBusinessObjectService()); 263 } 264 } 265 } 266 } catch (Exception e) { 267 throw new OleDocStoreException(e.getMessage(), e); 268 } 269 } 270 271 public void itemBarcodeValidation(Item item, List<String> fieldValues, String id) throws OleDocStoreException { 272 if (item.getAccessInformation() != null && StringUtils.isNotEmpty(item.getAccessInformation().getBarcode())) { 273 try { 274 if (fieldValues.contains(item.getAccessInformation().getBarcode()) || 275 QueryServiceImpl.getInstance().isFieldValueExists(DocType.ITEM.getCode(), "ItemBarcode_display", item.getAccessInformation().getBarcode(), id)) { 276 throw new OleDocStoreException("Barcode " + item.getAccessInformation().getBarcode() + " already exists "); 277 } 278 fieldValues.add(item.getAccessInformation().getBarcode()); 279 } catch (Exception e) { 280 throw new OleDocStoreException(e.getMessage(), e); 281 } 282 } 283 284 } 285 286 public void validateItem(RequestDocument linkedRequestDocument, BusinessObjectService businessObjectService, List<String> fieldValues) throws OleDocStoreException { 287 try { 288 String itemContent = linkedRequestDocument.getContent().getContent(); 289 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor(); 290 Item item = itemOlemlRecordProcessor.fromXML(itemContent); 291 //TODO:Ignored this validation as it affecting check in operation for an existing barcode 292 itemBarcodeValidation(item, fieldValues, linkedRequestDocument.getId()); 293 if (item.getCallNumber() != null) { 294 Map itemMap = new HashMap(); 295 itemMap.put("itemId", DocumentUniqueIDPrefix.getDocumentId(linkedRequestDocument.getId())); 296 List<ItemRecord> itemRecords = (List<ItemRecord>) getBusinessObjectService().findMatching(ItemRecord.class, itemMap); 297 if (itemRecords != null && itemRecords.size() > 0) { 298 Map instanceMap = new HashMap(); 299 // instanceMap.put("instanceId", itemRecords.get(0).getInstanceId()); 300 List<InstanceRecord> instanceRecords = (List<InstanceRecord>) getBusinessObjectService().findMatching(InstanceRecord.class, instanceMap); 301 HoldingsRecord holdingsRecord = null; 302 if (instanceRecords != null && instanceRecords.size() > 0) { 303 List<HoldingsRecord> holdingsRecords = instanceRecords.get(0).getHoldingsRecords(); 304 if (holdingsRecords != null && holdingsRecords.size() > 0) { 305 holdingsRecord = holdingsRecords.get(0); 306 getHoldingsContentNValidateItem(holdingsRecord, item, getBusinessObjectService()); 307 } 308 } 309 310 } 311 } 312 } catch (Exception e) { 313 throw new OleDocStoreException(e.getMessage(), e); 314 } 315 } 316 317 private void getHoldingsContentNValidateItem(HoldingsRecord holdingsRecord, Item item, BusinessObjectService businessObjectService) throws Exception { 318 RequestDocument requestDocument = new RequestDocument(); 319 requestDocument.setUuid(DocumentUniqueIDPrefix.getPrefixedId(holdingsRecord.getUniqueIdPrefix(), holdingsRecord.getHoldingsId())); 320 ResponseDocument responseDocument = RdbmsWorkHoldingsDocumentManager.getInstance().checkoutContent(requestDocument, businessObjectService); 321 String content = responseDocument.getContent().getContent(); 322 HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor(); 323 OleHoldings oleHoldings = holdingOlemlRecordProcessor.fromXML(content); 324 CallNumber callNumber = item.getCallNumber(); 325 validateCallNumber(callNumber, oleHoldings); 326 } 327 328 protected void buildItemContentForCheckin(Item item, ItemRecord itemRecord) { 329 330 saveItemRecord(item, itemRecord); 331 } 332 333 protected void modifyContent(RequestDocument reqDoc, String itemId) 334 throws OleDocStoreException { 335 if (reqDoc.getOperation().equalsIgnoreCase("checkIn")) { 336 ItemOlemlRecordProcessor itemProcessor = new ItemOlemlRecordProcessor(); 337 338 if (reqDoc.getContent() != null && reqDoc.getContent().getContent() != null) { 339 // get new item content to check in 340 Item newItem = itemProcessor.fromXML(reqDoc.getContent().getContent()); 341 // verify new item call number and shelving scheme to build sortable call num 342 Boolean status = true; 343 if (newItem.getCallNumber() == null) { 344 newItem.setCallNumber(new CallNumber()); 345 } 346 CallNumber cNum = newItem.getCallNumber(); 347 if (!(cNum.getShelvingOrder() != null && cNum.getShelvingOrder().getFullValue() != null && 348 cNum.getShelvingOrder().getFullValue().trim().length() > 0)) { 349 if (!(cNum.getNumber() != null && cNum.getNumber().trim().length() > 0)) { 350 351 OleHoldings hold = getHoldings(itemId); 352 updateShelvingOrder(newItem, hold); 353 status = false; 354 } else { 355 updateShelvingOrder(newItem, null); 356 status = false; 357 } 358 } 359 if (status) { 360 //get already existing item content from rdbms. 361 String existingItemXml = null; 362 Map itemMap = new HashMap(); 363 itemMap.put("itemId", itemId); 364 List<ItemRecord> itemRecords = (List<ItemRecord>) getBusinessObjectService().findMatching(ItemRecord.class, itemMap); 365 if (itemRecords != null && itemRecords.size() > 0) { 366 ItemRecord itemRecord = itemRecords.get(0); 367 existingItemXml = itemProcessor.toXML(buildItemContent(itemRecord)); 368 } 369 370 // if new item contains shelving scheme and call number 371 if (existingItemXml != null) { 372 Item existItem = itemProcessor.fromXML(existingItemXml); 373 if (existItem.getCallNumber() == null) { 374 existItem.setCallNumber(new CallNumber()); 375 } 376 CallNumber existCNum = existItem.getCallNumber(); 377 setItemValuesFromNullToEmpty(existItem); 378 setItemValuesFromNullToEmpty(newItem); 379 cNum = newItem.getCallNumber(); 380 computeCallNumberType(cNum); 381 if (!(existCNum.getNumber().equalsIgnoreCase((cNum.getNumber()))) | 382 !(existCNum.getShelvingScheme().getCodeValue().equalsIgnoreCase(cNum.getShelvingScheme().getCodeValue())) | 383 !((existItem.getEnumeration()).equalsIgnoreCase(newItem.getEnumeration())) | 384 !((existItem.getChronology()).equalsIgnoreCase(newItem.getChronology())) | 385 !((existItem.getCopyNumber()).equalsIgnoreCase(newItem.getCopyNumber()))) { 386 if (!(cNum.getNumber() != null && cNum.getNumber().trim().length() > 0)) { 387 OleHoldings hold = getHoldings(itemId); 388 updateShelvingOrder(newItem, hold); 389 } else { 390 updateShelvingOrder(newItem, null); 391 } 392 393 } 394 } 395 } 396 reqDoc.getContent().setContent(itemProcessor.toXML(newItem)); 397 } 398 } 399 } 400 401 private OleHoldings getHoldings(String itemId) { 402 OleHoldings oleHoldings = null; 403 Map itemMap = new HashMap(); 404 itemMap.put("itemId", itemId); 405 List<ItemRecord> itemRecords = (List<ItemRecord>) getBusinessObjectService().findMatching(ItemRecord.class, itemMap); 406 if (itemRecords != null && itemRecords.size() > 0) { 407 ItemRecord itemRecord = itemRecords.get(0); 408 String instanceId = null;//itemRecord.getInstanceId(); 409 Map instanceMap = new HashMap(); 410 instanceMap.put("instanceId", instanceId); 411 List<InstanceRecord> instanceRecords = (List<InstanceRecord>) getBusinessObjectService().findMatching(InstanceRecord.class, instanceMap); 412 if (instanceRecords != null && instanceRecords.size() > 0) { 413 List<HoldingsRecord> holdingsRecords = instanceRecords.get(0).getHoldingsRecords(); 414 if (holdingsRecords != null && holdingsRecords.size() > 0) { 415 HoldingsRecord holdingsRecord = holdingsRecords.get(0); 416 oleHoldings = buildHoldingsContent(holdingsRecord); 417 } 418 } 419 } 420 return oleHoldings; 421 } 422 423 private void setItemValuesFromNullToEmpty(Item item) { 424 CallNumber existCNum = item.getCallNumber(); 425 if (existCNum == null) { 426 item.setCallNumber(new CallNumber()); 427 } 428 if (existCNum.getNumber() == null) { 429 existCNum.setNumber(""); 430 } 431 ShelvingScheme existSS = existCNum.getShelvingScheme(); 432 if (existSS == null) { 433 existCNum.setShelvingScheme(new ShelvingScheme()); 434 existSS = existCNum.getShelvingScheme(); 435 } 436 if (existSS != null && !(existSS.getCodeValue() != null && existSS.getCodeValue().trim().length() > 0)) { 437 existSS.setCodeValue(""); 438 } 439 if (item.getEnumeration() == null) { 440 item.setEnumeration(""); 441 } 442 if (item.getChronology() == null) { 443 item.setChronology(""); 444 } 445 if (item.getCopyNumber() == null) { 446 item.setCopyNumber(""); 447 } 448 } 449 450 protected void updateItemCallNumberFromHoldings(String instanceId, OleHoldings newHold, RequestDocument reqDoc) 451 throws OleDocStoreException { 452 Map instanceMap = new HashMap(); 453 instanceMap.put("instanceId", instanceId); 454 List<InstanceRecord> instanceRecords = (List<InstanceRecord>) getBusinessObjectService().findMatching(InstanceRecord.class, instanceMap); 455 InstanceRecord instanceRecord = null; 456 if (instanceRecords != null && instanceRecords.size() > 0) { 457 instanceRecord = instanceRecords.get(0); 458 } 459 if (instanceRecord != null) { 460 for (ItemRecord itemRecord : instanceRecord.getItemRecords()) { 461 ItemOlemlRecordProcessor itemProcessor = new ItemOlemlRecordProcessor(); 462 Item item = buildItemContent(itemRecord); 463 if (item != null) { 464 String itemId = itemRecord.getItemId(); 465 if (item.getCallNumber() == null) { 466 item.setCallNumber(new CallNumber()); 467 } 468 item.getCallNumber().setNumber(""); 469 if (item.getCallNumber().getShelvingScheme() != null) 470 item.getCallNumber().getShelvingScheme().setCodeValue(""); 471 updateShelvingOrder(item, newHold); 472 String newItemXml = itemProcessor.toXML(item); 473 buildRequestDocumentForItem(newItemXml, reqDoc, itemId); 474 } 475 476 } 477 } 478 } 479 480 private void buildRequestDocumentForItem(String newItemXml, RequestDocument reqDoc, String uuid) { 481 RequestDocument requestDocument = new RequestDocument(); 482 requestDocument.setOperation("checkIn"); 483 requestDocument.setCategory(DocCategory.WORK.getCode()); 484 requestDocument.setType(DocType.ITEM.getCode()); 485 requestDocument.setFormat(DocFormat.OLEML.getCode()); 486 requestDocument.setUuid(uuid); 487 requestDocument.setId(uuid); 488 Content content = new Content(); 489 content.setContent(newItemXml); 490 requestDocument.setContent(content); 491 List<RequestDocument> reqDocList = reqDoc.getLinkedRequestDocuments(); 492 if (reqDocList == null) { 493 reqDoc.setLinkedRequestDocuments(new ArrayList<RequestDocument>()); 494 } 495 reqDocList.add(requestDocument); 496 } 497 498 499}