1 package org.kuali.ole.service.impl;
2
3 import org.kuali.ole.deliver.bo.FeeType;
4 import org.kuali.ole.deliver.bo.PatronBillPayment;
5 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
6 import org.kuali.ole.docstore.common.document.content.instance.Item;
7 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
8 import org.kuali.ole.sys.context.SpringContext;
9 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
10 import org.kuali.rice.krad.service.DocumentService;
11 import org.kuali.rice.krad.service.impl.MaintenanceDocumentServiceImpl;
12 import org.kuali.rice.krad.util.KRADConstants;
13 import org.kuali.rice.krad.util.ObjectUtils;
14
15 import java.io.Serializable;
16 import java.util.List;
17 import java.util.Map;
18
19
20
21
22
23
24
25
26 public class OlePatronBillMaintenanceDocumentServiceImpl extends MaintenanceDocumentServiceImpl {
27
28 private DocumentService documentService;
29 private DocstoreClientLocator docstoreClientLocator;
30
31 public DocstoreClientLocator getDocstoreClientLocator() {
32
33 if (docstoreClientLocator == null) {
34 docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
35
36 }
37 return docstoreClientLocator;
38 }
39
40
41
42
43
44 protected DocumentService getDocumentService() {
45 return this.documentService;
46 }
47
48
49
50
51 public void setDocumentService(DocumentService documentService) {
52 this.documentService = documentService;
53 }
54
55
56 public void setupMaintenanceObjectForDelete(MaintenanceDocument document, String maintenanceAction,
57 Map<String, String[]> requestParameters) {
58 document.getNewMaintainableObject().setMaintenanceAction(maintenanceAction);
59 document.getOldMaintainableObject().setMaintenanceAction(maintenanceAction);
60
61 Object oldDataObject = retrieveObjectForMaintenance(document, requestParameters);
62
63 document.getOldMaintainableObject().setDataObject(oldDataObject);
64 PatronBillPayment patronBillPayment=(PatronBillPayment)document.getOldMaintainableObject().getDataObject();
65 List<FeeType> feeTypes=patronBillPayment.getFeeType();
66 for(FeeType feeType:feeTypes){
67 if (feeType.getItemUuid() != null) {
68 try{
69 org.kuali.ole.docstore.common.document.Item item = getDocstoreClientLocator().getDocstoreClient().retrieveItem(feeType.getItemUuid());
70 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
71 Item itemContent = itemOlemlRecordProcessor.fromXML(item.getContent());
72 if (feeType.getItemUuid().equals(item.getId())) {
73 feeType.setItemTitle(item.getHolding().getBib().getTitle());
74 feeType.setItemType(itemContent.getItemType().getCodeValue());
75 }
76 } catch(Exception e)
77 {
78 e.printStackTrace();
79 }
80 }
81 }
82 patronBillPayment.setFeeType(feeTypes);
83 document.getOldMaintainableObject().setDataObject(patronBillPayment);
84 Object newDataObject = ObjectUtils.deepCopy((Serializable) oldDataObject);
85 document.getNewMaintainableObject().setDataObject(newDataObject);
86 }
87
88
89 }