1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.util;
17
18 import org.kuali.rice.core.api.util.RiceKeyConstants;
19 import org.kuali.rice.krad.bo.GlobalBusinessObject;
20 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
21 import org.kuali.rice.krad.util.KRADConstants;
22 import org.kuali.rice.krms.dto.RuleManagementWrapper;
23 import org.kuali.student.common.uif.rule.KsMaintenanceDocumentRuleBase;
24
25
26
27
28
29
30 public class RuleEditorBusRule extends KsMaintenanceDocumentRuleBase {
31
32 @Override
33 protected boolean primaryKeyCheck(MaintenanceDocument document) {
34
35 boolean success = true;
36 Class<?> dataObjectClass = document.getNewMaintainableObject().getDataObjectClass();
37
38
39 Object oldBo = ((RuleManagementWrapper) document.getOldMaintainableObject().getDataObject());
40 Object newDataObject = ((RuleManagementWrapper) document.getNewMaintainableObject().getDataObject());
41
42
43
44
45
46
47 if (newDataObject instanceof GlobalBusinessObject) {
48 return success;
49 }
50
51
52
53 if (document.isEdit()) {
54 if (!getDataObjectMetaDataService().equalsByPrimaryKeys(oldBo, newDataObject)) {
55
56 putDocumentError(KRADConstants.DOCUMENT_ERRORS,
57 RiceKeyConstants.ERROR_DOCUMENT_MAINTENANCE_PRIMARY_KEYS_CHANGED_ON_EDIT,
58 getHumanReadablePrimaryKeyFieldNames(dataObjectClass));
59 success &= false;
60 }
61 }
62
63 return success;
64 }
65
66 @Override
67 protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
68 return true;
69 }
70
71 }
72