1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.view;
17
18 import org.kuali.rice.krad.datadictionary.DocumentEntry;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.document.Document;
22 import org.kuali.rice.krad.document.DocumentViewAuthorizerBase;
23 import org.kuali.rice.krad.document.DocumentViewPresentationControllerBase;
24 import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
25 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
26 import org.kuali.rice.krad.uif.UifConstants;
27
28
29
30
31
32
33
34
35
36
37
38 @BeanTag(name = "documentView-bean", parent = "Uif-DocumentView")
39 public class DocumentView extends FormView {
40 private static final long serialVersionUID = 2251983409572774175L;
41
42 private Class<? extends Document> documentClass;
43
44 private boolean allowsNoteAttachments = true;
45 private boolean allowsNoteFYI = false;
46 private boolean displayTopicFieldInNotes = false;
47
48 private Class<? extends KeyValuesFinder> attachmentTypesValuesFinderClass;
49
50 public DocumentView() {
51 super();
52 }
53
54
55
56
57
58
59
60
61
62
63
64 @Override
65 public void performInitialization(Object model) {
66 super.performInitialization(model);
67
68
69 DocumentEntry documentEntry = getDocumentEntryForView();
70 pushObjectToContext(UifConstants.ContextVariableNames.DOCUMENT_ENTRY, documentEntry);
71
72
73 if (getAuthorizer() == null) {
74 setAuthorizer(new DocumentViewAuthorizerBase());
75 }
76
77 if (getAuthorizer() instanceof DocumentViewAuthorizerBase) {
78 DocumentViewAuthorizerBase documentViewAuthorizerBase = (DocumentViewAuthorizerBase) getAuthorizer();
79 if (documentViewAuthorizerBase.getDocumentAuthorizer() == null) {
80 documentViewAuthorizerBase.setDocumentAuthorizerClass(documentEntry.getDocumentAuthorizerClass());
81 }
82 }
83
84 if (getPresentationController() == null) {
85 setPresentationController(new DocumentViewPresentationControllerBase());
86 }
87
88 if (getPresentationController() instanceof DocumentViewPresentationControllerBase) {
89 DocumentViewPresentationControllerBase documentViewPresentationControllerBase =
90 (DocumentViewPresentationControllerBase) getPresentationController();
91 if (documentViewPresentationControllerBase.getDocumentPresentationController() == null) {
92 documentViewPresentationControllerBase.setDocumentPresentationControllerClass(
93 documentEntry.getDocumentPresentationControllerClass());
94 }
95 }
96
97 getObjectPathToConcreteClassMapping().put(getDefaultBindingObjectPath(), getDocumentClass());
98 }
99
100
101
102
103
104
105 protected DocumentEntry getDocumentEntryForView() {
106 DocumentEntry documentEntry = KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentEntryByClass(
107 getDocumentClass());
108
109 if (documentEntry == null) {
110 throw new RuntimeException(
111 "Unable to find document entry for document class: " + getDocumentClass().getName());
112 }
113
114 return documentEntry;
115 }
116
117
118
119
120
121
122 @BeanTagAttribute(name="documentClass")
123 public Class<? extends Document> getDocumentClass() {
124 return this.documentClass;
125 }
126
127
128
129
130
131
132 public void setDocumentClass(Class<? extends Document> documentClass) {
133 this.documentClass = documentClass;
134 }
135
136
137
138
139
140
141 @BeanTagAttribute(name="allowsNoteAttachments")
142 public boolean isAllowsNoteAttachments() {
143 return this.allowsNoteAttachments;
144 }
145
146
147
148
149
150
151 public void setAllowsNoteAttachments(boolean allowsNoteAttachments) {
152 this.allowsNoteAttachments = allowsNoteAttachments;
153 }
154
155
156
157
158
159
160 @BeanTagAttribute(name="allowsNoteFYI")
161 public boolean isAllowsNoteFYI() {
162 return this.allowsNoteFYI;
163 }
164
165
166
167
168
169
170 public void setAllowsNoteFYI(boolean allowsNoteFYI) {
171 this.allowsNoteFYI = allowsNoteFYI;
172 }
173
174
175
176
177
178
179 @BeanTagAttribute(name="displayTopicFieldInNotes")
180 public boolean isDisplayTopicFieldInNotes() {
181 return this.displayTopicFieldInNotes;
182 }
183
184
185
186
187
188
189 public void setDisplayTopicFieldInNotes(boolean displayTopicFieldInNotes) {
190 this.displayTopicFieldInNotes = displayTopicFieldInNotes;
191 }
192
193
194
195
196
197
198 @BeanTagAttribute(name="attachmentTypesValuesFinderClass",type = BeanTagAttribute.AttributeType.SINGLEBEAN)
199 public Class<? extends KeyValuesFinder> getAttachmentTypesValuesFinderClass() {
200 return this.attachmentTypesValuesFinderClass;
201 }
202
203
204
205
206
207
208 public void setAttachmentTypesValuesFinderClass(Class<? extends KeyValuesFinder> attachmentTypesValuesFinderClass) {
209 this.attachmentTypesValuesFinderClass = attachmentTypesValuesFinderClass;
210 }
211 }