1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.inquiry; |
17 | |
|
18 | |
import java.security.GeneralSecurityException; |
19 | |
import java.util.ArrayList; |
20 | |
import java.util.Collection; |
21 | |
import java.util.Collections; |
22 | |
import java.util.HashMap; |
23 | |
import java.util.Iterator; |
24 | |
import java.util.List; |
25 | |
import java.util.Map; |
26 | |
import java.util.Properties; |
27 | |
|
28 | |
import org.apache.commons.collections.BidiMap; |
29 | |
import org.apache.commons.collections.bidimap.DualHashBidiMap; |
30 | |
import org.apache.commons.lang.StringUtils; |
31 | |
import org.kuali.rice.core.api.config.property.ConfigurationService; |
32 | |
import org.kuali.rice.core.api.encryption.EncryptionService; |
33 | |
import org.kuali.rice.core.api.services.CoreApiServiceLocator; |
34 | |
import org.kuali.rice.core.web.format.Formatter; |
35 | |
import org.kuali.rice.kns.bo.BusinessObject; |
36 | |
import org.kuali.rice.kns.bo.BusinessObjectRelationship; |
37 | |
import org.kuali.rice.kns.bo.DocumentHeader; |
38 | |
import org.kuali.rice.kns.bo.ExternalizableBusinessObject; |
39 | |
import org.kuali.rice.kns.datadictionary.AttributeSecurity; |
40 | |
import org.kuali.rice.kns.datadictionary.InquirySectionDefinition; |
41 | |
import org.kuali.rice.kns.lookup.CollectionIncomplete; |
42 | |
import org.kuali.rice.kns.lookup.HtmlData; |
43 | |
import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData; |
44 | |
import org.kuali.rice.kns.lookup.LookupUtils; |
45 | |
import org.kuali.rice.kns.service.BusinessObjectAuthorizationService; |
46 | |
import org.kuali.rice.kns.service.BusinessObjectDictionaryService; |
47 | |
import org.kuali.rice.kns.service.BusinessObjectMetaDataService; |
48 | |
import org.kuali.rice.kns.service.BusinessObjectService; |
49 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
50 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
51 | |
import org.kuali.rice.kns.service.LookupService; |
52 | |
import org.kuali.rice.kns.service.ModuleService; |
53 | |
import org.kuali.rice.kns.service.PersistenceStructureService; |
54 | |
import org.kuali.rice.kns.uif.service.impl.ViewHelperServiceImpl; |
55 | |
import org.kuali.rice.kns.uif.widget.Inquiry; |
56 | |
import org.kuali.rice.kns.util.ExternalizableBusinessObjectUtils; |
57 | |
import org.kuali.rice.kns.util.GlobalVariables; |
58 | |
import org.kuali.rice.kns.util.InactiveRecordsHidingUtils; |
59 | |
import org.kuali.rice.kns.util.KNSConstants; |
60 | |
import org.kuali.rice.kns.util.ObjectUtils; |
61 | |
import org.kuali.rice.kns.util.UrlFactory; |
62 | |
import org.kuali.rice.kns.web.ui.Section; |
63 | |
import org.kuali.rice.kns.web.ui.SectionBridge; |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
public class KualiInquirableImpl extends ViewHelperServiceImpl implements Inquirable { |
76 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiInquirableImpl.class); |
77 | |
|
78 | |
protected LookupService lookupService; |
79 | |
protected BusinessObjectAuthorizationService businessObjectAuthorizationService; |
80 | |
protected BusinessObjectDictionaryService businessObjectDictionaryService; |
81 | |
protected BusinessObjectMetaDataService businessObjectMetaDataService; |
82 | |
protected PersistenceStructureService persistenceStructureService; |
83 | |
protected EncryptionService encryptionService; |
84 | |
protected ConfigurationService kualiConfigurationService; |
85 | |
protected static BusinessObjectService businessObjectService; |
86 | |
|
87 | |
protected Class<?> dataObjectClass; |
88 | |
|
89 | |
protected Map<String, Boolean> inactiveRecordDisplay; |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | 0 | public static List<Class<?>> SUPER_CLASS_TRANSLATOR_LIST = new ArrayList<Class<?>>(); |
99 | |
public static final String INQUIRY_TITLE_PREFIX = "title.inquiry.url.value.prependtext"; |
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | 0 | public KualiInquirableImpl() { |
105 | 0 | inactiveRecordDisplay = new HashMap<String, Boolean>(); |
106 | 0 | } |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
@SuppressWarnings("rawtypes") |
115 | |
@Override |
116 | |
public Object getDataObject(Map fieldValues) { |
117 | 0 | if (getDataObjectClass() == null) { |
118 | 0 | LOG.error("Data object class not set in inquirable."); |
119 | 0 | throw new RuntimeException( |
120 | |
"Data object class not set in inquirable."); |
121 | |
} |
122 | |
|
123 | 0 | CollectionIncomplete<Object> searchResults = null; |
124 | 0 | ModuleService moduleService = KNSServiceLocatorWeb |
125 | |
.getKualiModuleService().getResponsibleModuleService( |
126 | |
getDataObjectClass()); |
127 | 0 | if (moduleService != null |
128 | |
&& moduleService.isExternalizable(getDataObjectClass())) { |
129 | 0 | BusinessObject bo = moduleService.getExternalizableBusinessObject( |
130 | |
getBusinessObjectClass(), fieldValues); |
131 | 0 | if (bo != null) { |
132 | 0 | ArrayList<Object> list = new ArrayList<Object>(1); |
133 | 0 | list.add(bo); |
134 | 0 | searchResults = new CollectionIncomplete<Object>(list, 1L); |
135 | |
} |
136 | 0 | } else { |
137 | |
|
138 | |
|
139 | 0 | searchResults = (CollectionIncomplete<Object>) getLookupService() |
140 | |
.findCollectionBySearch(getBusinessObjectClass(), |
141 | |
fieldValues); |
142 | |
} |
143 | |
|
144 | 0 | BusinessObject foundObject = null; |
145 | 0 | if (searchResults != null && searchResults.size() > 0) { |
146 | 0 | foundObject = (BusinessObject) searchResults.get(0); |
147 | |
} |
148 | |
|
149 | 0 | return foundObject; |
150 | |
} |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
@Deprecated |
158 | |
public BusinessObject getBusinessObject(Map fieldValues) { |
159 | 0 | return (BusinessObject)getDataObject(fieldValues); |
160 | |
} |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
@Deprecated |
167 | |
public List<Section> getSections(BusinessObject bo) { |
168 | |
|
169 | 0 | List<Section> sections = new ArrayList<Section>(); |
170 | 0 | if (getBusinessObjectClass() == null) { |
171 | 0 | LOG.error("Business object class not set in inquirable."); |
172 | 0 | throw new RuntimeException("Business object class not set in inquirable."); |
173 | |
} |
174 | |
|
175 | 0 | InquiryRestrictions inquiryRestrictions = KNSServiceLocatorWeb.getBusinessObjectAuthorizationService() |
176 | |
.getInquiryRestrictions(bo, GlobalVariables.getUserSession().getPerson()); |
177 | |
|
178 | 0 | Collection<InquirySectionDefinition> inquirySections = getBusinessObjectDictionaryService().getInquirySections( |
179 | |
getBusinessObjectClass()); |
180 | 0 | for (Iterator<InquirySectionDefinition> iter = inquirySections.iterator(); iter.hasNext();) { |
181 | 0 | InquirySectionDefinition inquirySection = iter.next(); |
182 | 0 | if (!inquiryRestrictions.isHiddenSectionId(inquirySection.getId())) { |
183 | 0 | Section section = SectionBridge.toSection(this, inquirySection, bo, inquiryRestrictions); |
184 | 0 | sections.add(section); |
185 | |
} |
186 | 0 | } |
187 | |
|
188 | 0 | return sections; |
189 | |
} |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
public void buildInquirableLink(Object dataObject, String propertyName, Inquiry inquiry) { |
196 | 0 | Class<?> inquiryObjectClass = null; |
197 | |
|
198 | |
|
199 | 0 | Class<?> objectClass = ObjectUtils.materializeClassForProxiedObject(dataObject); |
200 | 0 | if (propertyName.equals(getBusinessObjectMetaDataService().getTitleAttribute(objectClass))) { |
201 | 0 | inquiryObjectClass = objectClass; |
202 | |
} |
203 | 0 | else if (ObjectUtils.isNestedAttribute(propertyName)) { |
204 | 0 | String nestedPropertyName = ObjectUtils.getNestedAttributePrefix(propertyName); |
205 | 0 | Object nestedPropertyObject = ObjectUtils.getNestedValue(dataObject, nestedPropertyName); |
206 | |
|
207 | 0 | if (ObjectUtils.isNotNull(nestedPropertyObject)) { |
208 | 0 | String nestedPropertyPrimitive = ObjectUtils.getNestedAttributePrimitive(propertyName); |
209 | 0 | Class<?> nestedPropertyObjectClass = ObjectUtils.materializeClassForProxiedObject(nestedPropertyObject); |
210 | |
|
211 | 0 | if (nestedPropertyPrimitive.equals(getBusinessObjectMetaDataService().getTitleAttribute(nestedPropertyObjectClass))) { |
212 | 0 | inquiryObjectClass = nestedPropertyObjectClass; |
213 | |
} |
214 | |
} |
215 | |
} |
216 | |
|
217 | |
|
218 | 0 | BusinessObjectRelationship relationship = null; |
219 | 0 | if (inquiryObjectClass == null) { |
220 | 0 | relationship = getBusinessObjectMetaDataService().getDataObjectRelationship(dataObject, objectClass, |
221 | |
propertyName, "", true, false, true); |
222 | 0 | if (relationship != null) { |
223 | 0 | inquiryObjectClass = relationship.getRelatedClass(); |
224 | |
} |
225 | |
} |
226 | |
|
227 | |
|
228 | 0 | if (inquiryObjectClass == null) { |
229 | 0 | inquiry.setRender(false); |
230 | |
|
231 | 0 | return; |
232 | |
} |
233 | |
|
234 | 0 | if (DocumentHeader.class.isAssignableFrom(inquiryObjectClass)) { |
235 | 0 | String documentNumber = (String) ObjectUtils.getPropertyValue(dataObject, propertyName); |
236 | 0 | if (StringUtils.isNotBlank(documentNumber)) { |
237 | 0 | inquiry.getInquiryLinkField().setHrefText( |
238 | |
getKualiConfigurationService().getPropertyString(KNSConstants.WORKFLOW_URL_KEY) |
239 | |
+ KNSConstants.DOCHANDLER_DO_URL + documentNumber + KNSConstants.DOCHANDLER_URL_CHUNK); |
240 | 0 | inquiry.getInquiryLinkField().setLinkLabel(documentNumber); |
241 | 0 | inquiry.setRender(true); |
242 | |
} |
243 | |
|
244 | 0 | return; |
245 | |
} |
246 | |
|
247 | 0 | synchronized (SUPER_CLASS_TRANSLATOR_LIST) { |
248 | 0 | for (Class<?> clazz : SUPER_CLASS_TRANSLATOR_LIST) { |
249 | 0 | if (clazz.isAssignableFrom(inquiryObjectClass)) { |
250 | 0 | inquiryObjectClass = clazz; |
251 | 0 | break; |
252 | |
} |
253 | |
} |
254 | 0 | } |
255 | |
|
256 | 0 | if (!inquiryObjectClass.isInterface() |
257 | |
&& ExternalizableBusinessObject.class.isAssignableFrom(inquiryObjectClass)) { |
258 | 0 | inquiryObjectClass = ExternalizableBusinessObjectUtils |
259 | |
.determineExternalizableBusinessObjectSubInterface(inquiryObjectClass); |
260 | |
} |
261 | |
|
262 | |
|
263 | |
|
264 | 0 | List<String> keys = new ArrayList<String>(getBusinessObjectMetaDataService().listPrimaryKeyFieldNames( |
265 | |
inquiryObjectClass)); |
266 | |
|
267 | 0 | if (keys == null) { |
268 | 0 | keys = Collections.emptyList(); |
269 | |
} |
270 | |
|
271 | |
|
272 | 0 | Map<String, String> inquiryParameters = new HashMap<String, String>(); |
273 | 0 | for (String keyName : keys) { |
274 | 0 | String keyConversion = keyName; |
275 | 0 | if (relationship != null) { |
276 | 0 | keyConversion = relationship.getChildAttributeForParentAttribute(keyName); |
277 | |
} |
278 | 0 | else if (ObjectUtils.isNestedAttribute(propertyName)) { |
279 | 0 | String nestedAttributePrefix = ObjectUtils.getNestedAttributePrefix(propertyName); |
280 | 0 | keyConversion = nestedAttributePrefix + "." + keyName; |
281 | |
} |
282 | |
|
283 | 0 | inquiryParameters.put(keyConversion, keyName); |
284 | 0 | } |
285 | |
|
286 | 0 | inquiry.buildInquiryLink(dataObject, propertyName, inquiryObjectClass, inquiryParameters); |
287 | 0 | } |
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
@Deprecated |
299 | |
public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { |
300 | 0 | Properties parameters = new Properties(); |
301 | 0 | AnchorHtmlData hRef = new AnchorHtmlData(KNSConstants.EMPTY_STRING, KNSConstants.EMPTY_STRING); |
302 | 0 | parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, "start"); |
303 | |
|
304 | 0 | Class inquiryBusinessObjectClass = null; |
305 | 0 | String attributeRefName = ""; |
306 | 0 | boolean isPkReference = false; |
307 | |
|
308 | 0 | boolean doesNestedReferenceHaveOwnPrimitiveReference = false; |
309 | 0 | BusinessObject nestedBusinessObject = null; |
310 | |
|
311 | 0 | Class businessObjectClass = ObjectUtils.materializeClassForProxiedObject(businessObject); |
312 | 0 | if (attributeName.equals(getBusinessObjectDictionaryService().getTitleAttribute(businessObjectClass))) { |
313 | 0 | inquiryBusinessObjectClass = businessObjectClass; |
314 | 0 | isPkReference = true; |
315 | |
} |
316 | |
else { |
317 | 0 | if (ObjectUtils.isNestedAttribute(attributeName)) { |
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
|
329 | 0 | String nestedReferenceName = ObjectUtils.getNestedAttributePrefix(attributeName); |
330 | 0 | Object nestedReferenceObject = ObjectUtils.getNestedValue(businessObject, nestedReferenceName); |
331 | |
|
332 | 0 | if (ObjectUtils.isNotNull(nestedReferenceObject) && nestedReferenceObject instanceof BusinessObject) { |
333 | 0 | nestedBusinessObject = (BusinessObject) nestedReferenceObject; |
334 | 0 | String nestedAttributePrimitive = ObjectUtils.getNestedAttributePrimitive(attributeName); |
335 | 0 | Class nestedBusinessObjectClass = ObjectUtils |
336 | |
.materializeClassForProxiedObject(nestedBusinessObject); |
337 | |
|
338 | 0 | if (nestedAttributePrimitive.equals(getBusinessObjectDictionaryService().getTitleAttribute( |
339 | |
nestedBusinessObjectClass))) { |
340 | |
|
341 | |
|
342 | 0 | inquiryBusinessObjectClass = nestedBusinessObjectClass; |
343 | |
|
344 | |
|
345 | 0 | doesNestedReferenceHaveOwnPrimitiveReference = false; |
346 | |
} |
347 | |
else { |
348 | 0 | Map primitiveReference = LookupUtils.getPrimitiveReference(nestedBusinessObject, |
349 | |
nestedAttributePrimitive); |
350 | 0 | if (primitiveReference != null && !primitiveReference.isEmpty()) { |
351 | 0 | attributeRefName = (String) primitiveReference.keySet().iterator().next(); |
352 | 0 | inquiryBusinessObjectClass = (Class) primitiveReference.get(attributeRefName); |
353 | 0 | doesNestedReferenceHaveOwnPrimitiveReference = true; |
354 | |
} |
355 | |
else { |
356 | |
|
357 | |
|
358 | 0 | inquiryBusinessObjectClass = ObjectUtils |
359 | |
.materializeClassForProxiedObject(nestedBusinessObject); |
360 | |
|
361 | |
|
362 | 0 | doesNestedReferenceHaveOwnPrimitiveReference = false; |
363 | |
} |
364 | |
} |
365 | |
} |
366 | 0 | } |
367 | |
else { |
368 | 0 | Map primitiveReference = LookupUtils.getPrimitiveReference(businessObject, attributeName); |
369 | 0 | if (primitiveReference != null && !primitiveReference.isEmpty()) { |
370 | 0 | attributeRefName = (String) primitiveReference.keySet().iterator().next(); |
371 | 0 | inquiryBusinessObjectClass = (Class) primitiveReference.get(attributeRefName); |
372 | |
} |
373 | |
} |
374 | |
} |
375 | |
|
376 | 0 | if (inquiryBusinessObjectClass != null && DocumentHeader.class.isAssignableFrom(inquiryBusinessObjectClass)) { |
377 | 0 | String documentNumber = (String) ObjectUtils.getPropertyValue(businessObject, attributeName); |
378 | 0 | if (!StringUtils.isBlank(documentNumber)) { |
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
|
387 | 0 | hRef.setHref(getKualiConfigurationService().getPropertyString(KNSConstants.WORKFLOW_URL_KEY) |
388 | |
+ KNSConstants.DOCHANDLER_DO_URL + documentNumber + KNSConstants.DOCHANDLER_URL_CHUNK); |
389 | |
} |
390 | 0 | return hRef; |
391 | |
} |
392 | |
|
393 | 0 | if (inquiryBusinessObjectClass == null |
394 | |
|| getBusinessObjectDictionaryService().isInquirable(inquiryBusinessObjectClass) == null |
395 | |
|| !getBusinessObjectDictionaryService().isInquirable(inquiryBusinessObjectClass).booleanValue()) { |
396 | 0 | return hRef; |
397 | |
} |
398 | |
|
399 | 0 | synchronized (SUPER_CLASS_TRANSLATOR_LIST) { |
400 | 0 | for (Class clazz : SUPER_CLASS_TRANSLATOR_LIST) { |
401 | 0 | if (clazz.isAssignableFrom(inquiryBusinessObjectClass)) { |
402 | 0 | inquiryBusinessObjectClass = clazz; |
403 | 0 | break; |
404 | |
} |
405 | |
} |
406 | 0 | } |
407 | |
|
408 | 0 | if (!inquiryBusinessObjectClass.isInterface() |
409 | |
&& ExternalizableBusinessObject.class.isAssignableFrom(inquiryBusinessObjectClass)) { |
410 | 0 | inquiryBusinessObjectClass = ExternalizableBusinessObjectUtils |
411 | |
.determineExternalizableBusinessObjectSubInterface(inquiryBusinessObjectClass); |
412 | |
} |
413 | |
|
414 | 0 | parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, inquiryBusinessObjectClass.getName()); |
415 | |
|
416 | |
|
417 | |
|
418 | 0 | List<String> keys = new ArrayList<String>(getBusinessObjectMetaDataService().listPrimaryKeyFieldNames( |
419 | |
inquiryBusinessObjectClass)); |
420 | |
|
421 | 0 | if (keys == null) { |
422 | 0 | keys = Collections.emptyList(); |
423 | |
} |
424 | |
|
425 | 0 | BusinessObjectRelationship businessObjectRelationship = null; |
426 | |
|
427 | 0 | if (attributeRefName != null && !"".equals(attributeRefName)) { |
428 | 0 | businessObjectRelationship = getBusinessObjectMetaDataService().getBusinessObjectRelationship( |
429 | |
businessObject, attributeRefName); |
430 | |
|
431 | 0 | if (businessObjectRelationship != null && businessObjectRelationship.getParentToChildReferences() != null) { |
432 | 0 | for (String targetNamePrimaryKey : businessObjectRelationship.getParentToChildReferences().values()) { |
433 | 0 | keys.add(targetNamePrimaryKey); |
434 | |
} |
435 | |
} |
436 | |
} |
437 | |
|
438 | 0 | String keyName = null; |
439 | 0 | String keyConversion = null; |
440 | 0 | Map<String, String> fieldList = new HashMap<String, String>(); |
441 | 0 | for (Iterator iter = keys.iterator(); iter.hasNext();) { |
442 | 0 | keyName = (String) iter.next(); |
443 | 0 | keyConversion = keyName; |
444 | 0 | if (ObjectUtils.isNestedAttribute(attributeName)) { |
445 | 0 | if (doesNestedReferenceHaveOwnPrimitiveReference) { |
446 | 0 | String nestedAttributePrefix = ObjectUtils.getNestedAttributePrefix(attributeName); |
447 | |
|
448 | |
|
449 | |
|
450 | |
|
451 | |
|
452 | 0 | String foreignKeyFieldName = getBusinessObjectMetaDataService().getForeignKeyFieldName( |
453 | |
nestedBusinessObject.getClass(), attributeRefName, keyName); |
454 | 0 | keyConversion = nestedAttributePrefix + "." + foreignKeyFieldName; |
455 | 0 | } |
456 | |
else { |
457 | 0 | keyConversion = ObjectUtils.getNestedAttributePrefix(attributeName) + "." + keyName; |
458 | |
} |
459 | |
} |
460 | |
else { |
461 | 0 | if (isPkReference) { |
462 | 0 | keyConversion = keyName; |
463 | |
} |
464 | 0 | else if (businessObjectRelationship != null) { |
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | 0 | BidiMap bidiMap = new DualHashBidiMap(businessObjectRelationship.getParentToChildReferences()); |
480 | 0 | keyConversion = (String) bidiMap.getKey(keyName); |
481 | |
|
482 | |
|
483 | |
|
484 | |
} |
485 | |
} |
486 | 0 | Object keyValue = null; |
487 | 0 | if (keyConversion != null) { |
488 | 0 | keyValue = ObjectUtils.getPropertyValue(businessObject, keyConversion); |
489 | |
} |
490 | |
|
491 | 0 | if (keyValue == null) { |
492 | 0 | keyValue = ""; |
493 | |
} |
494 | 0 | else if (keyValue instanceof java.sql.Date) { |
495 | |
|
496 | 0 | if (Formatter.findFormatter(keyValue.getClass()) != null) { |
497 | 0 | Formatter formatter = Formatter.getFormatter(keyValue.getClass()); |
498 | 0 | keyValue = (String) formatter.format(keyValue); |
499 | 0 | } |
500 | |
} |
501 | |
else { |
502 | 0 | keyValue = keyValue.toString(); |
503 | |
} |
504 | |
|
505 | |
|
506 | |
|
507 | |
|
508 | |
|
509 | 0 | AttributeSecurity attributeSecurity = KNSServiceLocatorWeb.getDataDictionaryService().getAttributeSecurity( |
510 | |
businessObject.getClass().getName(), keyName); |
511 | 0 | if (attributeSecurity != null && attributeSecurity.hasRestrictionThatRemovesValueFromUI()) { |
512 | |
try { |
513 | 0 | keyValue = getEncryptionService().encrypt(keyValue); |
514 | |
} |
515 | 0 | catch (GeneralSecurityException e) { |
516 | 0 | LOG.error("Exception while trying to encrypted value for inquiry framework.", e); |
517 | 0 | throw new RuntimeException(e); |
518 | 0 | } |
519 | |
} |
520 | |
|
521 | 0 | parameters.put(keyName, keyValue); |
522 | 0 | fieldList.put(keyName, keyValue.toString()); |
523 | 0 | } |
524 | |
|
525 | 0 | return getHyperLink(inquiryBusinessObjectClass, fieldList, |
526 | |
UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters)); |
527 | |
} |
528 | |
|
529 | |
@Deprecated |
530 | |
protected AnchorHtmlData getHyperLink(Class inquiryClass, Map<String, String> fieldList, String inquiryUrl) { |
531 | 0 | AnchorHtmlData a = new AnchorHtmlData(inquiryUrl, KNSConstants.EMPTY_STRING); |
532 | 0 | a.setTitle(HtmlData.getTitleText(this.createTitleText(inquiryClass), inquiryClass, fieldList)); |
533 | 0 | return a; |
534 | |
} |
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | |
|
541 | |
|
542 | |
|
543 | |
@Deprecated |
544 | |
protected String createTitleText(Class<?> dataObjectClass) { |
545 | 0 | String titleText = ""; |
546 | |
|
547 | 0 | String titlePrefixProp = getKualiConfigurationService().getPropertyString(INQUIRY_TITLE_PREFIX); |
548 | 0 | if (StringUtils.isNotBlank(titlePrefixProp)) { |
549 | 0 | titleText += titlePrefixProp + " "; |
550 | |
} |
551 | |
|
552 | 0 | String objectLabel = getDataDictionaryService().getDataDictionary() |
553 | |
.getBusinessObjectEntry(dataObjectClass.getName()).getObjectLabel(); |
554 | 0 | if (StringUtils.isNotBlank(objectLabel)) { |
555 | 0 | titleText += objectLabel + " "; |
556 | |
} |
557 | |
|
558 | 0 | return titleText; |
559 | |
} |
560 | |
|
561 | |
@Deprecated |
562 | |
public void addAdditionalSections(List columns, BusinessObject bo) { |
563 | 0 | } |
564 | |
|
565 | |
|
566 | |
|
567 | |
|
568 | |
@Deprecated |
569 | |
public String getHtmlMenuBar() { |
570 | |
|
571 | 0 | return getBusinessObjectDictionaryService().getLookupMenuBar(getBusinessObjectClass()); |
572 | |
} |
573 | |
|
574 | |
|
575 | |
|
576 | |
|
577 | |
@Deprecated |
578 | |
public String getTitle() { |
579 | 0 | return getBusinessObjectDictionaryService().getInquiryTitle(getBusinessObjectClass()); |
580 | |
} |
581 | |
|
582 | |
public Class<?> getDataObjectClass() { |
583 | 0 | return dataObjectClass; |
584 | |
} |
585 | |
|
586 | |
|
587 | |
|
588 | |
|
589 | |
@Override |
590 | |
public void setDataObjectClass(Class<?> dataObjectClass) { |
591 | 0 | this.dataObjectClass = dataObjectClass; |
592 | 0 | } |
593 | |
|
594 | |
|
595 | |
|
596 | |
|
597 | |
|
598 | |
@Deprecated |
599 | |
public void setBusinessObjectClass(Class businessObjectClass) { |
600 | 0 | this.dataObjectClass = businessObjectClass; |
601 | 0 | } |
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
@Deprecated |
607 | |
public Class getBusinessObjectClass() { |
608 | 0 | return dataObjectClass; |
609 | |
} |
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
@Deprecated |
615 | |
public Map<String, Boolean> getInactiveRecordDisplay() { |
616 | 0 | return inactiveRecordDisplay; |
617 | |
} |
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
@Deprecated |
623 | |
public boolean getShowInactiveRecords(String collectionName) { |
624 | 0 | return InactiveRecordsHidingUtils.getShowInactiveRecords(inactiveRecordDisplay, collectionName); |
625 | |
} |
626 | |
|
627 | |
|
628 | |
|
629 | |
|
630 | |
|
631 | |
@Deprecated |
632 | |
public void setShowInactiveRecords(String collectionName, boolean showInactive) { |
633 | 0 | InactiveRecordsHidingUtils.setShowInactiveRecords(inactiveRecordDisplay, collectionName, showInactive); |
634 | 0 | } |
635 | |
|
636 | |
protected LookupService getLookupService() { |
637 | 0 | if (lookupService == null) { |
638 | 0 | lookupService = KNSServiceLocatorWeb.getLookupService(); |
639 | |
} |
640 | 0 | return lookupService; |
641 | |
} |
642 | |
|
643 | |
public void setLookupService(LookupService lookupService) { |
644 | 0 | this.lookupService = lookupService; |
645 | 0 | } |
646 | |
|
647 | |
protected BusinessObjectDictionaryService getBusinessObjectDictionaryService() { |
648 | 0 | if (businessObjectDictionaryService == null) { |
649 | 0 | businessObjectDictionaryService = KNSServiceLocatorWeb.getBusinessObjectDictionaryService(); |
650 | |
} |
651 | 0 | return businessObjectDictionaryService; |
652 | |
} |
653 | |
|
654 | |
public void setBusinessObjectDictionaryService(BusinessObjectDictionaryService businessObjectDictionaryService) { |
655 | 0 | this.businessObjectDictionaryService = businessObjectDictionaryService; |
656 | 0 | } |
657 | |
|
658 | |
protected PersistenceStructureService getPersistenceStructureService() { |
659 | 0 | if (persistenceStructureService == null) { |
660 | 0 | persistenceStructureService = KNSServiceLocator.getPersistenceStructureService(); |
661 | |
} |
662 | 0 | return this.persistenceStructureService; |
663 | |
} |
664 | |
|
665 | |
public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService) { |
666 | 0 | this.persistenceStructureService = persistenceStructureService; |
667 | 0 | } |
668 | |
|
669 | |
protected EncryptionService getEncryptionService() { |
670 | 0 | if (encryptionService == null) { |
671 | 0 | encryptionService = CoreApiServiceLocator.getEncryptionService(); |
672 | |
} |
673 | 0 | return this.encryptionService; |
674 | |
} |
675 | |
|
676 | |
public void setEncryptionService(EncryptionService encryptionService) { |
677 | 0 | this.encryptionService = encryptionService; |
678 | 0 | } |
679 | |
|
680 | |
protected ConfigurationService getKualiConfigurationService() { |
681 | 0 | if (kualiConfigurationService == null) { |
682 | 0 | kualiConfigurationService = KNSServiceLocator.getKualiConfigurationService(); |
683 | |
} |
684 | 0 | return this.kualiConfigurationService; |
685 | |
} |
686 | |
|
687 | |
public void setKualiConfigurationService(ConfigurationService kualiConfigurationService) { |
688 | 0 | this.kualiConfigurationService = kualiConfigurationService; |
689 | 0 | } |
690 | |
|
691 | |
protected BusinessObjectMetaDataService getBusinessObjectMetaDataService() { |
692 | 0 | if (businessObjectMetaDataService == null) { |
693 | 0 | businessObjectMetaDataService = KNSServiceLocatorWeb.getBusinessObjectMetaDataService(); |
694 | |
} |
695 | 0 | return this.businessObjectMetaDataService; |
696 | |
} |
697 | |
|
698 | |
public void setBusinessObjectMetaDataService(BusinessObjectMetaDataService businessObjectMetaDataService) { |
699 | 0 | this.businessObjectMetaDataService = businessObjectMetaDataService; |
700 | 0 | } |
701 | |
|
702 | |
protected BusinessObjectService getBusinessObjectService() { |
703 | 0 | if (businessObjectService == null) { |
704 | 0 | businessObjectService = KNSServiceLocator.getBusinessObjectService(); |
705 | |
} |
706 | 0 | return businessObjectService; |
707 | |
} |
708 | |
|
709 | |
protected BusinessObjectAuthorizationService getBusinessObjectAuthorizationService() { |
710 | 0 | if (this.businessObjectAuthorizationService == null) { |
711 | 0 | this.businessObjectAuthorizationService = KNSServiceLocatorWeb.getBusinessObjectAuthorizationService(); |
712 | |
} |
713 | 0 | return this.businessObjectAuthorizationService; |
714 | |
} |
715 | |
|
716 | |
public void setBusinessObjectAuthorizationService( |
717 | |
BusinessObjectAuthorizationService businessObjectAuthorizationService) { |
718 | 0 | this.businessObjectAuthorizationService = businessObjectAuthorizationService; |
719 | 0 | } |
720 | |
|
721 | |
@Deprecated |
722 | |
protected AnchorHtmlData getInquiryUrlForPrimaryKeys(Class clazz, Object businessObject, List<String> primaryKeys, |
723 | |
String displayText) { |
724 | 0 | if (businessObject == null) |
725 | 0 | return new AnchorHtmlData(KNSConstants.EMPTY_STRING, KNSConstants.EMPTY_STRING); |
726 | |
|
727 | 0 | Properties parameters = new Properties(); |
728 | 0 | parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, KNSConstants.START_METHOD); |
729 | 0 | parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, clazz.getName()); |
730 | |
|
731 | |
String titleAttributeValue; |
732 | 0 | Map<String, String> fieldList = new HashMap<String, String>(); |
733 | 0 | for (String primaryKey : primaryKeys) { |
734 | 0 | titleAttributeValue = (String) ObjectUtils.getPropertyValue(businessObject, primaryKey); |
735 | 0 | parameters.put(primaryKey, titleAttributeValue); |
736 | 0 | fieldList.put(primaryKey, titleAttributeValue); |
737 | |
} |
738 | 0 | if (StringUtils.isEmpty(displayText)) |
739 | 0 | return getHyperLink(clazz, fieldList, UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters)); |
740 | |
else |
741 | 0 | return getHyperLink(clazz, fieldList, UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters), |
742 | |
displayText); |
743 | |
} |
744 | |
|
745 | |
@Deprecated |
746 | |
protected AnchorHtmlData getHyperLink(Class inquiryClass, Map<String, String> fieldList, String inquiryUrl, |
747 | |
String displayText) { |
748 | 0 | AnchorHtmlData a = new AnchorHtmlData(inquiryUrl, KNSConstants.EMPTY_STRING, displayText); |
749 | 0 | a.setTitle(AnchorHtmlData.getTitleText(getKualiConfigurationService().getPropertyString(INQUIRY_TITLE_PREFIX) |
750 | |
+ " " |
751 | |
+ getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(inquiryClass.getName()) |
752 | |
.getObjectLabel() + " ", inquiryClass, fieldList)); |
753 | 0 | return a; |
754 | |
} |
755 | |
|
756 | |
} |