1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.maintenance; |
17 | |
|
18 | |
import java.beans.PropertyDescriptor; |
19 | |
import java.io.Serializable; |
20 | |
import java.lang.reflect.InvocationTargetException; |
21 | |
import java.security.GeneralSecurityException; |
22 | |
import java.util.ArrayList; |
23 | |
import java.util.Arrays; |
24 | |
import java.util.Collection; |
25 | |
import java.util.HashMap; |
26 | |
import java.util.HashSet; |
27 | |
import java.util.Iterator; |
28 | |
import java.util.List; |
29 | |
import java.util.Map; |
30 | |
import java.util.Set; |
31 | |
|
32 | |
import org.apache.commons.beanutils.PropertyUtils; |
33 | |
import org.apache.commons.lang.StringUtils; |
34 | |
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException; |
35 | |
import org.kuali.rice.core.api.encryption.EncryptionService; |
36 | |
import org.kuali.rice.core.api.services.CoreApiServiceLocator; |
37 | |
import org.kuali.rice.core.web.format.FormatException; |
38 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
39 | |
import org.kuali.rice.kim.bo.Person; |
40 | |
import org.kuali.rice.kns.authorization.FieldRestriction; |
41 | |
import org.kuali.rice.kns.bo.BusinessObject; |
42 | |
import org.kuali.rice.kns.bo.BusinessObjectRelationship; |
43 | |
import org.kuali.rice.kns.bo.DocumentHeader; |
44 | |
import org.kuali.rice.kns.bo.PersistableBusinessObject; |
45 | |
import org.kuali.rice.kns.datadictionary.AttributeSecurity; |
46 | |
import org.kuali.rice.kns.datadictionary.MaintainableCollectionDefinition; |
47 | |
import org.kuali.rice.kns.datadictionary.MaintainableFieldDefinition; |
48 | |
import org.kuali.rice.kns.datadictionary.MaintainableItemDefinition; |
49 | |
import org.kuali.rice.kns.datadictionary.MaintainableSectionDefinition; |
50 | |
import org.kuali.rice.kns.datadictionary.exception.UnknownBusinessClassAttributeException; |
51 | |
import org.kuali.rice.kns.document.MaintenanceDocument; |
52 | |
import org.kuali.rice.kns.document.MaintenanceLock; |
53 | |
import org.kuali.rice.kns.document.authorization.MaintenanceDocumentPresentationController; |
54 | |
import org.kuali.rice.kns.document.authorization.MaintenanceDocumentRestrictions; |
55 | |
import org.kuali.rice.kns.exception.DocumentTypeAuthorizationException; |
56 | |
import org.kuali.rice.kns.exception.PessimisticLockingException; |
57 | |
import org.kuali.rice.kns.lookup.LookupUtils; |
58 | |
import org.kuali.rice.kns.lookup.valuefinder.ValueFinder; |
59 | |
import org.kuali.rice.kns.service.BusinessObjectAuthorizationService; |
60 | |
import org.kuali.rice.kns.service.BusinessObjectDictionaryService; |
61 | |
import org.kuali.rice.kns.service.BusinessObjectMetaDataService; |
62 | |
import org.kuali.rice.kns.service.BusinessObjectService; |
63 | |
import org.kuali.rice.kns.service.DataDictionaryService; |
64 | |
import org.kuali.rice.kns.service.DocumentHelperService; |
65 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
66 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
67 | |
import org.kuali.rice.kns.service.LookupService; |
68 | |
import org.kuali.rice.kns.service.MaintenanceDocumentDictionaryService; |
69 | |
import org.kuali.rice.kns.service.MaintenanceDocumentService; |
70 | |
import org.kuali.rice.kns.service.ModuleService; |
71 | |
import org.kuali.rice.kns.service.PersistenceStructureService; |
72 | |
import org.kuali.rice.kns.uif.container.CollectionGroup; |
73 | |
import org.kuali.rice.kns.uif.container.View; |
74 | |
import org.kuali.rice.kns.uif.service.impl.ViewHelperServiceImpl; |
75 | |
import org.kuali.rice.kns.uif.util.ObjectPropertyUtils; |
76 | |
import org.kuali.rice.kns.util.FieldUtils; |
77 | |
import org.kuali.rice.kns.util.GlobalVariables; |
78 | |
import org.kuali.rice.kns.util.InactiveRecordsHidingUtils; |
79 | |
import org.kuali.rice.kns.util.KNSConstants; |
80 | |
import org.kuali.rice.kns.util.KNSPropertyConstants; |
81 | |
import org.kuali.rice.kns.util.MaintenanceUtils; |
82 | |
import org.kuali.rice.kns.util.MessageMap; |
83 | |
import org.kuali.rice.kns.util.ObjectUtils; |
84 | |
import org.kuali.rice.kns.util.WebUtils; |
85 | |
import org.kuali.rice.kns.web.spring.form.MaintenanceForm; |
86 | |
import org.kuali.rice.kns.web.ui.Section; |
87 | |
import org.kuali.rice.kns.web.ui.SectionBridge; |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
public class KualiMaintainableImpl extends ViewHelperServiceImpl implements Maintainable { |
93 | |
private static final long serialVersionUID = 4814145799502207182L; |
94 | |
|
95 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiMaintainableImpl.class); |
96 | |
|
97 | |
protected String documentNumber; |
98 | |
protected Object dataObject; |
99 | |
protected PersistableBusinessObject businessObject; |
100 | |
protected Class boClass; |
101 | |
protected String maintenanceAction; |
102 | |
|
103 | 0 | protected Map<String, PersistableBusinessObject> newCollectionLines = new HashMap<String, PersistableBusinessObject>(); |
104 | 0 | protected Map<String, Boolean> inactiveRecordDisplay = new HashMap<String, Boolean>(); |
105 | |
|
106 | |
protected String docTypeName; |
107 | |
|
108 | |
|
109 | 0 | protected Set<String> newCollectionLineNames = new HashSet<String>(); |
110 | |
|
111 | |
protected transient PersistenceStructureService persistenceStructureService; |
112 | |
protected transient MaintenanceDocumentDictionaryService maintenanceDocumentDictionaryService; |
113 | |
protected transient BusinessObjectService businessObjectService; |
114 | |
protected transient BusinessObjectDictionaryService businessObjectDictionaryService; |
115 | |
protected transient EncryptionService encryptionService; |
116 | |
protected transient org.kuali.rice.kim.service.PersonService personService; |
117 | |
protected transient BusinessObjectMetaDataService businessObjectMetaDataService; |
118 | |
protected transient BusinessObjectAuthorizationService businessObjectAuthorizationService; |
119 | |
protected transient MaintenanceDocumentService maintenanceDocumentService; |
120 | |
protected transient DocumentHelperService documentHelperService; |
121 | |
protected transient LookupService lookupService; |
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
public KualiMaintainableImpl() { |
127 | 0 | super(); |
128 | 0 | } |
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
public KualiMaintainableImpl(PersistableBusinessObject businessObject) { |
136 | 0 | super(); |
137 | 0 | this.businessObject = businessObject; |
138 | 0 | this.dataObject = businessObject; |
139 | 0 | } |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
public void setupNewFromExisting(MaintenanceDocument document, Map<String, String[]> parameters) { |
148 | |
|
149 | 0 | } |
150 | |
|
151 | |
public void processAfterPost(MaintenanceDocument document, Map<String, String[]> parameters) { |
152 | |
|
153 | 0 | } |
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
public String getDocumentTitle(MaintenanceDocument document) { |
162 | |
|
163 | |
|
164 | 0 | return ""; |
165 | |
} |
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
public List<MaintenanceLock> generateMaintenanceLocks() { |
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | 0 | List<MaintenanceLock> maintenanceLocks = new ArrayList<MaintenanceLock>(); |
181 | 0 | StringBuffer lockRepresentation = new StringBuffer(boClass.getName()); |
182 | 0 | lockRepresentation.append(KNSConstants.Maintenance.AFTER_CLASS_DELIM); |
183 | |
|
184 | 0 | Object bo = getDataObject(); |
185 | 0 | List keyFieldNames = getMaintenanceDocumentDictionaryService().getLockingKeys(getDocumentTypeName()); |
186 | |
|
187 | 0 | for (Iterator i = keyFieldNames.iterator(); i.hasNext();) { |
188 | 0 | String fieldName = (String) i.next(); |
189 | 0 | Object fieldValue = ObjectUtils.getPropertyValue(bo, fieldName); |
190 | 0 | if (fieldValue == null) { |
191 | 0 | fieldValue = ""; |
192 | |
} |
193 | |
|
194 | |
|
195 | 0 | if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(boClass, |
196 | |
fieldName)) { |
197 | |
try { |
198 | 0 | fieldValue = getEncryptionService().encrypt(fieldValue); |
199 | |
} |
200 | 0 | catch (GeneralSecurityException e) { |
201 | 0 | LOG.error("Unable to encrypt secure field for locking representation " + e.getMessage()); |
202 | 0 | throw new RuntimeException("Unable to encrypt secure field for locking representation " |
203 | |
+ e.getMessage()); |
204 | 0 | } |
205 | |
} |
206 | |
|
207 | 0 | lockRepresentation.append(fieldName); |
208 | 0 | lockRepresentation.append(KNSConstants.Maintenance.AFTER_FIELDNAME_DELIM); |
209 | 0 | lockRepresentation.append(String.valueOf(fieldValue)); |
210 | 0 | if (i.hasNext()) { |
211 | 0 | lockRepresentation.append(KNSConstants.Maintenance.AFTER_VALUE_DELIM); |
212 | |
} |
213 | 0 | } |
214 | |
|
215 | 0 | MaintenanceLock maintenanceLock = new MaintenanceLock(); |
216 | 0 | maintenanceLock.setDocumentNumber(documentNumber); |
217 | 0 | maintenanceLock.setLockingRepresentation(lockRepresentation.toString()); |
218 | 0 | maintenanceLocks.add(maintenanceLock); |
219 | 0 | return maintenanceLocks; |
220 | |
} |
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
@SuppressWarnings("unchecked") |
227 | |
public Map populateBusinessObject(Map<String, String> fieldValues, MaintenanceDocument maintenanceDocument, |
228 | |
String methodToCall) { |
229 | 0 | fieldValues = decryptEncryptedData(fieldValues, maintenanceDocument, methodToCall); |
230 | 0 | Map newFieldValues = null; |
231 | 0 | newFieldValues = getPersonService().resolvePrincipalNamesToPrincipalIds(getBusinessObject(), fieldValues); |
232 | |
|
233 | 0 | Map cachedValues = FieldUtils.populateBusinessObjectFromMap(getBusinessObject(), newFieldValues); |
234 | 0 | performForceUpperCase(newFieldValues); |
235 | |
|
236 | 0 | return cachedValues; |
237 | |
} |
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
protected Map<String, String> decryptEncryptedData(Map<String, String> fieldValues, |
251 | |
MaintenanceDocument maintenanceDocument, String methodToCall) { |
252 | |
try { |
253 | 0 | MaintenanceDocumentRestrictions auths = KNSServiceLocatorWeb.getBusinessObjectAuthorizationService() |
254 | |
.getMaintenanceDocumentRestrictions(maintenanceDocument, |
255 | |
GlobalVariables.getUserSession().getPerson()); |
256 | 0 | for (Iterator<String> iter = fieldValues.keySet().iterator(); iter.hasNext();) { |
257 | 0 | String fieldName = iter.next(); |
258 | 0 | String fieldValue = (String) fieldValues.get(fieldName); |
259 | |
|
260 | 0 | if (fieldValue != null && !"".equals(fieldValue) |
261 | |
&& fieldValue.endsWith(EncryptionService.ENCRYPTION_POST_PREFIX)) { |
262 | 0 | if (shouldFieldBeEncrypted(maintenanceDocument, fieldName, auths, methodToCall)) { |
263 | 0 | String encryptedValue = fieldValue; |
264 | |
|
265 | |
|
266 | 0 | encryptedValue = StringUtils.stripEnd(encryptedValue, EncryptionService.ENCRYPTION_POST_PREFIX); |
267 | 0 | String decryptedValue = getEncryptionService().decrypt(encryptedValue); |
268 | |
|
269 | 0 | fieldValues.put(fieldName, decryptedValue); |
270 | 0 | } |
271 | |
else |
272 | 0 | throw new RuntimeException("The field value for field name " + fieldName |
273 | |
+ " should not be encrypted."); |
274 | |
} |
275 | 0 | else if (fieldValue != null && !"".equals(fieldValue) |
276 | |
&& shouldFieldBeEncrypted(maintenanceDocument, fieldName, auths, methodToCall)) |
277 | 0 | throw new RuntimeException("The field value for field name " + fieldName + " should be encrypted."); |
278 | 0 | } |
279 | |
} |
280 | 0 | catch (GeneralSecurityException e) { |
281 | 0 | throw new RuntimeException("Unable to decrypt secure data: " + e.getMessage()); |
282 | 0 | } |
283 | |
|
284 | 0 | return fieldValues; |
285 | |
} |
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
protected boolean shouldFieldBeEncrypted(MaintenanceDocument maintenanceDocument, String fieldName, |
307 | |
MaintenanceDocumentRestrictions auths, String methodToCall) { |
308 | 0 | if ("refresh".equals(methodToCall) && fieldName != null) { |
309 | 0 | fieldName = fieldName.replaceAll("\\[[0-9]*+\\]", ""); |
310 | 0 | fieldName = fieldName.replaceAll("^add\\.", ""); |
311 | 0 | Map<String, AttributeSecurity> fieldNameToAttributeSecurityMap = MaintenanceUtils |
312 | |
.retrievePropertyPathToAttributeSecurityMappings(getDocumentTypeName()); |
313 | 0 | AttributeSecurity attributeSecurity = fieldNameToAttributeSecurityMap.get(fieldName); |
314 | 0 | return attributeSecurity != null && attributeSecurity.hasRestrictionThatRemovesValueFromUI(); |
315 | |
} |
316 | |
else { |
317 | 0 | return false; |
318 | |
} |
319 | |
} |
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
public List getSections(MaintenanceDocument document, Maintainable oldMaintainable) { |
329 | 0 | List<Section> sections = new ArrayList<Section>(); |
330 | 0 | sections.addAll(getCoreSections(document, oldMaintainable)); |
331 | |
|
332 | 0 | return sections; |
333 | |
} |
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
public List<Section> getCoreSections(MaintenanceDocument document, Maintainable oldMaintainable) { |
345 | 0 | List<Section> sections = new ArrayList<Section>(); |
346 | 0 | MaintenanceDocumentRestrictions maintenanceRestrictions = KNSServiceLocatorWeb |
347 | |
.getBusinessObjectAuthorizationService().getMaintenanceDocumentRestrictions(document, |
348 | |
GlobalVariables.getUserSession().getPerson()); |
349 | |
|
350 | 0 | MaintenanceDocumentPresentationController maintenanceDocumentPresentationController = (MaintenanceDocumentPresentationController) getDocumentHelperService() |
351 | |
.getDocumentPresentationController(document); |
352 | 0 | Set<String> conditionallyRequiredFields = maintenanceDocumentPresentationController |
353 | |
.getConditionallyRequiredPropertyNames(document); |
354 | |
|
355 | 0 | List<MaintainableSectionDefinition> sectionDefinitions = getMaintenanceDocumentDictionaryService() |
356 | |
.getMaintainableSections(docTypeName); |
357 | |
try { |
358 | |
|
359 | 0 | for (Iterator iter = sectionDefinitions.iterator(); iter.hasNext();) { |
360 | 0 | MaintainableSectionDefinition maintSectionDef = (MaintainableSectionDefinition) iter.next(); |
361 | |
|
362 | 0 | List<String> displayedFieldNames = new ArrayList<String>(); |
363 | 0 | if (!maintenanceRestrictions.isHiddenSectionId(maintSectionDef.getId())) { |
364 | |
|
365 | 0 | for (Iterator iter2 = maintSectionDef.getMaintainableItems().iterator(); iter2.hasNext();) { |
366 | 0 | MaintainableItemDefinition item = (MaintainableItemDefinition) iter2.next(); |
367 | 0 | if (item instanceof MaintainableFieldDefinition) { |
368 | 0 | displayedFieldNames.add(((MaintainableFieldDefinition) item).getName()); |
369 | |
} |
370 | 0 | } |
371 | |
|
372 | 0 | Section section = SectionBridge.toSection(maintSectionDef, getBusinessObject(), this, |
373 | |
oldMaintainable, getMaintenanceAction(), displayedFieldNames, conditionallyRequiredFields); |
374 | 0 | if (maintenanceRestrictions.isReadOnlySectionId(maintSectionDef.getId())) { |
375 | 0 | section.setReadOnly(true); |
376 | |
} |
377 | |
|
378 | |
|
379 | 0 | sections.add(section); |
380 | |
} |
381 | |
|
382 | 0 | } |
383 | |
|
384 | |
} |
385 | 0 | catch (InstantiationException e) { |
386 | 0 | LOG.error("Unable to create instance of object class" + e.getMessage()); |
387 | 0 | throw new RuntimeException("Unable to create instance of object class" + e.getMessage()); |
388 | |
} |
389 | 0 | catch (IllegalAccessException e) { |
390 | 0 | LOG.error("Unable to create instance of object class" + e.getMessage()); |
391 | 0 | throw new RuntimeException("Unable to create instance of object class" + e.getMessage()); |
392 | 0 | } |
393 | |
|
394 | 0 | return sections; |
395 | |
} |
396 | |
|
397 | |
|
398 | |
|
399 | |
|
400 | |
|
401 | |
public void saveBusinessObject() { |
402 | 0 | getBusinessObjectService().linkAndSave(businessObject); |
403 | 0 | } |
404 | |
|
405 | |
|
406 | |
|
407 | |
|
408 | |
public String getMaintainableTitle() { |
409 | 0 | return getMaintenanceDocumentDictionaryService().getMaintenanceLabel(getDocumentTypeName()); |
410 | |
} |
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
public boolean isBoNotesEnabled() { |
416 | 0 | return getBusinessObjectDictionaryService().areNotesSupported(this.boClass); |
417 | |
} |
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
public void refresh(String refreshCaller, Map fieldValues, MaintenanceDocument document) { |
425 | 0 | String referencesToRefresh = (String) fieldValues.get(KNSConstants.REFERENCES_TO_REFRESH); |
426 | 0 | refreshReferences(referencesToRefresh); |
427 | 0 | } |
428 | |
|
429 | |
protected void refreshReferences(String referencesToRefresh) { |
430 | 0 | PersistenceStructureService persistenceStructureService = getPersistenceStructureService(); |
431 | 0 | if (StringUtils.isNotBlank(referencesToRefresh)) { |
432 | 0 | String[] references = StringUtils.split(referencesToRefresh, KNSConstants.REFERENCES_TO_REFRESH_SEPARATOR); |
433 | 0 | for (String reference : references) { |
434 | 0 | if (StringUtils.isNotBlank(reference)) { |
435 | 0 | if (reference.startsWith(KNSConstants.ADD_PREFIX + ".")) { |
436 | |
|
437 | 0 | reference = reference.substring(KNSConstants.ADD_PREFIX.length() + 1); |
438 | |
|
439 | 0 | String boToRefreshName = StringUtils.substringBeforeLast(reference, "."); |
440 | 0 | String propertyToRefresh = StringUtils.substringAfterLast(reference, "."); |
441 | 0 | if (StringUtils.isNotBlank(propertyToRefresh)) { |
442 | 0 | PersistableBusinessObject addlineBO = getNewCollectionLine(boToRefreshName); |
443 | 0 | Class addlineBOClass = addlineBO.getClass(); |
444 | 0 | if (LOG.isDebugEnabled()) { |
445 | 0 | LOG.debug("Refresh this \"new\"/add object for the collections: " + reference); |
446 | |
} |
447 | 0 | if (persistenceStructureService.hasReference(addlineBOClass, propertyToRefresh) |
448 | |
|| persistenceStructureService.hasCollection(addlineBOClass, propertyToRefresh)) { |
449 | 0 | addlineBO.refreshReferenceObject(propertyToRefresh); |
450 | |
} |
451 | |
else { |
452 | 0 | if (getDataDictionaryService().hasRelationship(addlineBOClass.getName(), |
453 | |
propertyToRefresh)) { |
454 | |
|
455 | |
|
456 | 0 | Object possibleBO = ObjectUtils.getPropertyValue(addlineBO, propertyToRefresh); |
457 | 0 | if (possibleBO != null && possibleBO instanceof PersistableBusinessObject) { |
458 | 0 | ((PersistableBusinessObject) possibleBO).refresh(); |
459 | |
} |
460 | |
} |
461 | |
} |
462 | 0 | } |
463 | |
else { |
464 | 0 | LOG.error("Error: unable to refresh this \"new\"/add object for the collections: " |
465 | |
+ reference); |
466 | |
} |
467 | 0 | } |
468 | 0 | else if (ObjectUtils.isNestedAttribute(reference)) { |
469 | 0 | Object nestedObject = ObjectUtils.getNestedValue(getBusinessObject(), |
470 | |
ObjectUtils.getNestedAttributePrefix(reference)); |
471 | 0 | if (nestedObject instanceof Collection) { |
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
} |
478 | 0 | else if (nestedObject instanceof PersistableBusinessObject) { |
479 | 0 | String propertyToRefresh = ObjectUtils.getNestedAttributePrimitive(reference); |
480 | 0 | if (persistenceStructureService.hasReference(nestedObject.getClass(), propertyToRefresh) |
481 | |
|| persistenceStructureService.hasCollection(nestedObject.getClass(), |
482 | |
propertyToRefresh)) { |
483 | 0 | if (LOG.isDebugEnabled()) { |
484 | 0 | LOG.debug("Refeshing " + ObjectUtils.getNestedAttributePrefix(reference) + " " |
485 | |
+ ObjectUtils.getNestedAttributePrimitive(reference)); |
486 | |
} |
487 | 0 | ((PersistableBusinessObject) nestedObject).refreshReferenceObject(propertyToRefresh); |
488 | |
} |
489 | |
else { |
490 | |
|
491 | |
|
492 | 0 | Object possibleBO = ObjectUtils.getPropertyValue(nestedObject, propertyToRefresh); |
493 | 0 | if (possibleBO != null && possibleBO instanceof PersistableBusinessObject) { |
494 | 0 | if (getDataDictionaryService().hasRelationship(possibleBO.getClass().getName(), |
495 | |
propertyToRefresh)) { |
496 | 0 | ((PersistableBusinessObject) possibleBO).refresh(); |
497 | |
} |
498 | |
} |
499 | |
} |
500 | 0 | } |
501 | |
else { |
502 | 0 | LOG.warn("Expected that a referenceToRefresh (" |
503 | |
+ reference |
504 | |
+ ") would be a PersistableBusinessObject or Collection, but instead, it was of class " |
505 | |
+ nestedObject.getClass().getName()); |
506 | |
} |
507 | 0 | } |
508 | |
else { |
509 | 0 | if (LOG.isDebugEnabled()) { |
510 | 0 | LOG.debug("Refreshing " + reference); |
511 | |
} |
512 | 0 | if (persistenceStructureService.hasReference(boClass, reference) |
513 | |
|| persistenceStructureService.hasCollection(boClass, reference)) { |
514 | 0 | getBusinessObject().refreshReferenceObject(reference); |
515 | |
} |
516 | |
else { |
517 | 0 | if (getDataDictionaryService().hasRelationship(getBusinessObject().getClass().getName(), |
518 | |
reference)) { |
519 | |
|
520 | |
|
521 | 0 | Object possibleRelationship = ObjectUtils.getPropertyValue(getBusinessObject(), |
522 | |
reference); |
523 | 0 | if (possibleRelationship != null) { |
524 | 0 | if (possibleRelationship instanceof PersistableBusinessObject) { |
525 | 0 | ((PersistableBusinessObject) possibleRelationship).refresh(); |
526 | |
} |
527 | 0 | else if (possibleRelationship instanceof Collection) { |
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
} |
536 | |
else { |
537 | 0 | LOG.warn("Expected that a referenceToRefresh (" |
538 | |
+ reference |
539 | |
+ ") would be a PersistableBusinessObject or Collection, but instead, it was of class " |
540 | |
+ possibleRelationship.getClass().getName()); |
541 | |
} |
542 | |
} |
543 | |
} |
544 | |
} |
545 | |
} |
546 | |
} |
547 | |
} |
548 | |
} |
549 | 0 | } |
550 | |
|
551 | |
public void addMultipleValueLookupResults(MaintenanceDocument document, String collectionName, |
552 | |
Collection<PersistableBusinessObject> rawValues, boolean needsBlank, PersistableBusinessObject bo) { |
553 | 0 | Collection maintCollection = (Collection) ObjectUtils.getPropertyValue(bo, collectionName); |
554 | 0 | String docTypeName = document.getDocumentHeader().getWorkflowDocument().getDocumentType(); |
555 | |
|
556 | 0 | List<String> duplicateIdentifierFieldsFromDataDictionary = getDuplicateIdentifierFieldsFromDataDictionary( |
557 | |
docTypeName, collectionName); |
558 | |
|
559 | 0 | List<String> existingIdentifierList = getMultiValueIdentifierList(maintCollection, |
560 | |
duplicateIdentifierFieldsFromDataDictionary); |
561 | |
|
562 | 0 | Class collectionClass = getMaintenanceDocumentDictionaryService().getCollectionBusinessObjectClass(docTypeName, |
563 | |
collectionName); |
564 | |
|
565 | 0 | List<MaintainableSectionDefinition> sections = getMaintenanceDocumentDictionaryService() |
566 | |
.getMaintainableSections(docTypeName); |
567 | 0 | Map<String, String> template = MaintenanceUtils.generateMultipleValueLookupBOTemplate(sections, collectionName); |
568 | |
try { |
569 | 0 | for (PersistableBusinessObject nextBo : rawValues) { |
570 | |
PersistableBusinessObject templatedBo; |
571 | 0 | if (needsBlank) { |
572 | 0 | templatedBo = (PersistableBusinessObject) collectionClass.newInstance(); |
573 | |
} |
574 | |
else { |
575 | |
|
576 | |
|
577 | |
|
578 | |
try { |
579 | 0 | ModuleService moduleService = KNSServiceLocatorWeb.getKualiModuleService() |
580 | |
.getResponsibleModuleService(collectionClass); |
581 | 0 | if (moduleService != null && moduleService.isExternalizable(collectionClass)) |
582 | 0 | templatedBo = (PersistableBusinessObject) moduleService |
583 | |
.createNewObjectFromExternalizableClass(collectionClass); |
584 | |
else |
585 | 0 | templatedBo = (PersistableBusinessObject) collectionClass.newInstance(); |
586 | |
} |
587 | 0 | catch (Exception e) { |
588 | 0 | throw new RuntimeException("Cannot instantiate " + collectionClass.getName(), e); |
589 | 0 | } |
590 | |
|
591 | 0 | setNewCollectionLineDefaultValues(collectionName, templatedBo); |
592 | |
|
593 | 0 | ObjectUtils.createHybridBusinessObject(templatedBo, nextBo, template); |
594 | |
|
595 | 0 | prepareBusinessObjectForAdditionFromMultipleValueLookup(collectionName, templatedBo); |
596 | |
} |
597 | 0 | templatedBo.setNewCollectionRecord(true); |
598 | |
|
599 | 0 | if (!hasBusinessObjectExisted(templatedBo, existingIdentifierList, |
600 | |
duplicateIdentifierFieldsFromDataDictionary)) { |
601 | 0 | maintCollection.add(templatedBo); |
602 | |
|
603 | |
} |
604 | 0 | } |
605 | |
} |
606 | 0 | catch (Exception e) { |
607 | 0 | LOG.error("Unable to add multiple value lookup results " + e.getMessage()); |
608 | 0 | throw new RuntimeException("Unable to add multiple value lookup results " + e.getMessage()); |
609 | 0 | } |
610 | 0 | } |
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
public List<String> getDuplicateIdentifierFieldsFromDataDictionary(String docTypeName, String collectionName) { |
623 | 0 | List<String> duplicateIdentifierFieldNames = new ArrayList<String>(); |
624 | 0 | MaintainableCollectionDefinition collDef = getMaintenanceDocumentDictionaryService().getMaintainableCollection( |
625 | |
docTypeName, collectionName); |
626 | 0 | Collection<MaintainableFieldDefinition> fieldDef = collDef.getDuplicateIdentificationFields(); |
627 | 0 | for (MaintainableFieldDefinition eachFieldDef : fieldDef) { |
628 | 0 | duplicateIdentifierFieldNames.add(eachFieldDef.getName()); |
629 | |
} |
630 | 0 | return duplicateIdentifierFieldNames; |
631 | |
} |
632 | |
|
633 | |
public List<String> getMultiValueIdentifierList(Collection maintCollection, List<String> duplicateIdentifierFields) { |
634 | 0 | List<String> identifierList = new ArrayList<String>(); |
635 | 0 | for (PersistableBusinessObject bo : (Collection<PersistableBusinessObject>) maintCollection) { |
636 | 0 | String uniqueIdentifier = new String(); |
637 | 0 | for (String identifierField : duplicateIdentifierFields) { |
638 | 0 | uniqueIdentifier = uniqueIdentifier + identifierField + "-" |
639 | |
+ ObjectUtils.getPropertyValue(bo, identifierField); |
640 | |
} |
641 | 0 | if (StringUtils.isNotEmpty(uniqueIdentifier)) { |
642 | 0 | identifierList.add(uniqueIdentifier); |
643 | |
} |
644 | 0 | } |
645 | 0 | return identifierList; |
646 | |
} |
647 | |
|
648 | |
public boolean hasBusinessObjectExisted(BusinessObject bo, List<String> existingIdentifierList, |
649 | |
List<String> duplicateIdentifierFields) { |
650 | 0 | String uniqueIdentifier = new String(); |
651 | 0 | for (String identifierField : duplicateIdentifierFields) { |
652 | 0 | uniqueIdentifier = uniqueIdentifier + identifierField + "-" |
653 | |
+ ObjectUtils.getPropertyValue(bo, identifierField); |
654 | |
} |
655 | 0 | if (existingIdentifierList.contains(uniqueIdentifier)) { |
656 | 0 | return true; |
657 | |
} |
658 | |
else { |
659 | 0 | return false; |
660 | |
} |
661 | |
} |
662 | |
|
663 | |
public void prepareBusinessObjectForAdditionFromMultipleValueLookup(String collectionName, BusinessObject bo) { |
664 | |
|
665 | 0 | } |
666 | |
|
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
public void prepareForSave() { |
672 | |
|
673 | 0 | } |
674 | |
|
675 | |
|
676 | |
|
677 | |
|
678 | |
|
679 | |
public void processAfterRetrieve() { |
680 | 0 | } |
681 | |
|
682 | |
|
683 | |
|
684 | |
|
685 | |
|
686 | |
|
687 | |
|
688 | |
public void processAfterCopy(MaintenanceDocument document, Map<String, String[]> parameters) { |
689 | |
try { |
690 | 0 | ObjectUtils.setObjectPropertyDeep(businessObject, KNSPropertyConstants.NEW_COLLECTION_RECORD, |
691 | |
boolean.class, true, 2); |
692 | |
} |
693 | 0 | catch (Exception e) { |
694 | 0 | LOG.error("unable to set newCollectionRecord property: " + e.getMessage(), e); |
695 | 0 | throw new RuntimeException("unable to set newCollectionRecord property: " + e.getMessage(), e); |
696 | 0 | } |
697 | 0 | } |
698 | |
|
699 | |
|
700 | |
|
701 | |
|
702 | |
public void processAfterEdit(MaintenanceDocument document, Map<String, String[]> parameters) { |
703 | 0 | } |
704 | |
|
705 | |
|
706 | |
|
707 | |
|
708 | |
public void processAfterNew(MaintenanceDocument document, Map<String, String[]> parameters) { |
709 | 0 | } |
710 | |
|
711 | |
|
712 | |
|
713 | |
|
714 | |
|
715 | |
protected String getDocumentTypeName() { |
716 | 0 | return getMaintenanceDocumentDictionaryService().getDocumentTypeName(boClass); |
717 | |
} |
718 | |
|
719 | |
@Override |
720 | |
public Object getDataObject() { |
721 | 0 | return dataObject; |
722 | |
} |
723 | |
|
724 | |
@Override |
725 | |
public void setDataObject(Object object) { |
726 | 0 | this.dataObject = object; |
727 | |
|
728 | 0 | if(object instanceof PersistableBusinessObject) { |
729 | 0 | this.businessObject = (PersistableBusinessObject)object; |
730 | |
} |
731 | 0 | } |
732 | |
|
733 | |
|
734 | |
|
735 | |
|
736 | |
public PersistableBusinessObject getBusinessObject() { |
737 | 0 | return businessObject; |
738 | |
} |
739 | |
|
740 | |
|
741 | |
|
742 | |
|
743 | |
|
744 | |
|
745 | |
public void setBusinessObject(PersistableBusinessObject businessObject) { |
746 | 0 | this.businessObject = businessObject; |
747 | 0 | this.dataObject = businessObject; |
748 | 0 | } |
749 | |
|
750 | |
|
751 | |
|
752 | |
|
753 | |
public Class getBoClass() { |
754 | 0 | return boClass; |
755 | |
} |
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
public void setBoClass(Class boClass) { |
762 | 0 | this.boClass = boClass; |
763 | 0 | this.docTypeName = getDocumentTypeName(); |
764 | 0 | } |
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
public String getMaintenanceAction() { |
770 | 0 | return maintenanceAction; |
771 | |
} |
772 | |
|
773 | |
|
774 | |
|
775 | |
|
776 | |
|
777 | |
public void setMaintenanceAction(String maintenanceAction) { |
778 | 0 | this.maintenanceAction = maintenanceAction; |
779 | 0 | } |
780 | |
|
781 | |
|
782 | |
|
783 | |
|
784 | |
|
785 | |
public void setGenerateDefaultValues(String docTypeName) { |
786 | 0 | List<MaintainableSectionDefinition> sectionDefinitions = getMaintenanceDocumentDictionaryService() |
787 | |
.getMaintainableSections(docTypeName); |
788 | 0 | Map defaultValues = new HashMap(); |
789 | |
|
790 | |
try { |
791 | |
|
792 | 0 | for (Iterator iter = sectionDefinitions.iterator(); iter.hasNext();) { |
793 | |
|
794 | 0 | MaintainableSectionDefinition maintSectionDef = (MaintainableSectionDefinition) iter.next(); |
795 | 0 | Collection maintItems = maintSectionDef.getMaintainableItems(); |
796 | 0 | for (Iterator iterator = maintItems.iterator(); iterator.hasNext();) { |
797 | 0 | MaintainableItemDefinition item = (MaintainableItemDefinition) iterator.next(); |
798 | |
|
799 | 0 | if (item instanceof MaintainableFieldDefinition) { |
800 | 0 | MaintainableFieldDefinition maintainableFieldDefinition = (MaintainableFieldDefinition) item; |
801 | |
|
802 | 0 | String defaultValue = maintainableFieldDefinition.getDefaultValue(); |
803 | 0 | if (defaultValue != null) { |
804 | 0 | if (defaultValue.equals("true")) { |
805 | 0 | defaultValue = "Yes"; |
806 | |
} |
807 | 0 | else if (defaultValue.equals("false")) { |
808 | 0 | defaultValue = "No"; |
809 | |
} |
810 | |
} |
811 | |
|
812 | 0 | Class defaultValueFinderClass = maintainableFieldDefinition.getDefaultValueFinderClass(); |
813 | 0 | if (defaultValueFinderClass != null) { |
814 | 0 | defaultValue = ((ValueFinder) defaultValueFinderClass.newInstance()).getValue(); |
815 | |
|
816 | |
} |
817 | 0 | if (defaultValue != null) { |
818 | 0 | defaultValues.put(item.getName(), defaultValue); |
819 | |
} |
820 | |
} |
821 | 0 | } |
822 | 0 | } |
823 | 0 | Map cachedValues = FieldUtils.populateBusinessObjectFromMap(getBusinessObject(), defaultValues); |
824 | |
} |
825 | 0 | catch (Exception e) { |
826 | 0 | LOG.error("Unable to set default value " + e.getMessage(), e); |
827 | 0 | throw new RuntimeException("Unable to set default value" + e.getMessage(), e); |
828 | 0 | } |
829 | |
|
830 | 0 | } |
831 | |
|
832 | |
|
833 | |
|
834 | |
|
835 | |
|
836 | |
public void setGenerateBlankRequiredValues(String docTypeName) { |
837 | |
try { |
838 | 0 | List<MaintainableSectionDefinition> sectionDefinitions = getMaintenanceDocumentDictionaryService() |
839 | |
.getMaintainableSections(docTypeName); |
840 | 0 | Map<String, String> defaultValues = new HashMap<String, String>(); |
841 | |
|
842 | 0 | for (MaintainableSectionDefinition maintSectionDef : sectionDefinitions) { |
843 | 0 | for (MaintainableItemDefinition item : maintSectionDef.getMaintainableItems()) { |
844 | 0 | if (item instanceof MaintainableFieldDefinition) { |
845 | 0 | MaintainableFieldDefinition maintainableFieldDefinition = (MaintainableFieldDefinition) item; |
846 | 0 | if (maintainableFieldDefinition.isRequired() |
847 | |
&& maintainableFieldDefinition.isUnconditionallyReadOnly()) { |
848 | 0 | Object currPropVal = ObjectUtils.getPropertyValue(this.getBusinessObject(), item.getName()); |
849 | 0 | if (currPropVal == null |
850 | |
|| (currPropVal instanceof String && StringUtils.isBlank((String) currPropVal))) { |
851 | 0 | Class<? extends ValueFinder> defaultValueFinderClass = maintainableFieldDefinition |
852 | |
.getDefaultValueFinderClass(); |
853 | 0 | if (defaultValueFinderClass != null) { |
854 | 0 | String defaultValue = defaultValueFinderClass.newInstance().getValue(); |
855 | 0 | if (defaultValue != null) { |
856 | 0 | defaultValues.put(item.getName(), defaultValue); |
857 | |
} |
858 | |
} |
859 | |
} |
860 | |
} |
861 | 0 | } |
862 | |
} |
863 | |
} |
864 | 0 | FieldUtils.populateBusinessObjectFromMap(getBusinessObject(), defaultValues); |
865 | |
} |
866 | 0 | catch (Exception e) { |
867 | 0 | LOG.error("Unable to set blank required value " + e.getMessage(), e); |
868 | 0 | throw new RuntimeException("Unable to set blank required value" + e.getMessage(), e); |
869 | 0 | } |
870 | 0 | } |
871 | |
|
872 | |
|
873 | |
|
874 | |
|
875 | |
|
876 | |
|
877 | |
|
878 | |
public final void setDocumentNumber(String documentNumber) { |
879 | 0 | this.documentNumber = documentNumber; |
880 | 0 | } |
881 | |
|
882 | |
@Deprecated |
883 | |
public void processAfterAddLine(String colName, Class colClass) { |
884 | 0 | } |
885 | |
|
886 | |
|
887 | |
|
888 | |
|
889 | |
|
890 | |
public void processBeforeAddLine(String colName, Class colClass, BusinessObject addBO) { |
891 | 0 | } |
892 | |
|
893 | |
|
894 | |
|
895 | |
|
896 | |
public boolean getShowInactiveRecords(String collectionName) { |
897 | 0 | return InactiveRecordsHidingUtils.getShowInactiveRecords(inactiveRecordDisplay, collectionName); |
898 | |
} |
899 | |
|
900 | |
|
901 | |
|
902 | |
|
903 | |
|
904 | |
public void setShowInactiveRecords(String collectionName, boolean showInactive) { |
905 | 0 | InactiveRecordsHidingUtils.setShowInactiveRecords(inactiveRecordDisplay, collectionName, showInactive); |
906 | 0 | } |
907 | |
|
908 | |
|
909 | |
|
910 | |
|
911 | |
public Map<String, Boolean> getInactiveRecordDisplay() { |
912 | 0 | return inactiveRecordDisplay; |
913 | |
} |
914 | |
|
915 | |
public void addNewLineToCollection(String collectionName) { |
916 | |
|
917 | 0 | if (LOG.isDebugEnabled()) { |
918 | 0 | LOG.debug("addNewLineToCollection( " + collectionName + " )"); |
919 | |
} |
920 | |
|
921 | 0 | PersistableBusinessObject addLine = newCollectionLines.get(collectionName); |
922 | 0 | if (addLine != null) { |
923 | |
|
924 | |
|
925 | 0 | addLine.setNewCollectionRecord(true); |
926 | |
|
927 | |
|
928 | |
|
929 | |
|
930 | |
|
931 | 0 | Collection maintCollection = (Collection) ObjectUtils.getPropertyValue(getBusinessObject(), collectionName); |
932 | |
|
933 | 0 | maintCollection.add(addLine); |
934 | |
|
935 | |
|
936 | |
|
937 | 0 | String referencesToRefresh = LookupUtils |
938 | |
.convertReferencesToSelectCollectionToString(getAllRefreshableReferences(getBusinessObject() |
939 | |
.getClass())); |
940 | 0 | if (LOG.isInfoEnabled()) { |
941 | 0 | LOG.info("References to refresh for adding line to collection " + collectionName + ": " |
942 | |
+ referencesToRefresh); |
943 | |
} |
944 | 0 | refreshReferences(referencesToRefresh); |
945 | |
} |
946 | |
|
947 | 0 | initNewCollectionLine(collectionName); |
948 | |
|
949 | 0 | } |
950 | |
|
951 | |
public PersistableBusinessObject getNewCollectionLine(String collectionName) { |
952 | 0 | if (LOG.isDebugEnabled()) { |
953 | |
|
954 | |
|
955 | 0 | LOG.debug("newCollectionLines: " + newCollectionLines); |
956 | |
} |
957 | 0 | PersistableBusinessObject addLine = newCollectionLines.get(collectionName); |
958 | 0 | if (addLine == null) { |
959 | 0 | addLine = initNewCollectionLine(collectionName); |
960 | |
} |
961 | 0 | return addLine; |
962 | |
} |
963 | |
|
964 | |
public PersistableBusinessObject initNewCollectionLine(String collectionName) { |
965 | 0 | if (LOG.isDebugEnabled()) { |
966 | 0 | LOG.debug("initNewCollectionLine( " + collectionName + " )"); |
967 | |
} |
968 | |
|
969 | |
|
970 | |
|
971 | |
|
972 | |
PersistableBusinessObject addLine; |
973 | |
try { |
974 | 0 | addLine = (PersistableBusinessObject) getMaintenanceDocumentDictionaryService() |
975 | |
.getCollectionBusinessObjectClass(docTypeName, collectionName).newInstance(); |
976 | |
} |
977 | 0 | catch (Exception ex) { |
978 | 0 | LOG.error("unable to instantiate new collection line", ex); |
979 | 0 | throw new RuntimeException("unable to instantiate new collection line", ex); |
980 | 0 | } |
981 | |
|
982 | 0 | newCollectionLines.put(collectionName, addLine); |
983 | |
|
984 | |
|
985 | 0 | setNewCollectionLineDefaultValues(collectionName, addLine); |
986 | 0 | return addLine; |
987 | |
} |
988 | |
|
989 | |
|
990 | |
|
991 | |
|
992 | |
|
993 | |
public Map<String, String> populateNewCollectionLines(Map<String, String> fieldValues, |
994 | |
MaintenanceDocument maintenanceDocument, String methodToCall) { |
995 | 0 | if (LOG.isDebugEnabled()) { |
996 | 0 | LOG.debug("populateNewCollectionLines: " + fieldValues); |
997 | |
} |
998 | 0 | fieldValues = decryptEncryptedData(fieldValues, maintenanceDocument, methodToCall); |
999 | |
|
1000 | 0 | Map<String, String> cachedValues = new HashMap<String, String>(); |
1001 | |
|
1002 | |
|
1003 | 0 | List<MaintainableCollectionDefinition> collections = getMaintenanceDocumentDictionaryService() |
1004 | |
.getMaintainableCollections(docTypeName); |
1005 | |
|
1006 | 0 | for (MaintainableCollectionDefinition coll : collections) { |
1007 | |
|
1008 | 0 | String collName = coll.getName(); |
1009 | 0 | if (LOG.isDebugEnabled()) { |
1010 | 0 | LOG.debug("checking for collection: " + collName); |
1011 | |
} |
1012 | |
|
1013 | 0 | Map<String, String> collectionValues = new HashMap<String, String>(); |
1014 | 0 | Map<String, String> subCollectionValues = new HashMap<String, String>(); |
1015 | |
|
1016 | |
|
1017 | 0 | for (Map.Entry<String, String> entry : fieldValues.entrySet()) { |
1018 | 0 | String key = entry.getKey(); |
1019 | 0 | if (key.startsWith(collName)) { |
1020 | 0 | String subStrKey = key.substring(collName.length() + 1); |
1021 | |
|
1022 | |
|
1023 | |
|
1024 | 0 | if (key.contains("[")) { |
1025 | |
|
1026 | |
|
1027 | |
|
1028 | |
|
1029 | 0 | subCollectionValues.put(key, entry.getValue()); |
1030 | |
} |
1031 | |
else { |
1032 | 0 | collectionValues.put(subStrKey, entry.getValue()); |
1033 | |
} |
1034 | |
} |
1035 | 0 | } |
1036 | |
|
1037 | 0 | if (LOG.isDebugEnabled()) { |
1038 | 0 | LOG.debug("values for collection: " + collectionValues); |
1039 | |
} |
1040 | 0 | cachedValues.putAll(FieldUtils.populateBusinessObjectFromMap(getNewCollectionLine(collName), |
1041 | |
collectionValues, KNSConstants.MAINTENANCE_ADD_PREFIX + collName + ".")); |
1042 | 0 | performFieldForceUpperCase(getNewCollectionLine(collName), collectionValues); |
1043 | |
|
1044 | 0 | cachedValues.putAll(populateNewSubCollectionLines(coll, subCollectionValues)); |
1045 | 0 | } |
1046 | |
|
1047 | |
|
1048 | 0 | return cachedValues; |
1049 | |
} |
1050 | |
|
1051 | |
|
1052 | |
|
1053 | |
|
1054 | |
|
1055 | |
|
1056 | |
protected Map populateNewSubCollectionLines(MaintainableCollectionDefinition parentCollection, Map fieldValues) { |
1057 | 0 | if (LOG.isDebugEnabled()) { |
1058 | 0 | LOG.debug("populateNewSubCollectionLines: " + fieldValues); |
1059 | |
} |
1060 | 0 | Map cachedValues = new HashMap(); |
1061 | |
|
1062 | 0 | for (MaintainableCollectionDefinition coll : parentCollection.getMaintainableCollections()) { |
1063 | |
|
1064 | 0 | String collName = coll.getName(); |
1065 | |
|
1066 | 0 | if (LOG.isDebugEnabled()) { |
1067 | 0 | LOG.debug("checking for sub collection: " + collName); |
1068 | |
} |
1069 | 0 | Map<String, String> parents = new HashMap<String, String>(); |
1070 | |
|
1071 | 0 | for (Object entry : fieldValues.entrySet()) { |
1072 | 0 | String key = (String) ((Map.Entry) entry).getKey(); |
1073 | 0 | if (key.contains(collName)) { |
1074 | 0 | parents.put(StringUtils.substringBefore(key, "."), ""); |
1075 | |
} |
1076 | 0 | } |
1077 | |
|
1078 | 0 | for (String parent : parents.keySet()) { |
1079 | |
|
1080 | 0 | Map<String, Object> collectionValues = new HashMap<String, Object>(); |
1081 | |
|
1082 | |
|
1083 | 0 | for (Object entry : fieldValues.entrySet()) { |
1084 | 0 | String key = (String) ((Map.Entry) entry).getKey(); |
1085 | 0 | if (key.contains(parent)) { |
1086 | 0 | String substr = StringUtils.substringAfterLast(key, "."); |
1087 | 0 | collectionValues.put(substr, ((Map.Entry) entry).getValue()); |
1088 | |
} |
1089 | 0 | } |
1090 | |
|
1091 | 0 | if (LOG.isDebugEnabled()) { |
1092 | 0 | LOG.debug("values for sub collection: " + collectionValues); |
1093 | |
} |
1094 | 0 | GlobalVariables.getMessageMap().addToErrorPath( |
1095 | |
KNSConstants.MAINTENANCE_ADD_PREFIX + parent + "." + collName); |
1096 | 0 | cachedValues.putAll(FieldUtils.populateBusinessObjectFromMap(getNewCollectionLine(parent + "." |
1097 | |
+ collName), collectionValues, KNSConstants.MAINTENANCE_ADD_PREFIX + parent + "." + collName |
1098 | |
+ ".")); |
1099 | 0 | performFieldForceUpperCase(getNewCollectionLine(parent + "." + collName), collectionValues); |
1100 | 0 | GlobalVariables.getMessageMap().removeFromErrorPath( |
1101 | |
KNSConstants.MAINTENANCE_ADD_PREFIX + parent + "." + collName); |
1102 | 0 | } |
1103 | |
|
1104 | 0 | cachedValues.putAll(populateNewSubCollectionLines(coll, fieldValues)); |
1105 | 0 | } |
1106 | |
|
1107 | 0 | return cachedValues; |
1108 | |
} |
1109 | |
|
1110 | |
public Collection<String> getAffectedReferencesFromLookup(BusinessObject baseBO, String attributeName, |
1111 | |
String collectionPrefix) { |
1112 | 0 | PersistenceStructureService pss = getPersistenceStructureService(); |
1113 | 0 | String nestedBOPrefix = ""; |
1114 | 0 | if (ObjectUtils.isNestedAttribute(attributeName)) { |
1115 | |
|
1116 | |
|
1117 | 0 | nestedBOPrefix = ObjectUtils.getNestedAttributePrefix(attributeName); |
1118 | |
|
1119 | |
|
1120 | |
|
1121 | 0 | Class reference = ObjectUtils.getPropertyType(baseBO, nestedBOPrefix, pss); |
1122 | 0 | if (!(PersistableBusinessObject.class.isAssignableFrom(reference))) { |
1123 | 0 | return new ArrayList<String>(); |
1124 | |
} |
1125 | |
|
1126 | |
try { |
1127 | 0 | baseBO = (PersistableBusinessObject) reference.newInstance(); |
1128 | |
} |
1129 | 0 | catch (InstantiationException e) { |
1130 | 0 | LOG.error(e); |
1131 | |
} |
1132 | 0 | catch (IllegalAccessException e) { |
1133 | 0 | LOG.error(e); |
1134 | 0 | } |
1135 | 0 | attributeName = ObjectUtils.getNestedAttributePrimitive(attributeName); |
1136 | |
} |
1137 | |
|
1138 | 0 | if (baseBO == null) { |
1139 | 0 | return new ArrayList<String>(); |
1140 | |
} |
1141 | |
|
1142 | 0 | Map<String, Class> referenceNameToClassFromPSS = LookupUtils.getPrimitiveReference(baseBO, attributeName); |
1143 | 0 | if (referenceNameToClassFromPSS.size() > 1) { |
1144 | 0 | LOG.error("LookupUtils.getPrimitiveReference return results should only have at most one element"); |
1145 | |
} |
1146 | |
|
1147 | 0 | BusinessObjectMetaDataService businessObjectMetaDataService = getBusinessObjectMetaDataService(); |
1148 | 0 | BusinessObjectRelationship relationship = businessObjectMetaDataService.getBusinessObjectRelationship(baseBO, |
1149 | |
attributeName); |
1150 | 0 | if (relationship == null) { |
1151 | 0 | return new ArrayList<String>(); |
1152 | |
} |
1153 | |
|
1154 | 0 | Map<String, String> fkToPkMappings = relationship.getParentToChildReferences(); |
1155 | |
|
1156 | 0 | Collection<String> affectedReferences = generateAllAffectedReferences(baseBO.getClass(), fkToPkMappings, |
1157 | |
nestedBOPrefix, collectionPrefix); |
1158 | 0 | if (LOG.isDebugEnabled()) { |
1159 | 0 | LOG.debug("References affected by a lookup on BO attribute \"" + collectionPrefix + nestedBOPrefix + "." |
1160 | |
+ attributeName + ": " + affectedReferences); |
1161 | |
} |
1162 | |
|
1163 | 0 | return affectedReferences; |
1164 | |
} |
1165 | |
|
1166 | |
protected boolean isRelationshipRefreshable(Class boClass, String relationshipName) { |
1167 | 0 | if (getPersistenceStructureService().isPersistable(boClass)) { |
1168 | 0 | if (getPersistenceStructureService().hasCollection(boClass, relationshipName)) { |
1169 | 0 | return !getPersistenceStructureService().isCollectionUpdatable(boClass, relationshipName); |
1170 | |
} |
1171 | 0 | else if (getPersistenceStructureService().hasReference(boClass, relationshipName)) { |
1172 | 0 | return !getPersistenceStructureService().isReferenceUpdatable(boClass, relationshipName); |
1173 | |
} |
1174 | |
|
1175 | |
} |
1176 | |
|
1177 | 0 | return true; |
1178 | |
} |
1179 | |
|
1180 | |
protected Collection<String> generateAllAffectedReferences(Class boClass, Map<String, String> fkToPkMappings, |
1181 | |
String nestedBOPrefix, String collectionPrefix) { |
1182 | 0 | Set<String> allAffectedReferences = new HashSet<String>(); |
1183 | 0 | DataDictionaryService dataDictionaryService = getDataDictionaryService(); |
1184 | 0 | PersistenceStructureService pss = getPersistenceStructureService(); |
1185 | |
|
1186 | 0 | collectionPrefix = StringUtils.isBlank(collectionPrefix) ? "" : collectionPrefix; |
1187 | |
|
1188 | |
|
1189 | |
|
1190 | 0 | Collection<String> attributeReferenceFKAttributes = fkToPkMappings.keySet(); |
1191 | |
|
1192 | |
|
1193 | |
|
1194 | |
|
1195 | |
|
1196 | |
|
1197 | |
|
1198 | |
|
1199 | 0 | for (String fkAttribute : attributeReferenceFKAttributes) { |
1200 | 0 | for (String affectedReference : pss.getReferencesForForeignKey(boClass, fkAttribute).keySet()) { |
1201 | 0 | if (isRelationshipRefreshable(boClass, affectedReference)) { |
1202 | 0 | if (StringUtils.isBlank(nestedBOPrefix)) { |
1203 | 0 | allAffectedReferences.add(collectionPrefix + affectedReference); |
1204 | |
} |
1205 | |
else { |
1206 | 0 | allAffectedReferences.add(collectionPrefix + nestedBOPrefix + "." + affectedReference); |
1207 | |
} |
1208 | |
} |
1209 | |
} |
1210 | |
} |
1211 | |
|
1212 | |
|
1213 | 0 | for (String collectionName : pss.listCollectionObjectTypes(boClass).keySet()) { |
1214 | 0 | if (isRelationshipRefreshable(boClass, collectionName)) { |
1215 | 0 | Map<String, String> keyMappingsForCollection = pss.getInverseForeignKeysForCollection(boClass, |
1216 | |
collectionName); |
1217 | 0 | for (String collectionForeignKey : keyMappingsForCollection.keySet()) { |
1218 | 0 | if (attributeReferenceFKAttributes.contains(collectionForeignKey)) { |
1219 | 0 | if (StringUtils.isBlank(nestedBOPrefix)) { |
1220 | 0 | allAffectedReferences.add(collectionPrefix + collectionName); |
1221 | |
} |
1222 | |
else { |
1223 | 0 | allAffectedReferences.add(collectionPrefix + nestedBOPrefix + "." + collectionName); |
1224 | |
} |
1225 | |
} |
1226 | |
} |
1227 | 0 | } |
1228 | |
} |
1229 | |
|
1230 | |
|
1231 | 0 | List<String> ddDefinedRelationships = dataDictionaryService.getRelationshipNames(boClass.getName()); |
1232 | 0 | for (String ddRelationship : ddDefinedRelationships) { |
1233 | |
|
1234 | 0 | Map<String, String> referencePKtoFKmappings = dataDictionaryService.getRelationshipAttributeMap( |
1235 | |
boClass.getName(), ddRelationship); |
1236 | 0 | for (String sourceAttribute : referencePKtoFKmappings.values()) { |
1237 | |
|
1238 | |
|
1239 | 0 | if (attributeReferenceFKAttributes.contains(sourceAttribute)) { |
1240 | 0 | for (String affectedReference : dataDictionaryService.getRelationshipEntriesForSourceAttribute( |
1241 | |
boClass.getName(), sourceAttribute)) { |
1242 | 0 | if (isRelationshipRefreshable(boClass, ddRelationship)) { |
1243 | 0 | if (StringUtils.isBlank(nestedBOPrefix)) { |
1244 | 0 | allAffectedReferences.add(affectedReference); |
1245 | |
} |
1246 | |
else { |
1247 | 0 | allAffectedReferences.add(nestedBOPrefix + "." + affectedReference); |
1248 | |
} |
1249 | |
} |
1250 | |
} |
1251 | |
} |
1252 | |
} |
1253 | 0 | } |
1254 | 0 | return allAffectedReferences; |
1255 | |
} |
1256 | |
|
1257 | |
protected Collection<String> getAllRefreshableReferences(Class boClass) { |
1258 | 0 | HashSet<String> references = new HashSet<String>(); |
1259 | 0 | for (String referenceName : getPersistenceStructureService().listReferenceObjectFields(boClass).keySet()) { |
1260 | 0 | if (isRelationshipRefreshable(boClass, referenceName)) { |
1261 | 0 | references.add(referenceName); |
1262 | |
} |
1263 | |
} |
1264 | 0 | for (String collectionName : getPersistenceStructureService().listCollectionObjectTypes(boClass).keySet()) { |
1265 | 0 | if (isRelationshipRefreshable(boClass, collectionName)) { |
1266 | 0 | references.add(collectionName); |
1267 | |
} |
1268 | |
} |
1269 | 0 | for (String relationshipName : getDataDictionaryService().getRelationshipNames(boClass.getName())) { |
1270 | 0 | if (isRelationshipRefreshable(boClass, relationshipName)) { |
1271 | 0 | references.add(relationshipName); |
1272 | |
} |
1273 | |
} |
1274 | 0 | return references; |
1275 | |
} |
1276 | |
|
1277 | |
protected void setNewCollectionLineDefaultValues(String collectionName, PersistableBusinessObject addLine) { |
1278 | 0 | PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(addLine); |
1279 | 0 | for (int i = 0; i < descriptors.length; ++i) { |
1280 | 0 | PropertyDescriptor propertyDescriptor = descriptors[i]; |
1281 | |
|
1282 | 0 | String fieldName = propertyDescriptor.getName(); |
1283 | 0 | Class propertyType = propertyDescriptor.getPropertyType(); |
1284 | 0 | String value = getMaintenanceDocumentDictionaryService().getCollectionFieldDefaultValue(docTypeName, |
1285 | |
collectionName, fieldName); |
1286 | |
|
1287 | 0 | if (value != null) { |
1288 | |
try { |
1289 | 0 | ObjectUtils.setObjectProperty(addLine, fieldName, propertyType, value); |
1290 | |
} |
1291 | 0 | catch (Exception ex) { |
1292 | 0 | LOG.error("Unable to set default property of collection object: " + "\nobject: " + addLine |
1293 | |
+ "\nfieldName=" + fieldName + "\npropertyType=" + propertyType + "\nvalue=" + value, ex); |
1294 | 0 | } |
1295 | |
} |
1296 | |
|
1297 | |
} |
1298 | 0 | } |
1299 | |
|
1300 | |
public void doRouteStatusChange(DocumentHeader documentHeader) { |
1301 | 0 | } |
1302 | |
|
1303 | |
public List<Long> getWorkflowEngineDocumentIdsToLock() { |
1304 | 0 | return null; |
1305 | |
} |
1306 | |
|
1307 | |
|
1308 | |
|
1309 | |
|
1310 | |
public void clearBusinessObjectOfRestrictedValues(MaintenanceDocumentRestrictions maintenanceDocumentRestrictions) { |
1311 | 0 | List<MaintainableSectionDefinition> sections = getMaintenanceDocumentDictionaryService() |
1312 | |
.getMaintainableSections(docTypeName); |
1313 | 0 | for (MaintainableSectionDefinition sectionDefinition : sections) { |
1314 | 0 | for (MaintainableItemDefinition itemDefinition : sectionDefinition.getMaintainableItems()) { |
1315 | 0 | if (itemDefinition instanceof MaintainableFieldDefinition) { |
1316 | 0 | clearFieldRestrictedValues("", businessObject, (MaintainableFieldDefinition) itemDefinition, |
1317 | |
maintenanceDocumentRestrictions); |
1318 | |
} |
1319 | 0 | else if (itemDefinition instanceof MaintainableCollectionDefinition) { |
1320 | 0 | clearCollectionRestrictedValues("", businessObject, |
1321 | |
(MaintainableCollectionDefinition) itemDefinition, maintenanceDocumentRestrictions); |
1322 | |
} |
1323 | |
} |
1324 | |
} |
1325 | 0 | } |
1326 | |
|
1327 | |
protected void clearCollectionRestrictedValues(String fieldNamePrefix, BusinessObject businessObject, |
1328 | |
MaintainableCollectionDefinition collectionDefinition, |
1329 | |
MaintenanceDocumentRestrictions maintenanceDocumentRestrictions) { |
1330 | 0 | String collectionName = fieldNamePrefix + collectionDefinition.getName(); |
1331 | 0 | Collection<BusinessObject> collection = (Collection<BusinessObject>) ObjectUtils.getPropertyValue( |
1332 | |
businessObject, collectionDefinition.getName()); |
1333 | |
|
1334 | 0 | if (collection != null) { |
1335 | 0 | int i = 0; |
1336 | |
|
1337 | |
|
1338 | 0 | for (BusinessObject collectionItem : collection) { |
1339 | 0 | String collectionItemNamePrefix = collectionName + "[" + i + "]."; |
1340 | 0 | for (MaintainableCollectionDefinition subCollectionDefinition : collectionDefinition |
1341 | |
.getMaintainableCollections()) { |
1342 | 0 | clearCollectionRestrictedValues(collectionItemNamePrefix, collectionItem, subCollectionDefinition, |
1343 | |
maintenanceDocumentRestrictions); |
1344 | |
} |
1345 | 0 | for (MaintainableFieldDefinition fieldDefinition : collectionDefinition.getMaintainableFields()) { |
1346 | 0 | clearFieldRestrictedValues(collectionItemNamePrefix, collectionItem, fieldDefinition, |
1347 | |
maintenanceDocumentRestrictions); |
1348 | |
} |
1349 | 0 | i++; |
1350 | 0 | } |
1351 | |
} |
1352 | 0 | } |
1353 | |
|
1354 | |
protected void clearFieldRestrictedValues(String fieldNamePrefix, BusinessObject businessObject, |
1355 | |
MaintainableFieldDefinition fieldDefinition, MaintenanceDocumentRestrictions maintenanceDocumentRestrictions) { |
1356 | 0 | String fieldName = fieldNamePrefix + fieldDefinition.getName(); |
1357 | |
|
1358 | 0 | FieldRestriction fieldRestriction = maintenanceDocumentRestrictions.getFieldRestriction(fieldName); |
1359 | 0 | if (fieldRestriction.isRestricted()) { |
1360 | 0 | String defaultValue = null; |
1361 | 0 | if (StringUtils.isNotBlank(fieldDefinition.getDefaultValue())) { |
1362 | 0 | defaultValue = fieldDefinition.getDefaultValue(); |
1363 | |
} |
1364 | 0 | else if (fieldDefinition.getDefaultValueFinderClass() != null) { |
1365 | |
try { |
1366 | 0 | defaultValue = ((ValueFinder) fieldDefinition.getDefaultValueFinderClass().newInstance()) |
1367 | |
.getValue(); |
1368 | |
} |
1369 | 0 | catch (Exception e) { |
1370 | 0 | defaultValue = null; |
1371 | 0 | LOG.error("Error trying to instantiate ValueFinder or to determine ValueFinder for doc type: " |
1372 | |
+ docTypeName + " field name " + fieldDefinition.getName() + " with field prefix: " |
1373 | |
+ fieldNamePrefix, e); |
1374 | 0 | } |
1375 | |
} |
1376 | |
try { |
1377 | 0 | ObjectUtils.setObjectProperty(businessObject, fieldDefinition.getName(), defaultValue); |
1378 | |
} |
1379 | 0 | catch (Exception e) { |
1380 | |
|
1381 | |
|
1382 | 0 | LOG.error("Unable to clear maintenance document values for field name: " + fieldName |
1383 | |
+ " default value: " + defaultValue, e); |
1384 | 0 | throw new RuntimeException("Unable to clear maintenance document values for field name: " + fieldName, |
1385 | |
e); |
1386 | 0 | } |
1387 | |
} |
1388 | 0 | } |
1389 | |
|
1390 | |
protected void performForceUpperCase(Map fieldValues) { |
1391 | 0 | List<MaintainableSectionDefinition> sections = getMaintenanceDocumentDictionaryService() |
1392 | |
.getMaintainableSections(docTypeName); |
1393 | 0 | for (MaintainableSectionDefinition sectionDefinition : sections) { |
1394 | 0 | for (MaintainableItemDefinition itemDefinition : sectionDefinition.getMaintainableItems()) { |
1395 | 0 | if (itemDefinition instanceof MaintainableFieldDefinition) { |
1396 | 0 | performFieldForceUpperCase("", businessObject, (MaintainableFieldDefinition) itemDefinition, |
1397 | |
fieldValues); |
1398 | |
} |
1399 | 0 | else if (itemDefinition instanceof MaintainableCollectionDefinition) { |
1400 | 0 | performCollectionForceUpperCase("", businessObject, |
1401 | |
(MaintainableCollectionDefinition) itemDefinition, fieldValues); |
1402 | |
|
1403 | |
} |
1404 | |
} |
1405 | |
} |
1406 | 0 | } |
1407 | |
|
1408 | |
protected void performFieldForceUpperCase(String fieldNamePrefix, BusinessObject bo, |
1409 | |
MaintainableFieldDefinition fieldDefinition, Map fieldValues) { |
1410 | 0 | MessageMap errorMap = GlobalVariables.getMessageMap(); |
1411 | 0 | String fieldName = fieldDefinition.getName(); |
1412 | 0 | String mapKey = fieldNamePrefix + fieldName; |
1413 | 0 | if (fieldValues != null && fieldValues.get(mapKey) != null) { |
1414 | 0 | if (PropertyUtils.isWriteable(bo, fieldName) && ObjectUtils.getNestedValue(bo, fieldName) != null) { |
1415 | |
|
1416 | |
try { |
1417 | 0 | Class type = ObjectUtils.easyGetPropertyType(bo, fieldName); |
1418 | |
|
1419 | 0 | Class businessObjectClass = bo.getClass(); |
1420 | 0 | boolean upperCase = false; |
1421 | |
try { |
1422 | 0 | upperCase = getDataDictionaryService().getAttributeForceUppercase(businessObjectClass, |
1423 | |
fieldName); |
1424 | |
} |
1425 | 0 | catch (UnknownBusinessClassAttributeException t) { |
1426 | 0 | boolean catchme = true; |
1427 | |
|
1428 | 0 | } |
1429 | |
|
1430 | 0 | Object fieldValue = ObjectUtils.getNestedValue(bo, fieldName); |
1431 | |
|
1432 | 0 | if (upperCase && fieldValue instanceof String) { |
1433 | 0 | fieldValue = ((String) fieldValue).toUpperCase(); |
1434 | |
} |
1435 | 0 | ObjectUtils.setObjectProperty(bo, fieldName, type, fieldValue); |
1436 | |
} |
1437 | 0 | catch (FormatException e) { |
1438 | 0 | errorMap.putError(fieldName, e.getErrorKey(), e.getErrorArgs()); |
1439 | |
} |
1440 | 0 | catch (IllegalAccessException e) { |
1441 | 0 | LOG.error("unable to populate business object" + e.getMessage()); |
1442 | 0 | throw new RuntimeException(e.getMessage(), e); |
1443 | |
} |
1444 | 0 | catch (InvocationTargetException e) { |
1445 | 0 | LOG.error("unable to populate business object" + e.getMessage()); |
1446 | 0 | throw new RuntimeException(e.getMessage(), e); |
1447 | |
} |
1448 | 0 | catch (NoSuchMethodException e) { |
1449 | 0 | LOG.error("unable to populate business object" + e.getMessage()); |
1450 | 0 | throw new RuntimeException(e.getMessage(), e); |
1451 | 0 | } |
1452 | |
} |
1453 | |
} |
1454 | 0 | } |
1455 | |
|
1456 | |
protected void performCollectionForceUpperCase(String fieldNamePrefix, BusinessObject bo, |
1457 | |
MaintainableCollectionDefinition collectionDefinition, Map fieldValues) { |
1458 | 0 | String collectionName = fieldNamePrefix + collectionDefinition.getName(); |
1459 | 0 | Collection<BusinessObject> collection = (Collection<BusinessObject>) ObjectUtils.getPropertyValue(bo, |
1460 | |
collectionDefinition.getName()); |
1461 | 0 | if (collection != null) { |
1462 | 0 | int i = 0; |
1463 | |
|
1464 | |
|
1465 | 0 | for (BusinessObject collectionItem : collection) { |
1466 | 0 | String collectionItemNamePrefix = collectionName + "[" + i + "]."; |
1467 | |
|
1468 | 0 | for (MaintainableFieldDefinition fieldDefinition : collectionDefinition.getMaintainableFields()) { |
1469 | 0 | performFieldForceUpperCase(collectionItemNamePrefix, collectionItem, fieldDefinition, fieldValues); |
1470 | |
} |
1471 | 0 | for (MaintainableCollectionDefinition subCollectionDefinition : collectionDefinition |
1472 | |
.getMaintainableCollections()) { |
1473 | 0 | performCollectionForceUpperCase(collectionItemNamePrefix, collectionItem, subCollectionDefinition, |
1474 | |
fieldValues); |
1475 | |
} |
1476 | 0 | i++; |
1477 | 0 | } |
1478 | |
} |
1479 | 0 | } |
1480 | |
|
1481 | |
protected void performFieldForceUpperCase(BusinessObject bo, Map fieldValues) { |
1482 | 0 | MessageMap errorMap = GlobalVariables.getMessageMap(); |
1483 | |
|
1484 | |
try { |
1485 | 0 | for (Iterator iter = fieldValues.keySet().iterator(); iter.hasNext();) { |
1486 | 0 | String propertyName = (String) iter.next(); |
1487 | |
|
1488 | 0 | if (PropertyUtils.isWriteable(bo, propertyName) && fieldValues.get(propertyName) != null) { |
1489 | |
|
1490 | |
|
1491 | 0 | Class type = ObjectUtils.easyGetPropertyType(bo, propertyName); |
1492 | |
try { |
1493 | |
|
1494 | |
|
1495 | |
|
1496 | |
|
1497 | 0 | Class businessObjectClass = bo.getClass(); |
1498 | 0 | boolean upperCase = false; |
1499 | |
try { |
1500 | 0 | upperCase = getDataDictionaryService().getAttributeForceUppercase(businessObjectClass, |
1501 | |
propertyName); |
1502 | |
} |
1503 | 0 | catch (UnknownBusinessClassAttributeException t) { |
1504 | 0 | boolean catchme = true; |
1505 | |
|
1506 | 0 | } |
1507 | |
|
1508 | 0 | Object fieldValue = fieldValues.get(propertyName); |
1509 | |
|
1510 | 0 | if (upperCase && fieldValue instanceof String) { |
1511 | 0 | fieldValue = ((String) fieldValue).toUpperCase(); |
1512 | |
} |
1513 | 0 | ObjectUtils.setObjectProperty(bo, propertyName, type, fieldValue); |
1514 | |
} |
1515 | 0 | catch (FormatException e) { |
1516 | 0 | errorMap.putError(propertyName, e.getErrorKey(), e.getErrorArgs()); |
1517 | 0 | } |
1518 | |
} |
1519 | 0 | } |
1520 | |
} |
1521 | 0 | catch (IllegalAccessException e) { |
1522 | 0 | LOG.error("unable to populate business object" + e.getMessage()); |
1523 | 0 | throw new RuntimeException(e.getMessage(), e); |
1524 | |
} |
1525 | 0 | catch (InvocationTargetException e) { |
1526 | 0 | LOG.error("unable to populate business object" + e.getMessage()); |
1527 | 0 | throw new RuntimeException(e.getMessage(), e); |
1528 | |
} |
1529 | 0 | catch (NoSuchMethodException e) { |
1530 | 0 | LOG.error("unable to populate business object" + e.getMessage()); |
1531 | 0 | throw new RuntimeException(e.getMessage(), e); |
1532 | 0 | } |
1533 | |
|
1534 | 0 | } |
1535 | |
|
1536 | |
|
1537 | |
|
1538 | |
|
1539 | |
|
1540 | |
|
1541 | |
public boolean isExternalBusinessObject() { |
1542 | 0 | return false; |
1543 | |
} |
1544 | |
|
1545 | |
|
1546 | |
|
1547 | |
|
1548 | |
public void prepareBusinessObject(BusinessObject businessObject) { |
1549 | |
|
1550 | 0 | } |
1551 | |
|
1552 | |
|
1553 | |
|
1554 | |
|
1555 | |
public String getLockingDocumentId() { |
1556 | 0 | return getMaintenanceDocumentService().getLockingDocumentId(this, documentNumber); |
1557 | |
} |
1558 | |
|
1559 | |
|
1560 | |
|
1561 | |
|
1562 | |
|
1563 | |
|
1564 | |
|
1565 | |
|
1566 | |
|
1567 | |
public boolean useCustomLockDescriptors() { |
1568 | 0 | return false; |
1569 | |
} |
1570 | |
|
1571 | |
|
1572 | |
|
1573 | |
|
1574 | |
|
1575 | |
|
1576 | |
|
1577 | |
|
1578 | |
public String getCustomLockDescriptor(Person user) { |
1579 | 0 | throw new PessimisticLockingException( |
1580 | |
"The Maintainable for document " |
1581 | |
+ documentNumber |
1582 | |
+ " is using pessimistic locking with custom lock descriptors, but the Maintainable has not overriden the getCustomLockDescriptor method"); |
1583 | |
} |
1584 | |
|
1585 | |
|
1586 | |
public void deleteBusinessObject() { |
1587 | 0 | if (businessObject == null) |
1588 | 0 | return; |
1589 | |
|
1590 | 0 | KNSServiceLocator.getBusinessObjectService().delete(businessObject); |
1591 | 0 | businessObject = null; |
1592 | 0 | } |
1593 | |
|
1594 | |
public boolean isOldBusinessObjectInDocument() { |
1595 | 0 | boolean isOldBusinessObjectInExistence = false; |
1596 | 0 | if (getBusinessObject() == null) { |
1597 | 0 | isOldBusinessObjectInExistence = false; |
1598 | |
} |
1599 | |
else { |
1600 | 0 | if (KNSServiceLocator.getPersistenceStructureService().isPersistable(getBusinessObject().getClass())) { |
1601 | 0 | isOldBusinessObjectInExistence = KNSServiceLocator.getPersistenceStructureService() |
1602 | |
.hasPrimaryKeyFieldValues(getBusinessObject()); |
1603 | |
} |
1604 | |
} |
1605 | 0 | return isOldBusinessObjectInExistence; |
1606 | |
|
1607 | |
} |
1608 | |
|
1609 | |
|
1610 | |
|
1611 | |
|
1612 | |
|
1613 | |
public void setupMaintenanceObject(MaintenanceDocument document, String maintenanceAction, |
1614 | |
Map<String, String[]> requestParameters) { |
1615 | 0 | setMaintenanceAction(maintenanceAction); |
1616 | 0 | document.getOldMaintainableObject().setMaintenanceAction(maintenanceAction); |
1617 | |
|
1618 | |
|
1619 | 0 | if (!KNSConstants.MAINTENANCE_NEW_ACTION.equals(maintenanceAction) |
1620 | |
&& !KNSConstants.MAINTENANCE_NEWWITHEXISTING_ACTION.equals(maintenanceAction)) { |
1621 | 0 | Object oldBusinessObject = retrieveObjectForMaintenance(document, requestParameters); |
1622 | |
|
1623 | |
|
1624 | |
|
1625 | 0 | Object newBusinessObject = ObjectUtils.deepCopy((Serializable) oldBusinessObject); |
1626 | |
|
1627 | |
|
1628 | 0 | if (KNSConstants.MAINTENANCE_COPY_ACTION.equals(maintenanceAction)) { |
1629 | 0 | processMaintenanceObjectForCopy(document, newBusinessObject, requestParameters); |
1630 | |
} |
1631 | |
else { |
1632 | 0 | checkMaintenanceActionAuthorization(document, oldBusinessObject, requestParameters); |
1633 | |
} |
1634 | |
|
1635 | |
|
1636 | 0 | document.getOldMaintainableObject().setDataObject(oldBusinessObject); |
1637 | 0 | document.getNewMaintainableObject().setDataObject(newBusinessObject); |
1638 | |
} |
1639 | |
|
1640 | |
|
1641 | 0 | if (KNSConstants.MAINTENANCE_NEWWITHEXISTING_ACTION.equals(maintenanceAction)) { |
1642 | 0 | Object newBO = document.getNewMaintainableObject().getDataObject(); |
1643 | 0 | Map<String, String> parameters = buildKeyMapFromRequest(requestParameters); |
1644 | 0 | ObjectPropertyUtils.copyPropertiesToObject(parameters, newBO); |
1645 | 0 | if(newBO instanceof PersistableBusinessObject) { |
1646 | 0 | ((PersistableBusinessObject)newBO).refresh(); |
1647 | |
} |
1648 | |
|
1649 | 0 | setupNewFromExisting(document, requestParameters); |
1650 | 0 | } |
1651 | 0 | else if (KNSConstants.MAINTENANCE_NEW_ACTION.equals(maintenanceAction)) { |
1652 | 0 | processAfterNew(document, requestParameters); |
1653 | |
} |
1654 | 0 | } |
1655 | |
|
1656 | |
|
1657 | |
|
1658 | |
|
1659 | |
|
1660 | |
|
1661 | |
|
1662 | |
|
1663 | |
|
1664 | |
|
1665 | |
|
1666 | |
|
1667 | |
|
1668 | |
|
1669 | |
protected void checkMaintenanceActionAuthorization(MaintenanceDocument document, Object oldBusinessObject, |
1670 | |
Map<String, String[]> requestParameters) { |
1671 | 0 | if (KNSConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceAction)) { |
1672 | 0 | boolean allowsEdit = getBusinessObjectAuthorizationService().canMaintain( |
1673 | |
oldBusinessObject, GlobalVariables.getUserSession().getPerson(), |
1674 | |
document.getDocumentHeader().getWorkflowDocument().getDocumentType()); |
1675 | 0 | if (!allowsEdit) { |
1676 | 0 | LOG.error("Document type " + document.getDocumentHeader().getWorkflowDocument().getDocumentType() |
1677 | |
+ " does not allow edit actions."); |
1678 | 0 | throw new DocumentTypeAuthorizationException(GlobalVariables.getUserSession().getPerson() |
1679 | |
.getPrincipalId(), "edit", document.getDocumentHeader().getWorkflowDocument().getDocumentType()); |
1680 | |
} |
1681 | |
|
1682 | |
|
1683 | 0 | processAfterEdit(document, requestParameters); |
1684 | 0 | } |
1685 | |
|
1686 | 0 | else if (KNSConstants.MAINTENANCE_DELETE_ACTION.equals(maintenanceAction)) { |
1687 | 0 | boolean allowsDelete = getBusinessObjectAuthorizationService().canMaintain( |
1688 | |
(BusinessObject) oldBusinessObject, GlobalVariables.getUserSession().getPerson(), |
1689 | |
document.getDocumentHeader().getWorkflowDocument().getDocumentType()); |
1690 | 0 | if (!allowsDelete) { |
1691 | 0 | LOG.error("Document type " + document.getDocumentHeader().getWorkflowDocument().getDocumentType() |
1692 | |
+ " does not allow delete actions."); |
1693 | 0 | throw new DocumentTypeAuthorizationException(GlobalVariables.getUserSession().getPerson() |
1694 | |
.getPrincipalId(), "delete", document.getDocumentHeader().getWorkflowDocument() |
1695 | |
.getDocumentType()); |
1696 | |
} |
1697 | |
} |
1698 | 0 | } |
1699 | |
|
1700 | |
|
1701 | |
|
1702 | |
|
1703 | |
|
1704 | |
|
1705 | |
|
1706 | |
|
1707 | |
|
1708 | |
|
1709 | |
|
1710 | |
|
1711 | |
|
1712 | |
|
1713 | |
|
1714 | |
|
1715 | |
|
1716 | |
|
1717 | |
protected Object retrieveObjectForMaintenance(MaintenanceDocument document, Map<String, String[]> requestParameters) { |
1718 | |
|
1719 | |
|
1720 | |
|
1721 | |
|
1722 | |
|
1723 | |
|
1724 | |
|
1725 | |
|
1726 | 0 | Map<String, String> keyMap = buildKeyMapFromRequest(requestParameters); |
1727 | |
|
1728 | 0 | Object oldBusinessObject = retrieveObjectForEditOrCopy(document, keyMap); |
1729 | |
|
1730 | 0 | if (oldBusinessObject == null && !document.getOldMaintainableObject().isExternalBusinessObject()) { |
1731 | 0 | throw new RuntimeException( |
1732 | |
"Cannot retrieve old record for maintenance document, incorrect parameters passed on maint url: " |
1733 | |
+ requestParameters); |
1734 | |
} |
1735 | |
|
1736 | 0 | if (document.getOldMaintainableObject().isExternalBusinessObject()) { |
1737 | 0 | if (oldBusinessObject == null) { |
1738 | |
try { |
1739 | 0 | oldBusinessObject = document.getOldMaintainableObject().getBoClass() |
1740 | |
.newInstance(); |
1741 | |
} |
1742 | 0 | catch (Exception ex) { |
1743 | 0 | throw new RuntimeException( |
1744 | |
"External BO maintainable was null and unable to instantiate for old maintainable object.", |
1745 | |
ex); |
1746 | 0 | } |
1747 | |
} |
1748 | |
|
1749 | 0 | populateMaintenanceObjectWithCopyKeyValues(WebUtils.translateRequestParameterMap(requestParameters), |
1750 | |
oldBusinessObject, document.getOldMaintainableObject()); |
1751 | 0 | document.getOldMaintainableObject().prepareBusinessObject((PersistableBusinessObject)oldBusinessObject); |
1752 | 0 | oldBusinessObject = document.getOldMaintainableObject().getDataObject(); |
1753 | |
} |
1754 | |
|
1755 | 0 | return oldBusinessObject; |
1756 | |
} |
1757 | |
|
1758 | |
|
1759 | |
|
1760 | |
|
1761 | |
|
1762 | |
@Override |
1763 | |
public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) { |
1764 | 0 | Object dataObject = null; |
1765 | |
|
1766 | |
try { |
1767 | 0 | dataObject = getLookupService().findObjectBySearch(getBoClass(), dataObjectKeys); |
1768 | |
} |
1769 | 0 | catch (ClassNotPersistenceCapableException ex) { |
1770 | 0 | if (!document.getOldMaintainableObject().isExternalBusinessObject()) { |
1771 | 0 | throw new RuntimeException("BO Class: " + getBoClass() |
1772 | |
+ " is not persistable and is not externalizable - configuration error"); |
1773 | |
} |
1774 | |
|
1775 | 0 | } |
1776 | |
|
1777 | 0 | return dataObject; |
1778 | |
} |
1779 | |
|
1780 | |
|
1781 | |
|
1782 | |
|
1783 | |
|
1784 | |
|
1785 | |
|
1786 | |
|
1787 | |
|
1788 | |
|
1789 | |
|
1790 | |
|
1791 | |
|
1792 | |
protected void processMaintenanceObjectForCopy(MaintenanceDocument document, Object maintenanceObject, |
1793 | |
Map<String, String[]> requestParameters) { |
1794 | 0 | if (!document.isFieldsClearedOnCopy()) { |
1795 | 0 | if (!maintenanceDocumentDictionaryService.getPreserveLockingKeysOnCopy(getBoClass())) { |
1796 | 0 | clearPrimaryKeyFields(maintenanceObject); |
1797 | |
} |
1798 | |
|
1799 | 0 | clearUnauthorizedNewFields(document); |
1800 | |
|
1801 | 0 | Maintainable maintainable = document.getNewMaintainableObject(); |
1802 | 0 | maintainable.processAfterCopy(document, requestParameters); |
1803 | |
|
1804 | |
|
1805 | 0 | document.setFieldsClearedOnCopy(true); |
1806 | |
} |
1807 | 0 | } |
1808 | |
|
1809 | |
|
1810 | |
|
1811 | |
|
1812 | |
|
1813 | |
|
1814 | |
|
1815 | |
protected void clearPrimaryKeyFields(Object maintenanceObject) { |
1816 | 0 | List<String> keyFieldNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(getBoClass()); |
1817 | 0 | for (String keyFieldName : keyFieldNames) { |
1818 | 0 | ObjectPropertyUtils.setPropertyValue(maintenanceObject, keyFieldName, null); |
1819 | |
} |
1820 | 0 | } |
1821 | |
|
1822 | |
|
1823 | |
|
1824 | |
|
1825 | |
|
1826 | |
|
1827 | |
|
1828 | |
|
1829 | |
|
1830 | |
protected void clearUnauthorizedNewFields(MaintenanceDocument document) { |
1831 | |
|
1832 | 0 | Person user = GlobalVariables.getUserSession().getPerson(); |
1833 | |
|
1834 | |
|
1835 | 0 | MaintenanceDocumentRestrictions maintenanceDocumentRestrictions = getBusinessObjectAuthorizationService() |
1836 | |
.getMaintenanceDocumentRestrictions(document, user); |
1837 | |
|
1838 | 0 | clearBusinessObjectOfRestrictedValues(maintenanceDocumentRestrictions); |
1839 | 0 | } |
1840 | |
|
1841 | |
|
1842 | |
|
1843 | |
|
1844 | |
|
1845 | |
|
1846 | |
|
1847 | |
|
1848 | |
|
1849 | |
|
1850 | |
|
1851 | |
protected Map<String, String> buildKeyMapFromRequest(Map<String, String[]> requestParameters) { |
1852 | 0 | List<String> keyFieldNames = null; |
1853 | |
|
1854 | |
|
1855 | 0 | Map<String, String> parameters = WebUtils.translateRequestParameterMap(requestParameters); |
1856 | |
|
1857 | |
|
1858 | |
|
1859 | 0 | if (!StringUtils.isBlank(parameters.get(KNSConstants.OVERRIDE_KEYS))) { |
1860 | 0 | String[] overrideKeys = parameters.get(KNSConstants.OVERRIDE_KEYS).split( |
1861 | |
KNSConstants.FIELD_CONVERSIONS_SEPARATOR); |
1862 | 0 | keyFieldNames = Arrays.asList(overrideKeys); |
1863 | 0 | } |
1864 | |
else { |
1865 | 0 | keyFieldNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(getBoClass()); |
1866 | |
} |
1867 | |
|
1868 | 0 | return WebUtils.getParametersFromRequest(keyFieldNames, getBoClass(), parameters); |
1869 | |
} |
1870 | |
|
1871 | |
|
1872 | |
|
1873 | |
|
1874 | |
|
1875 | |
|
1876 | |
|
1877 | |
|
1878 | |
|
1879 | |
|
1880 | |
|
1881 | |
|
1882 | |
|
1883 | |
|
1884 | |
protected void populateMaintenanceObjectWithCopyKeyValues(Map<String, String> parameters, Object oldBusinessObject, |
1885 | |
Maintainable oldMaintainableObject) { |
1886 | 0 | List<String> keyFieldNamesToCopy = null; |
1887 | 0 | Map<String, String> parametersToCopy = null; |
1888 | |
|
1889 | 0 | if (!StringUtils.isBlank(parameters.get(KNSConstants.COPY_KEYS))) { |
1890 | 0 | String[] copyKeys = parameters.get(KNSConstants.COPY_KEYS).split(KNSConstants.FIELD_CONVERSIONS_SEPARATOR); |
1891 | 0 | keyFieldNamesToCopy = Arrays.asList(copyKeys); |
1892 | 0 | parametersToCopy = WebUtils.getParametersFromRequest(keyFieldNamesToCopy, |
1893 | |
oldMaintainableObject.getBoClass(), parameters); |
1894 | |
} |
1895 | |
|
1896 | 0 | if (parametersToCopy != null) { |
1897 | |
|
1898 | 0 | ObjectPropertyUtils.copyPropertiesToObject(parametersToCopy, oldBusinessObject); |
1899 | |
} |
1900 | 0 | } |
1901 | |
|
1902 | |
|
1903 | |
|
1904 | |
|
1905 | |
|
1906 | |
|
1907 | |
|
1908 | |
|
1909 | |
|
1910 | |
|
1911 | |
|
1912 | |
@Override |
1913 | |
protected void processAfterAddLine(View view, CollectionGroup collectionGroup, Object model, Object addLine) { |
1914 | 0 | super.processAfterAddLine(view, collectionGroup, model, addLine); |
1915 | |
|
1916 | 0 | if (KNSConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceAction)) { |
1917 | 0 | MaintenanceForm maintenanceForm = (MaintenanceForm) model; |
1918 | 0 | MaintenanceDocument document = maintenanceForm.getDocument(); |
1919 | |
|
1920 | |
|
1921 | 0 | Collection<Object> oldCollection = ObjectPropertyUtils.getPropertyValue(document.getOldMaintainableObject() |
1922 | |
.getBusinessObject(), collectionGroup.getPropertyName()); |
1923 | |
try { |
1924 | 0 | Object blankLine = getBoClass().newInstance(); |
1925 | 0 | oldCollection.add(blankLine); |
1926 | |
} |
1927 | 0 | catch (Exception e) { |
1928 | 0 | throw new RuntimeException("Unable to create new line instance for old maintenance object", e); |
1929 | 0 | } |
1930 | |
} |
1931 | 0 | } |
1932 | |
|
1933 | |
protected PersistenceStructureService getPersistenceStructureService() { |
1934 | 0 | if (persistenceStructureService == null) { |
1935 | 0 | persistenceStructureService = KNSServiceLocator.getPersistenceStructureService(); |
1936 | |
} |
1937 | 0 | return persistenceStructureService; |
1938 | |
} |
1939 | |
|
1940 | |
protected MaintenanceDocumentDictionaryService getMaintenanceDocumentDictionaryService() { |
1941 | 0 | if (maintenanceDocumentDictionaryService == null) { |
1942 | 0 | maintenanceDocumentDictionaryService = KNSServiceLocatorWeb.getMaintenanceDocumentDictionaryService(); |
1943 | |
} |
1944 | 0 | return maintenanceDocumentDictionaryService; |
1945 | |
} |
1946 | |
|
1947 | |
protected BusinessObjectService getBusinessObjectService() { |
1948 | 0 | if (businessObjectService == null) { |
1949 | 0 | businessObjectService = KNSServiceLocator.getBusinessObjectService(); |
1950 | |
} |
1951 | 0 | return businessObjectService; |
1952 | |
} |
1953 | |
|
1954 | |
protected BusinessObjectDictionaryService getBusinessObjectDictionaryService() { |
1955 | 0 | if (businessObjectDictionaryService == null) { |
1956 | 0 | businessObjectDictionaryService = KNSServiceLocatorWeb.getBusinessObjectDictionaryService(); |
1957 | |
} |
1958 | 0 | return businessObjectDictionaryService; |
1959 | |
} |
1960 | |
|
1961 | |
protected EncryptionService getEncryptionService() { |
1962 | 0 | if (encryptionService == null) { |
1963 | 0 | encryptionService = CoreApiServiceLocator.getEncryptionService(); |
1964 | |
} |
1965 | 0 | return encryptionService; |
1966 | |
} |
1967 | |
|
1968 | |
protected org.kuali.rice.kim.service.PersonService getPersonService() { |
1969 | 0 | if (personService == null) { |
1970 | 0 | personService = KimApiServiceLocator.getPersonService(); |
1971 | |
} |
1972 | 0 | return personService; |
1973 | |
} |
1974 | |
|
1975 | |
protected BusinessObjectMetaDataService getBusinessObjectMetaDataService() { |
1976 | 0 | if (businessObjectMetaDataService == null) { |
1977 | 0 | businessObjectMetaDataService = KNSServiceLocatorWeb.getBusinessObjectMetaDataService(); |
1978 | |
} |
1979 | 0 | return businessObjectMetaDataService; |
1980 | |
} |
1981 | |
|
1982 | |
protected BusinessObjectAuthorizationService getBusinessObjectAuthorizationService() { |
1983 | 0 | if (businessObjectAuthorizationService == null) { |
1984 | 0 | businessObjectAuthorizationService = KNSServiceLocatorWeb.getBusinessObjectAuthorizationService(); |
1985 | |
} |
1986 | 0 | return businessObjectAuthorizationService; |
1987 | |
} |
1988 | |
|
1989 | |
protected MaintenanceDocumentService getMaintenanceDocumentService() { |
1990 | 0 | if (maintenanceDocumentService == null) { |
1991 | 0 | maintenanceDocumentService = KNSServiceLocatorWeb.getMaintenanceDocumentService(); |
1992 | |
} |
1993 | 0 | return maintenanceDocumentService; |
1994 | |
} |
1995 | |
|
1996 | |
protected DocumentHelperService getDocumentHelperService() { |
1997 | 0 | if (documentHelperService == null) { |
1998 | 0 | documentHelperService = KNSServiceLocatorWeb.getDocumentHelperService(); |
1999 | |
} |
2000 | 0 | return documentHelperService; |
2001 | |
} |
2002 | |
|
2003 | |
public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService) { |
2004 | 0 | this.persistenceStructureService = persistenceStructureService; |
2005 | 0 | } |
2006 | |
|
2007 | |
public void setMaintenanceDocumentDictionaryService( |
2008 | |
MaintenanceDocumentDictionaryService maintenanceDocumentDictionaryService) { |
2009 | 0 | this.maintenanceDocumentDictionaryService = maintenanceDocumentDictionaryService; |
2010 | 0 | } |
2011 | |
|
2012 | |
public void setBusinessObjectService(BusinessObjectService businessObjectService) { |
2013 | 0 | this.businessObjectService = businessObjectService; |
2014 | 0 | } |
2015 | |
|
2016 | |
public void setBusinessObjectDictionaryService(BusinessObjectDictionaryService businessObjectDictionaryService) { |
2017 | 0 | this.businessObjectDictionaryService = businessObjectDictionaryService; |
2018 | 0 | } |
2019 | |
|
2020 | |
public void setEncryptionService(EncryptionService encryptionService) { |
2021 | 0 | this.encryptionService = encryptionService; |
2022 | 0 | } |
2023 | |
|
2024 | |
public void setPersonService(org.kuali.rice.kim.service.PersonService personService) { |
2025 | 0 | this.personService = personService; |
2026 | 0 | } |
2027 | |
|
2028 | |
public void setBusinessObjectMetaDataService(BusinessObjectMetaDataService businessObjectMetaDataService) { |
2029 | 0 | this.businessObjectMetaDataService = businessObjectMetaDataService; |
2030 | 0 | } |
2031 | |
|
2032 | |
public void setBusinessObjectAuthorizationService( |
2033 | |
BusinessObjectAuthorizationService businessObjectAuthorizationService) { |
2034 | 0 | this.businessObjectAuthorizationService = businessObjectAuthorizationService; |
2035 | 0 | } |
2036 | |
|
2037 | |
public void setMaintenanceDocumentService(MaintenanceDocumentService maintenanceDocumentService) { |
2038 | 0 | this.maintenanceDocumentService = maintenanceDocumentService; |
2039 | 0 | } |
2040 | |
|
2041 | |
public void setDocumentHelperService(DocumentHelperService documentHelperService) { |
2042 | 0 | this.documentHelperService = documentHelperService; |
2043 | 0 | } |
2044 | |
|
2045 | |
protected LookupService getLookupService() { |
2046 | 0 | if (lookupService == null) { |
2047 | 0 | lookupService = KNSServiceLocatorWeb.getLookupService(); |
2048 | |
} |
2049 | 0 | return this.lookupService; |
2050 | |
} |
2051 | |
|
2052 | |
public void setLookupService(LookupService lookupService) { |
2053 | 0 | this.lookupService = lookupService; |
2054 | 0 | } |
2055 | |
|
2056 | |
} |