1 package org.kuali.ole.deliver.maintenance;
2
3
4 import org.kuali.ole.OLEConstants;
5 import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
6 import org.kuali.ole.deliver.service.OleDeliverRequestDocumentHelperServiceImpl;
7 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
8 import org.kuali.ole.sys.context.SpringContext;
9 import org.kuali.ole.util.DocstoreUtil;
10 import org.kuali.rice.krad.maintenance.MaintainableImpl;
11 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
12 import org.kuali.rice.krad.maintenance.MaintenanceLock;
13 import org.kuali.rice.krad.util.GlobalVariables;
14 import org.kuali.rice.krad.util.ObjectUtils;
15
16 import java.sql.Date;
17 import java.util.Collections;
18 import java.util.List;
19 import java.util.Map;
20
21
22
23
24
25
26
27
28 public class OleDeliverRequestMaintenanceImpl extends MaintainableImpl {
29
30 private DocstoreUtil docstoreUtil;
31 public DocstoreUtil getDocstoreUtil() {
32
33 if (docstoreUtil == null) {
34 docstoreUtil = SpringContext.getBean(DocstoreUtil.class);
35
36 }
37 return docstoreUtil;
38 }
39
40
41
42
43
44
45
46
47 @Override
48 public void processAfterNew(MaintenanceDocument document,
49 Map<String, String[]> requestParameters) {
50 super.processAfterNew(document, requestParameters);
51 document.getDocumentHeader().setDocumentDescription(OLEConstants.NEW_REQUEST_DOC);
52 OleDeliverRequestBo oleDeliverRequestBo = (OleDeliverRequestBo) document.getNewMaintainableObject().getDataObject();
53 oleDeliverRequestBo.setRequestCreator(OLEConstants.OleDeliverRequest.REQUESTER_PATRON);
54 oleDeliverRequestBo.setOperatorCreateId(GlobalVariables.getUserSession().getPrincipalId());
55 oleDeliverRequestBo.setOperatorCreateName(GlobalVariables.getUserSession().getPrincipalName());
56 oleDeliverRequestBo.setCreateDate(new Date(System.currentTimeMillis()));
57
58
59 }
60
61
62
63
64
65
66
67 @Override
68 public void processAfterCopy(MaintenanceDocument document, Map<String, String[]> requestParameters) {
69 super.processAfterCopy(document, requestParameters);
70 document.getDocumentHeader().setDocumentDescription(OLEConstants.COPY_REQUEST_DOC);
71 OleDeliverRequestBo oleDeliverRequestBo = (OleDeliverRequestBo) document.getNewMaintainableObject().getDataObject();
72 oleDeliverRequestBo.setCreateDate(new Date(System.currentTimeMillis()));
73 }
74
75
76
77
78
79
80
81 @Override
82 public void processAfterEdit(MaintenanceDocument document, Map<String, String[]> requestParameters) {
83 super.processAfterEdit(document, requestParameters);
84 OleDeliverRequestBo oleDeliverRequestBo = (OleDeliverRequestBo) document.getNewMaintainableObject().getDataObject();
85 document.getDocumentHeader().setDocumentDescription(OLEConstants.EDIT_REQUEST_DOC);
86 }
87
88 @Override
89 public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
90 OleDeliverRequestBo oleDeliverRequestBo = (OleDeliverRequestBo) super.retrieveObjectForEditOrCopy(document, dataObjectKeys);
91 OleDeliverRequestBo newOleDeliverRequestBo = (OleDeliverRequestBo) ObjectUtils.deepCopy(oleDeliverRequestBo);
92 if (newOleDeliverRequestBo.getModifiedDate() == null) {
93 newOleDeliverRequestBo.setModifiedDate(new Date(System.currentTimeMillis()));
94 }
95
96 newOleDeliverRequestBo.setOperatorModifiedId(GlobalVariables.getUserSession().getPrincipalId());
97 newOleDeliverRequestBo.setOperatorModifierName(GlobalVariables.getUserSession().getPrincipalName());
98
99 if (newOleDeliverRequestBo.getOperatorCreateId() != null && !newOleDeliverRequestBo.getOperatorCreateId().isEmpty()) {
100 newOleDeliverRequestBo.setRequestCreator(OLEConstants.OleDeliverRequest.REQUESTER_OPERATOR);
101 } else if (newOleDeliverRequestBo.getProxyBorrowerId() != null && !newOleDeliverRequestBo.getProxyBorrowerId().isEmpty()) {
102 newOleDeliverRequestBo.setRequestCreator(OLEConstants.OleDeliverRequest.REQUESTER_PROXY_PATRON);
103 } else {
104 newOleDeliverRequestBo.setRequestCreator(OLEConstants.OleDeliverRequest.REQUESTER_PATRON);
105 }
106 OleDeliverRequestDocumentHelperServiceImpl oleDeliverRequestDocumentHelperService = new OleDeliverRequestDocumentHelperServiceImpl();
107
108 OleDeliverRequestBo oleDeliverRequestBo1 = newOleDeliverRequestBo;
109
110 getDocstoreUtil().isItemAvailableInDocStore(newOleDeliverRequestBo);
111
112 newOleDeliverRequestBo.setOleItem(null);
113
114 return newOleDeliverRequestBo;
115
116
117 }
118
119 @Override
120 public List<MaintenanceLock> generateMaintenanceLocks() {
121 return Collections.emptyList();
122 }
123
124 }