1 package org.kuali.ole.loan;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.incubator.SolrRequestReponseHandler;
5 import org.kuali.ole.OLEConstants;
6 import org.kuali.ole.catalog.bo.OleInstanceItemType;
7 import org.kuali.ole.docstore.model.xmlpojo.ingest.AdditionalAttributes;
8 import org.kuali.ole.docstore.model.xmlpojo.work.instance.oleml.LocationLevel;
9 import org.kuali.ole.docstore.model.xmlpojo.work.instance.oleml.OleItem;
10 import org.kuali.ole.docstore.model.xmlpojo.work.instance.oleml.PhysicalLocation;
11 import org.kuali.ole.docstore.model.xstream.work.instance.oleml.WorkItemOlemlRecordProcessor;
12 import org.kuali.ole.editor.service.DocstoreHelperService;
13 import org.kuali.ole.ingest.pojo.MatchBo;
14 import org.kuali.ole.ingest.pojo.ProfileAttributeBo;
15 import org.kuali.ole.loan.bo.OleLoanDocument;
16 import org.kuali.ole.loan.bo.OleLoanStatus;
17 import org.kuali.ole.loan.bo.OleLoanTermUnit;
18 import org.kuali.ole.location.bo.OleLocation;
19 import org.kuali.ole.location.bo.OleLocationLevel;
20 import org.kuali.ole.patron.bo.OleBorrowerType;
21 import org.kuali.ole.patron.bo.OlePatronDocument;
22 import org.kuali.ole.service.OleCirculationPolicyService;
23 import org.kuali.ole.service.OleCirculationPolicyServiceImpl;
24 import org.kuali.rice.core.api.util.type.KualiInteger;
25 import org.kuali.rice.kim.impl.identity.name.EntityNameBo;
26 import org.kuali.rice.krad.service.BusinessObjectService;
27 import org.kuali.rice.krad.service.KRADServiceLocator;
28 import org.kuali.rice.krad.util.GlobalVariables;
29 import org.kuali.rice.krms.api.KrmsApiServiceLocator;
30 import org.kuali.rice.krms.api.engine.*;
31 import org.kuali.rice.krms.framework.engine.BasicRule;
32 import org.kuali.rice.krms.impl.repository.AgendaBo;
33
34 import java.sql.Date;
35 import java.sql.Timestamp;
36 import java.text.SimpleDateFormat;
37 import java.util.*;
38
39
40
41
42
43
44
45
46 public class LoanProcessor {
47 private static final Logger LOG = Logger.getLogger(LoanProcessor.class);
48
49 private BusinessObjectService businessObjectService;
50 private DocstoreHelperService docstoreHelperService;
51 private OleCirculationPolicyService oleCirculationPolicyService;
52
53 private static final String NAMESPACE_CODE_SELECTOR = "namespaceCode";
54 private static final String NAME_SELECTOR = "name";
55
56 private BusinessObjectService getBusinessObjectService() {
57 if (null == businessObjectService) {
58 businessObjectService = KRADServiceLocator.getBusinessObjectService();
59 }
60 return businessObjectService;
61 }
62
63 public OleCirculationPolicyService getOleCirculationPolicyService() {
64 if (null == oleCirculationPolicyService) {
65 oleCirculationPolicyService = new OleCirculationPolicyServiceImpl();
66 }
67 return oleCirculationPolicyService;
68 }
69
70 private DocstoreHelperService getDocstoreHelperService() {
71 if (null == docstoreHelperService) {
72 return new DocstoreHelperService();
73 }
74 return docstoreHelperService;
75 }
76
77
78
79
80
81
82 public OleLoanDocument getPatronDetails(String barcode) throws Exception{
83
84 return getPatronBarCodeRecord(barcode);
85 }
86
87 private OleLoanDocument getPatronBarCodeRecord(String barcode) throws Exception{
88 OleLoanDocument loanDocument = new OleLoanDocument();
89 try{
90 Map barMap = new HashMap();
91 barMap.put("barcode",barcode);
92 List<OlePatronDocument> matching = (List<OlePatronDocument>)getBusinessObjectService().findMatching(OlePatronDocument.class, barMap);
93 if(matching != null && matching.size() > 0){
94 loanDocument.setBorrowerTypeId(matching.get(0).getBorrowerType());
95 loanDocument.setBorrowerTypeName(getborrowerTypeName(loanDocument.getBorrowerTypeId()));
96 loanDocument.setPatronName(getPatronName(matching.get(0).getOlePatronId()));
97 loanDocument.setPatronId(matching.get(0).getOlePatronId());
98 return loanDocument;
99 } else {
100 LOG.error("Patron Barcode does not exist.");
101 throw new Exception("Patron Barcode does not exist.");
102 }
103 }catch (Exception e){
104 LOG.error("Patron Barcode does not exist.");
105 throw new Exception("Patron Barcode does not exist.");
106 }
107
108 }
109
110
111 public String getborrowerTypeName(String borrowerId) {
112 Map barMap = new HashMap();
113 barMap.put("borrowerTypeId",borrowerId);
114 OleBorrowerType oleBorrowerType = getBusinessObjectService().findBySinglePrimaryKey(OleBorrowerType.class,barMap);
115 return oleBorrowerType.getBorrowerTypeName();
116 }
117
118
119 private String getPatronName(String entityId) {
120 Map barMap = new HashMap();
121 barMap.put("entityId",entityId);
122 List<EntityNameBo> entityNameBo = (List<EntityNameBo>)getBusinessObjectService().findMatching(EntityNameBo.class,barMap);
123 return entityNameBo.get(0).getFirstName()+" "+entityNameBo.get(0).getLastName();
124 }
125
126 private String getEntityId(String name) {
127 Map barMap = new HashMap();
128 barMap.put("firstName",name);
129 List<EntityNameBo> entityNameBo = (List<EntityNameBo>)getBusinessObjectService().findMatching(EntityNameBo.class,barMap);
130 return entityNameBo.get(0).getEntityId();
131 }
132
133
134 public List<OleLoanDocument> getPatronLoanedItem(String patronId) throws Exception{
135 Map barMap = new HashMap();
136 barMap.put("patronId",patronId);
137 List<OleLoanDocument> matchingLoan = (List<OleLoanDocument>)getBusinessObjectService().findMatching(OleLoanDocument.class,barMap);
138 for(int itemid=0;itemid<matchingLoan.size();itemid++){
139 String itemUuid = matchingLoan.get(itemid).getItemId();
140 Map docStoreDetails = getItemDetails(itemUuid);
141 matchingLoan.get(itemid).setTitle(getTitlefromBib((String)docStoreDetails.get("bibUuid")));
142 matchingLoan.get(itemid).setItemUuid((String)docStoreDetails.get("itemUuid"));
143 }
144 return matchingLoan;
145 }
146
147
148
149
150
151
152
153 public Map getItemDetails(String itemBarcode) throws Exception{
154 SolrRequestReponseHandler solrRequestReponseHandler = new SolrRequestReponseHandler();
155 HashMap itemAndTitleDetails = new HashMap();
156 try {
157
158 List<HashMap<String, Object>> documentList= solrRequestReponseHandler.retriveResults("Barcode_display:"+itemBarcode);
159 HashMap<String, Object> itemvalues = documentList.get(0);
160 itemAndTitleDetails.put("instanceUuid",(String)((ArrayList)itemvalues.get("instanceIdentifier")).get(0));
161 itemAndTitleDetails.put("itemUuid",(String)((ArrayList)itemvalues.get("ItemIdentifier_display")).get(0));
162 if(itemvalues.get("bibIdentifier")!= null){
163 itemAndTitleDetails.put("bibUuid",(String)((ArrayList)itemvalues.get("bibIdentifier")).get(0));
164 }
165 return itemAndTitleDetails;
166 }
167 catch (Exception e) {
168 LOG.error("Item Barcode is not available in Docstore");
169 throw new Exception("Item Barcode is not available in Docstore");
170 }
171
172
173 }
174
175
176 private String getTitlefromBib(String bibUuid) throws Exception{
177 SolrRequestReponseHandler solrRequestReponseHandler = new SolrRequestReponseHandler();
178 try{
179 List<HashMap<String, Object>> bibDocumentList= solrRequestReponseHandler.retriveResults("id:"+bibUuid);
180 HashMap<String, Object> bibvalues = bibDocumentList.get(0);
181 return (String)((ArrayList)bibvalues.get("245a")).get(0);
182 }catch (Exception e){
183 LOG.error("Title does not exist.");
184 throw new Exception("Title does not exist in the docStore.");
185 }
186 }
187
188
189
190
191
192
193
194
195
196
197 public OleLoanDocument addLoan(String patronBarcode,String itemBarcode,OleLoanDocument oleLoanDocument) throws Exception{
198
199 Map itemUuid = getItemDetails(itemBarcode);
200 DocstoreHelperService docstoreHelperService = new DocstoreHelperService();
201 OleItem oleItem = null;
202 String itemXml = null;
203 oleLoanDocument.setInstanceUuid((String) itemUuid.get("instanceUuid"));
204 oleLoanDocument.setItemUuid((String) itemUuid.get("itemUuid"));
205 try{
206 itemXml = docstoreHelperService.getDocstoreData(oleLoanDocument.getItemUuid());
207 System.out.println(itemXml);
208 }catch (Exception e) {
209 LOG.error("Item Barcode is not available in Docstore");
210 throw new Exception("Item Barcode is not available in DocStore.");
211 }
212 try{
213 WorkItemOlemlRecordProcessor workItemOlemlRecordProcessor = new WorkItemOlemlRecordProcessor();
214 oleItem = workItemOlemlRecordProcessor.fromXML(itemXml);
215 }catch (Exception e){
216 LOG.error("Parser Exception-item xml to item pojo.");
217 throw new Exception("Parser Exception-item xml to item pojo.");
218 }
219 oleLoanDocument.setOleItem(oleItem);
220 try{
221 AdditionalAttributes additionalAttributes = (AdditionalAttributes) oleItem.getExtension().get(0).getContent().get(0);
222 oleLoanDocument.setItemLoanStatus(additionalAttributes.getAttribute(OLEConstants.STATUS));
223 }catch (Exception e){
224 LOG.error("Item Status not available in item xml.");
225 throw new Exception("Item Status not available in item.");
226 }
227 oleLoanDocument.setItemId(itemBarcode);
228 if(oleItem.getItemType()!=null && oleItem.getItemType()!=""){
229 oleLoanDocument.setItemTypeName(oleItem.getItemType());
230 oleLoanDocument.setItemType(getItemTypeIdByItemType(oleLoanDocument.getItemTypeName()).getInstanceItemTypeId());
231 }
232 getLocation(oleItem,oleLoanDocument);
233 oleLoanDocument.setPatronBarcode(patronBarcode);
234 if(!initiateKRMSRule(oleLoanDocument)){
235 return oleLoanDocument;
236 }
237 saveLoan(oleLoanDocument);
238 return oleLoanDocument;
239 }
240
241
242
243
244
245
246
247
248
249 private boolean initiateKRMSRule(OleLoanDocument oleLoanDocument) throws Exception{
250 EngineResults engineResult = getKRMSEngineResults(oleLoanDocument);
251 List<ResultEvent> allResults = engineResult.getAllResults();
252 boolean results = true;
253 boolean flag = false;
254 int i=0;
255 StringBuffer failures = new StringBuffer();
256 for (Iterator<ResultEvent> resultEventIterator = allResults.iterator(); resultEventIterator.hasNext(); ) {
257 ResultEvent resultEvent = resultEventIterator.next();
258 if (resultEvent.getType().equals("Rule Evaluated")) {
259 if(!resultEvent.getResult()) {
260 BasicRule source = (BasicRule)resultEvent.getSource() ;
261
262 if(!flag){
263 failures.append("<b>This Patron is not able to borrow items because of following reasons : </b> <br/>");
264 i++;
265 flag = true;
266 }
267 if(source.getName().equals("barcodeStatusCheck")){
268 failures.append(i+". Barcode Status is False <br/>");
269 i++;
270 }else if(source.getName().equals("membershipExpirationDateCheck")){
271 failures.append(i+". Their Patron record expired on "+oleLoanDocument.getExpirationDate()+" <br/>");
272 i++;
273 } else if(source.getName().equals("borrowerLimitCheck")){
274 failures.append(i+". Patron borrowerLimit Exceeds <br/>");
275 i++;
276 } else if(source.getName().equals("itemUnAvailableCheck")){
277 failures.append(i+". Item staus is "+oleLoanDocument.getItemLoanStatus()+" <br/>");
278 i++;
279 } else if(source.getName().equals("itemDueDateCheck")){
280 oleLoanDocument.setDueDateEmpty(true);
281 failures.append(i+". You must provide Due Date <br/>");
282 i++;
283 }
284 }
285 results &= resultEvent.getResult();
286 }
287 }
288 if(!results){
289 oleLoanDocument.setErrorMessage(failures.toString());
290 return results;
291 }
292 return results;
293 }
294
295 private EngineResults getKRMSEngineResults(OleLoanDocument oleLoanDocument) throws Exception{
296 EngineResults engineResult = null;
297 try{
298 Engine engine = KrmsApiServiceLocator.getEngine();
299 String agendaName = getAgendaName(oleLoanDocument.getBorrowerTypeName());
300 HashMap<String, Object> agendaValue = new HashMap<String, Object>();
301 agendaValue.put("nm", agendaName);
302 List<AgendaBo> agendaBos = (List<AgendaBo>) KRADServiceLocator.getBusinessObjectService().findMatching(AgendaBo.class, agendaValue);
303 AgendaBo agendaBo = agendaBos.get(0);
304 HashMap<String, String> map = new HashMap<String, String>();
305 map.put("AGENDA_NAME", agendaBo.getName());
306 List<MatchBo> matchBos = (List<MatchBo>) KRADServiceLocator.getBusinessObjectService().findMatching(MatchBo.class, map);
307
308 SelectionCriteria selectionCriteria =
309 SelectionCriteria.createCriteria(null, getSelectionContext(agendaBo.getContext().getName()), getAgendaContext(agendaName));
310
311 ExecutionOptions executionOptions = new ExecutionOptions();
312 executionOptions.setFlag(ExecutionFlag.LOG_EXECUTION, true);
313
314 Facts.Builder factBuilder = Facts.Builder.create();
315 boolean barcodeStatus = getOleCirculationPolicyService().isValidBarcode(oleLoanDocument.getPatronBarcode());
316 java.util.Date expirationDate = getOleCirculationPolicyService().getPatronMembershipExpireDate(oleLoanDocument.getPatronBarcode());
317 Integer loanedItems = getOleCirculationPolicyService().getNoOfItemsLoaned(oleLoanDocument.getPatronId());
318 String attributeValue = getAttributeValue(agendaBo.getName(),getItemTypeIdByItemType(oleLoanDocument.getItemTypeName()).getInstanceItemTypeCode());
319 oleLoanDocument.setLoanTermUnitId(getLoanTermUnitIdByCode((attributeValue!=null && attributeValue.trim().length()>0)?attributeValue.split("-")[1].toString():"UNSPECIFIED"));
320 oleLoanDocument.setLoanPeriod((attributeValue!=null && attributeValue.trim().length()>0 && new Integer(attributeValue.split("-").length)<3)?new Integer(attributeValue.split("-")[0]):0);
321 Timestamp dueDate = getOleCirculationPolicyService().calculateLoanDueDate(attributeValue);
322 oleLoanDocument.setLoanDueDate(dueDate);
323 oleLoanDocument.setExpirationDate(expirationDate);
324 HashMap<String,Object> termValues = new HashMap<String, Object>() ;
325 termValues.put("barcodeStatus",barcodeStatus?"true":"false");
326 termValues.put("expirationDate",expirationDate);
327 termValues.put("loanedItems",loanedItems) ;
328 termValues.put("itemStatus",oleLoanDocument.getItemLoanStatus());
329 termValues.put("dueDate",dueDate!=null?dueDate.toString():"null");
330
331 for (Iterator<MatchBo> matchBoIterator = matchBos.iterator(); matchBoIterator.hasNext(); ) {
332 MatchBo matchBo = matchBoIterator.next();
333 factBuilder.addFact(matchBo.getTermName(), termValues.get((matchBo.getTermName())));
334 }
335
336
337 engineResult = engine.execute(selectionCriteria, factBuilder.build(), executionOptions);
338 }catch (Exception krmsException){
339 LOG.error("-----------KRMS EXCEPTION------------------");
340 throw new Exception("Please ingest the Loan Patron xml in KRMS Builder.");
341 }
342 return engineResult;
343 }
344
345 protected Map<String, String> getSelectionContext(String contextName) throws Exception{
346 Map<String, String> selector = new HashMap<String, String>();
347 selector.put(NAMESPACE_CODE_SELECTOR, "OLE");
348 selector.put(NAME_SELECTOR, contextName);
349 return selector;
350 }
351 protected Map<String, String> getAgendaContext(String agendaName) throws Exception{
352 Map<String, String> selector = new HashMap<String, String>();
353 selector.put(NAME_SELECTOR, agendaName);
354 return selector;
355 }
356
357 private String getAgendaName(String attributeValue) throws Exception{
358 Map map = new HashMap();
359 map.put("attributeName", "borrowerType");
360 map.put("attributeValue", attributeValue);
361 List<ProfileAttributeBo> profileAttributeBos = (List<ProfileAttributeBo>) KRADServiceLocator.getBusinessObjectService().findMatching(ProfileAttributeBo.class, map);
362 return profileAttributeBos!=null&& profileAttributeBos.size()>0?profileAttributeBos.get(0).getAgendaName():null;
363 }
364
365 private String getAttributeValue(String agendaName,String attributeName) throws Exception{
366 Map map = new HashMap();
367 map.put("agendaName", agendaName);
368 map.put("attributeName", attributeName);
369 List<ProfileAttributeBo> profileAttributeBos = (List<ProfileAttributeBo>) KRADServiceLocator.getBusinessObjectService().findMatching(ProfileAttributeBo.class, map);
370 return profileAttributeBos!=null&& profileAttributeBos.size()>0?profileAttributeBos.get(0).getAttributeValue():null;
371 }
372
373 private OleInstanceItemType getItemTypeIdByItemType(String itemTypeName) throws Exception{
374 Map barMap = new HashMap();
375 barMap.put("instanceItemTypeName",itemTypeName);
376 List<OleInstanceItemType> matchingItemType = (List<OleInstanceItemType>)getBusinessObjectService().findMatching(OleInstanceItemType.class,barMap);
377 return matchingItemType.get(0);
378 }
379
380 private List getLocationByLocationName(String locationName) throws Exception{
381 Map barMap = new HashMap();
382 barMap.put("locationName",locationName);
383 List<OleLocation> matchingLocation = (List<OleLocation>)getBusinessObjectService().findMatching(OleLocation.class,barMap);
384 return matchingLocation;
385 }
386
387 private OleLocation getLocationByParentId(String locationId) throws Exception{
388 Map barMap = new HashMap();
389 barMap.put("locationId",locationId);
390 OleLocation oleLocation = getBusinessObjectService().findBySinglePrimaryKey(OleLocation.class,locationId);
391 return oleLocation;
392 }
393
394 private String getLocationLevelByLevelId(String levelId) throws Exception{
395 Map barMap1 = new HashMap();
396 barMap1.put("levelId",levelId);
397 OleLocationLevel matchingLocationLevel = (OleLocationLevel)getBusinessObjectService().findByPrimaryKey(OleLocationLevel.class,barMap1);
398 return matchingLocationLevel.getLevelName();
399 }
400
401 private String getLoanStatusId() throws Exception{
402 Map barMap1 = new HashMap();
403 barMap1.put("loanStatusCode",OLEConstants.ITEM_STATUS_LOANED);
404 List<OleLoanStatus> matchingOleLoanStatus = (List<OleLoanStatus>)getBusinessObjectService().findMatching(OleLoanStatus.class, barMap1);
405 return matchingOleLoanStatus.get(0).getLoanStatusId();
406 }
407
408 private OleLoanDocument setLocation(String locationLevelName,String locationCode,OleLoanDocument oleLoanDoc) throws Exception{
409 if(locationLevelName.equalsIgnoreCase("Shelving Location")) {
410 oleLoanDoc.setItemLocation(locationCode);
411 }
412 else if (locationLevelName.equalsIgnoreCase("Collection")) {
413 oleLoanDoc.setItemCollection(locationCode);
414 }
415 else if (locationLevelName.equalsIgnoreCase("Library")) {
416 oleLoanDoc.setItemLibrary(locationCode);
417 }
418 else if (locationLevelName.equalsIgnoreCase("Institution")) {
419 oleLoanDoc.setItemInstitution(locationCode);
420 }
421 else if (locationLevelName.equalsIgnoreCase("Campus")) {
422 oleLoanDoc.setItemCampus(locationCode);
423 }
424 return oleLoanDoc;
425 }
426
427 private void getLocation(OleItem oleItem,OleLoanDocument oleLoanDoc) throws Exception{
428 try{
429 List<PhysicalLocation> physicalLocations = oleItem.getLocation();
430 List<LocationLevel> locationLevels = new ArrayList<LocationLevel>();
431 for(PhysicalLocation physicalLocation : physicalLocations) {
432 locationLevels = physicalLocation.getLocationLevel();
433 getLocationLevel(oleLoanDoc,locationLevels);
434 }
435
436 setLoan(oleLoanDoc);
437 }catch (Exception e){
438 LOG.error("--------------Invalid location data.---------------");
439 throw new Exception("Invalid location");
440 }
441 }
442
443 public OleLoanDocument getLocationLevel(OleLoanDocument oleLoanDoc,List<LocationLevel> locationLevels) throws Exception{
444 String locationLevelName = null;
445 String locationName = null;
446 String parentId = null;
447 String locationCode = null;
448 int levelId = 0;
449 List<OleLocation> matchingLocation = new ArrayList<OleLocation>();
450 if(locationLevels != null){
451 for(LocationLevel locationLevel : locationLevels) {
452 locationName = locationLevel.getLocationName().getValue();
453 matchingLocation = getLocationByLocationName(locationName);
454 locationCode = matchingLocation.get(0).getLocationCode();
455 parentId = matchingLocation.get(0).getParentLocationId();
456 if(parentId != null){
457 levelId = Integer.parseInt(matchingLocation.get(0).getLevelId());
458 LOG.info("levelId"+levelId);
459 locationLevelName = getLocationLevelByLevelId(String.valueOf(levelId));
460 oleLoanDoc = setLocation(locationLevelName,locationCode,oleLoanDoc);
461 for(int i=levelId-1;i>0;i--){
462 LOG.info("levelId" + i);
463 locationLevelName = getLocationLevelByLevelId(String.valueOf(i));
464 OleLocation oleLocation = getLocationByParentId(parentId);
465 parentId = oleLocation.getParentLocationId();
466 oleLoanDoc = setLocation(locationLevelName,oleLocation.getLocationCode(),oleLoanDoc);
467 }
468 }
469 }
470 }
471 return oleLoanDoc;
472 }
473
474 private String getLoanTermUnitIdByCode(String code) throws Exception{
475 Map barMap1 = new HashMap();
476 barMap1.put("loanTermUnitCode",code);
477 List<OleLoanTermUnit> matchingOleLoanTermUnit = (List<OleLoanTermUnit>)getBusinessObjectService().findMatching(OleLoanTermUnit.class,barMap1);
478 return matchingOleLoanTermUnit.get(0).getLoanTermUnitId();
479
480 }
481
482 private OleLoanDocument setLoan(OleLoanDocument oleLoanDocument) throws Exception{
483 Map docStoreDetails = getItemDetails(oleLoanDocument.getItemId());
484 oleLoanDocument.setTitle(getTitlefromBib((String)docStoreDetails.get("bibUuid")));
485 oleLoanDocument.setLoanStatusId(getLoanStatusId());
486 oleLoanDocument.setLoanApproverId(getEntityId(GlobalVariables.getUserSession().getPrincipalId()));
487 oleLoanDocument.setLoanOperatorId(getEntityId(GlobalVariables.getUserSession().getPrincipalId()));
488
489 oleLoanDocument.setBorrowerLimit(false);
490 oleLoanDocument.setItemUnavailable(false);
491 return oleLoanDocument;
492 }
493
494
495
496
497
498 public void saveLoan(OleLoanDocument oleLoanDocument) throws Exception{
499 if(oleLoanDocument!=null){
500 getBusinessObjectService().save(oleLoanDocument);
501 postLoan(oleLoanDocument.getOleItem());
502 }
503 }
504
505 public String buildItemContent (OleItem oleItem) throws Exception{
506 AdditionalAttributes additionalAttributes = (AdditionalAttributes) oleItem.getExtension().get(0).getContent().get(0);
507 additionalAttributes.setAttribute(OLEConstants.STATUS,OLEConstants.ITEM_STATUS_LOANED);
508 additionalAttributes.setAttribute(OLEConstants.LAST_UPDATED_BY, GlobalVariables.getUserSession().getPrincipalId());
509 additionalAttributes.setAttribute(OLEConstants.LAST_UPDATED,
510 String.valueOf(new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a").format(new java.util.Date())));
511 String itemContent = new WorkItemOlemlRecordProcessor().toXML(oleItem);
512 return itemContent;
513 }
514
515 public void postLoan(OleItem oleItem) throws Exception{
516 try{
517 String itemUuid = oleItem.getItemIdentifier();
518 String itemXmlContent = buildItemContent(oleItem);
519
520 String itemRecordUpdateResponse =
521 getDocstoreHelperService().updateInstanceRecord(itemUuid, OLEConstants.ITEM_DOC_TYPE, itemXmlContent);
522 LOG.info(itemRecordUpdateResponse);
523
524 } catch (Exception e) {
525 LOG.error("Item Status to docStore failed.");
526 throw new Exception("Item Status to docStore failed.");
527 }
528 }
529 }