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