1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.document.authorization;
17
18 import java.util.HashSet;
19 import java.util.Set;
20
21 import org.kuali.rice.kns.document.authorization.FieldRestriction;
22 import org.kuali.rice.kns.document.authorization.InquiryOrMaintenanceDocumentRestrictionsBase;
23 import org.kuali.rice.kns.document.authorization.MaintenanceDocumentRestrictions;
24 import org.kuali.rice.kns.web.ui.Field;
25
26
27
28
29 @Deprecated
30 public class MaintenanceDocumentRestrictionsBase extends InquiryOrMaintenanceDocumentRestrictionsBase implements MaintenanceDocumentRestrictions {
31 private Set<String> readOnlyFields;
32 private Set<String> readOnlySectionIds;
33
34 public MaintenanceDocumentRestrictionsBase() {
35 }
36
37 public void addReadOnlyField(String fieldName) {
38 readOnlyFields.add(fieldName);
39 }
40
41 public void addReadOnlySectionId(String sectionId) {
42 readOnlySectionIds.add(sectionId);
43 }
44
45 public Set<String> getReadOnlySectionIds() {
46 return readOnlySectionIds;
47 }
48
49 @Override
50 public FieldRestriction getFieldRestriction(String fieldName) {
51 FieldRestriction fieldRestriction = super
52 .getFieldRestriction(fieldName);
53 if (fieldRestriction == null && isReadOnlyField(fieldName)) {
54 fieldRestriction = new FieldRestriction(fieldName, Field.READONLY);
55 }
56
57 if (Field.EDITABLE
58 .equals(fieldRestriction.getKualiFieldDisplayFlag())
59 && isReadOnlyField(fieldName)) {
60 fieldRestriction = new FieldRestriction(fieldName,
61 Field.READONLY);
62 }
63 return fieldRestriction;
64 }
65
66 @Override
67 public void clearAllRestrictions() {
68 super.clearAllRestrictions();
69 readOnlyFields = new HashSet<String>();
70 readOnlySectionIds = new HashSet<String>();
71 }
72
73 protected boolean isReadOnlyField(String fieldName) {
74 String normalizedFieldName = normalizeFieldName(fieldName);
75 return readOnlyFields.contains(normalizedFieldName);
76 }
77
78
79
80
81 @Override
82 public boolean hasAnyFieldRestrictions() {
83 return super.hasAnyFieldRestrictions() || !readOnlyFields.isEmpty();
84 }
85
86
87
88
89 @Override
90 public boolean hasRestriction(String fieldName) {
91 return super.hasRestriction(fieldName) || isReadOnlyField(fieldName);
92 }
93
94
95
96
97 public boolean isReadOnlySectionId(String sectionId) {
98 return readOnlySectionIds.contains(sectionId);
99 }
100 }