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 org.kuali.rice.kns.inquiry.InquiryRestrictions;
19 import org.kuali.rice.kns.web.ui.Field;
20
21 import java.util.HashSet;
22 import java.util.Set;
23
24 public class InquiryOrMaintenanceDocumentRestrictionsBase extends
25 BusinessObjectRestrictionsBase implements InquiryOrMaintenanceDocumentRestrictions, InquiryRestrictions {
26 private Set<String> hiddenFields;
27 private Set<String> hiddenSectionIds;
28
29 public void addHiddenField(String fieldName) {
30 hiddenFields.add(fieldName);
31 }
32
33 public void addHiddenSectionId(String sectionId) {
34 hiddenSectionIds.add(sectionId);
35 }
36
37 @Override
38 public FieldRestriction getFieldRestriction(String fieldName) {
39 FieldRestriction fieldRestriction = super
40 .getFieldRestriction(fieldName);
41 if (isHiddenField(fieldName)) {
42 fieldRestriction = new FieldRestriction(fieldName, Field.HIDDEN);
43 }
44 return fieldRestriction;
45 }
46
47
48
49
50 @Override
51 public boolean hasRestriction(String fieldName) {
52 return super.hasRestriction(fieldName) || isHiddenField(fieldName);
53 }
54
55
56
57
58 @Override
59 public boolean hasAnyFieldRestrictions() {
60 return super.hasAnyFieldRestrictions() || !hiddenFields.isEmpty();
61 }
62
63 @Override
64 public void clearAllRestrictions() {
65 super.clearAllRestrictions();
66 hiddenFields = new HashSet<String>();
67 hiddenSectionIds = new HashSet<String>();
68 }
69
70
71
72
73 public boolean isHiddenSectionId(String sectionId) {
74 return hiddenSectionIds.contains(sectionId);
75 }
76
77 protected boolean isHiddenField(String fieldName) {
78 String normalizedFieldName = normalizeFieldName(fieldName);
79 return hiddenFields.contains(normalizedFieldName);
80 }
81 }