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.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.datadictionary.DocumentEntry;
20 import org.kuali.rice.krad.document.Document;
21 import org.kuali.rice.krad.document.DocumentViewAuthorizerBase;
22 import org.kuali.rice.krad.document.DocumentViewPresentationControllerBase;
23 import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
24 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
25 import org.kuali.rice.krad.uif.UifConstants;
26
27
28
29
30
31
32
33
34
35
36
37 public class DocumentView extends FormView {
38 private static final long serialVersionUID = 2251983409572774175L;
39
40 private Class<? extends Document> documentClass;
41
42 private boolean allowsNoteAttachments = true;
43 private boolean allowsNoteFYI = false;
44 private boolean displayTopicFieldInNotes = false;
45
46 private Class<? extends KeyValuesFinder> attachmentTypesValuesFinderClass;
47
48 public DocumentView() {
49 super();
50 }
51
52
53
54
55
56
57
58
59
60
61
62
63 @Override
64 public void performInitialization(View view, Object model) {
65 super.performInitialization(view, model);
66
67
68 DocumentEntry documentEntry = getDocumentEntryForView();
69 pushObjectToContext(UifConstants.ContextVariableNames.DOCUMENT_ENTRY, documentEntry);
70
71
72 if (getAuthorizer() == null) {
73 setAuthorizer(new DocumentViewAuthorizerBase());
74 }
75
76 if (getAuthorizer() instanceof DocumentViewAuthorizerBase) {
77 DocumentViewAuthorizerBase documentViewAuthorizerBase = (DocumentViewAuthorizerBase) getAuthorizer();
78 if (documentViewAuthorizerBase.getDocumentAuthorizer() == null) {
79 documentViewAuthorizerBase.setDocumentAuthorizerClass(documentEntry.getDocumentAuthorizerClass());
80 }
81 }
82
83 if (getPresentationController() == null) {
84 setPresentationController(new DocumentViewPresentationControllerBase());
85 }
86
87 if (getPresentationController() instanceof DocumentViewPresentationControllerBase) {
88 DocumentViewPresentationControllerBase documentViewPresentationControllerBase =
89 (DocumentViewPresentationControllerBase) getPresentationController();
90 if (documentViewPresentationControllerBase.getDocumentPresentationController() == null) {
91 documentViewPresentationControllerBase.setDocumentPresentationControllerClass(
92 documentEntry.getDocumentPresentationControllerClass());
93 }
94 }
95 }
96
97
98
99
100
101
102 protected DocumentEntry getDocumentEntryForView() {
103 DocumentEntry documentEntry = KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentEntryByClass(
104 getDocumentClass());
105
106 if (documentEntry == null) {
107 throw new RuntimeException(
108 "Unable to find document entry for document class: " + getDocumentClass().getName());
109 }
110
111 return documentEntry;
112 }
113
114 public Class<? extends Document> getDocumentClass() {
115 return this.documentClass;
116 }
117
118 public void setDocumentClass(Class<? extends Document> documentClass) {
119 this.documentClass = documentClass;
120 }
121
122 public boolean isAllowsNoteAttachments() {
123 return this.allowsNoteAttachments;
124 }
125
126 public void setAllowsNoteAttachments(boolean allowsNoteAttachments) {
127 this.allowsNoteAttachments = allowsNoteAttachments;
128 }
129
130 public boolean isAllowsNoteFYI() {
131 return this.allowsNoteFYI;
132 }
133
134 public void setAllowsNoteFYI(boolean allowsNoteFYI) {
135 this.allowsNoteFYI = allowsNoteFYI;
136 }
137
138 public boolean isDisplayTopicFieldInNotes() {
139 return this.displayTopicFieldInNotes;
140 }
141
142 public void setDisplayTopicFieldInNotes(boolean displayTopicFieldInNotes) {
143 this.displayTopicFieldInNotes = displayTopicFieldInNotes;
144 }
145
146 public Class<? extends KeyValuesFinder> getAttachmentTypesValuesFinderClass() {
147 return this.attachmentTypesValuesFinderClass;
148 }
149
150 public void setAttachmentTypesValuesFinderClass(Class<? extends KeyValuesFinder> attachmentTypesValuesFinderClass) {
151 this.attachmentTypesValuesFinderClass = attachmentTypesValuesFinderClass;
152 }
153
154 }