1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.ui;
17
18 import org.kuali.rice.krad.maintenance.MaintainableImpl;
19 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
20 import org.kuali.rice.krad.service.KRADServiceLocator;
21 import org.kuali.rice.krad.service.SequenceAccessorService;
22 import org.kuali.rice.krad.util.KRADConstants;
23 import org.kuali.rice.krms.impl.repository.ContextBo;
24
25 import java.util.Map;
26
27
28
29
30
31
32 public class ContextMaintainable extends MaintainableImpl {
33
34 private transient SequenceAccessorService sequenceAccessorService;
35
36 @Override
37 public void processAfterNew(MaintenanceDocument document, Map<String, String[]> requestParameters) {
38 ContextBo newContext = (ContextBo) document.getNewMaintainableObject().getDataObject();
39
40 String nextId = getSequenceAccessorService().getNextAvailableSequenceNumber(KrmsMaintenanceConstants.Sequences.CONTEXT).toString();
41 newContext.setId(nextId);
42
43 super.processAfterNew(document, requestParameters);
44 }
45
46 @Override
47 public void processAfterCopy(MaintenanceDocument document, Map<String, String[]> requestParameters) {
48 ContextBo context = (ContextBo) document.getNewMaintainableObject().getDataObject();
49
50 String nextId = getSequenceAccessorService().getNextAvailableSequenceNumber(KrmsMaintenanceConstants.Sequences.CONTEXT).toString();
51 context.setId(nextId);
52
53 super.processAfterCopy(document,
54 requestParameters);
55 }
56
57
58
59 @Override
60 public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
61
62 ContextBo contextBo = (ContextBo) super.retrieveObjectForEditOrCopy(document, dataObjectKeys);
63
64 if (KRADConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction())) {
65 document.getDocumentHeader().setDocumentDescription("New Context Document");
66
67 contextBo = contextBo.copyContext(" Copy " + System.currentTimeMillis());
68 }
69
70 return contextBo;
71 }
72
73
74
75
76
77 private SequenceAccessorService getSequenceAccessorService() {
78 if ( sequenceAccessorService == null ) {
79 sequenceAccessorService = KRADServiceLocator.getSequenceAccessorService();
80 }
81 return sequenceAccessorService;
82 }
83
84 }