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.core.api.resourceloader.GlobalResourceLoader;
19 import org.kuali.rice.core.impl.cache.DistributedCacheManagerDecorator;
20 import org.kuali.rice.krad.maintenance.MaintainableImpl;
21 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
22 import org.kuali.rice.krad.util.KRADConstants;
23 import org.kuali.rice.krms.api.KrmsConstants;
24 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
25 import org.kuali.rice.krms.impl.repository.ContextBo;
26 import org.kuali.rice.krms.impl.repository.RepositoryBoIncrementer;
27
28 import java.util.Map;
29
30
31
32
33
34
35 public class ContextMaintainable extends MaintainableImpl {
36
37 private static final RepositoryBoIncrementer contextIdIncrementer = new RepositoryBoIncrementer(ContextBo.CONTEXT_SEQ_NAME);
38
39 @Override
40 public void processAfterNew(MaintenanceDocument document, Map<String, String[]> requestParameters) {
41 ContextBo newContext = (ContextBo) document.getNewMaintainableObject().getDataObject();
42
43 newContext.setId(contextIdIncrementer.getNewId());
44
45 super.processAfterNew(document, requestParameters);
46 }
47
48 @Override
49 public void processAfterCopy(MaintenanceDocument document, Map<String, String[]> requestParameters) {
50 ContextBo context = (ContextBo) document.getNewMaintainableObject().getDataObject();
51
52 context.setId(contextIdIncrementer.getNewId());
53
54 super.processAfterCopy(document,
55 requestParameters);
56 }
57
58 @Override
59 public void saveDataObject() {
60 super.saveDataObject();
61
62
63 DistributedCacheManagerDecorator distributedCacheManagerDecorator =
64 GlobalResourceLoader.getService(KrmsConstants.KRMS_DISTRIBUTED_CACHE);
65 distributedCacheManagerDecorator.getCache(ContextDefinition.Cache.NAME).clear();
66 }
67
68 @Override
69 public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
70
71 ContextBo contextBo = (ContextBo) super.retrieveObjectForEditOrCopy(document, dataObjectKeys);
72
73 if (KRADConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction())) {
74 document.getDocumentHeader().setDocumentDescription("New Context Document");
75
76 contextBo = contextBo.copyContext(" Copy " + System.currentTimeMillis());
77 }
78
79 return contextBo;
80 }
81 }