1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.authorization; |
17 | |
|
18 | |
import java.util.HashSet; |
19 | |
import java.util.Set; |
20 | |
|
21 | |
import org.kuali.rice.kns.inquiry.InquiryRestrictions; |
22 | |
import org.kuali.rice.kns.web.ui.Field; |
23 | |
|
24 | 0 | 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 | 0 | hiddenFields.add(fieldName); |
31 | 0 | } |
32 | |
|
33 | |
public void addHiddenSectionId(String sectionId) { |
34 | 0 | hiddenSectionIds.add(sectionId); |
35 | 0 | } |
36 | |
|
37 | |
@Override |
38 | |
public FieldRestriction getFieldRestriction(String fieldName) { |
39 | 0 | FieldRestriction fieldRestriction = super |
40 | |
.getFieldRestriction(fieldName); |
41 | 0 | if (isHiddenField(fieldName)) { |
42 | 0 | fieldRestriction = new FieldRestriction(fieldName, Field.HIDDEN); |
43 | |
} |
44 | 0 | return fieldRestriction; |
45 | |
} |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
@Override |
51 | |
public boolean hasRestriction(String fieldName) { |
52 | 0 | return super.hasRestriction(fieldName) || isHiddenField(fieldName); |
53 | |
} |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
@Override |
59 | |
public boolean hasAnyFieldRestrictions() { |
60 | 0 | return super.hasAnyFieldRestrictions() || !hiddenFields.isEmpty(); |
61 | |
} |
62 | |
|
63 | |
@Override |
64 | |
public void clearAllRestrictions() { |
65 | 0 | super.clearAllRestrictions(); |
66 | 0 | hiddenFields = new HashSet<String>(); |
67 | 0 | hiddenSectionIds = new HashSet<String>(); |
68 | 0 | } |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
public boolean isHiddenSectionId(String sectionId) { |
74 | 0 | return hiddenSectionIds.contains(sectionId); |
75 | |
} |
76 | |
|
77 | |
protected boolean isHiddenField(String fieldName) { |
78 | 0 | String normalizedFieldName = normalizeFieldName(fieldName); |
79 | 0 | return hiddenFields.contains(normalizedFieldName); |
80 | |
} |
81 | |
} |