| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  package org.kuali.rice.kns.lookup; | 
  | 17 |  |   | 
  | 18 |  |  import java.security.GeneralSecurityException; | 
  | 19 |  |  import java.sql.Date; | 
  | 20 |  |  import java.util.ArrayList; | 
  | 21 |  |  import java.util.Collection; | 
  | 22 |  |  import java.util.HashMap; | 
  | 23 |  |  import java.util.HashSet; | 
  | 24 |  |  import java.util.Iterator; | 
  | 25 |  |  import java.util.List; | 
  | 26 |  |  import java.util.Map; | 
  | 27 |  |  import java.util.Properties; | 
  | 28 |  |  import java.util.Set; | 
  | 29 |  |   | 
  | 30 |  |  import org.apache.commons.lang.StringUtils; | 
  | 31 |  |  import org.kuali.rice.core.service.EncryptionService; | 
  | 32 |  |  import org.kuali.rice.kim.bo.Person; | 
  | 33 |  |  import org.kuali.rice.kns.authorization.BusinessObjectRestrictions; | 
  | 34 |  |  import org.kuali.rice.kns.authorization.FieldRestriction; | 
  | 35 |  |  import org.kuali.rice.kns.bo.BusinessObject; | 
  | 36 |  |  import org.kuali.rice.kns.bo.PersistableBusinessObject; | 
  | 37 |  |  import org.kuali.rice.kns.datadictionary.AttributeSecurity; | 
  | 38 |  |  import org.kuali.rice.kns.datadictionary.mask.MaskFormatter; | 
  | 39 |  |  import org.kuali.rice.kns.exception.ValidationException; | 
  | 40 |  |  import org.kuali.rice.kns.inquiry.Inquirable; | 
  | 41 |  |  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData; | 
  | 42 |  |  import org.kuali.rice.kns.lookup.HtmlData.InputHtmlData; | 
  | 43 |  |  import org.kuali.rice.kns.service.BusinessObjectAuthorizationService; | 
  | 44 |  |  import org.kuali.rice.kns.service.BusinessObjectDictionaryService; | 
  | 45 |  |  import org.kuali.rice.kns.service.BusinessObjectMetaDataService; | 
  | 46 |  |  import org.kuali.rice.kns.service.BusinessObjectService; | 
  | 47 |  |  import org.kuali.rice.kns.service.DataDictionaryService; | 
  | 48 |  |  import org.kuali.rice.kns.service.KNSServiceLocator; | 
  | 49 |  |  import org.kuali.rice.kns.service.KualiConfigurationService; | 
  | 50 |  |  import org.kuali.rice.kns.service.LookupService; | 
  | 51 |  |  import org.kuali.rice.kns.service.MaintenanceDocumentDictionaryService; | 
  | 52 |  |  import org.kuali.rice.kns.service.ParameterService; | 
  | 53 |  |  import org.kuali.rice.kns.service.PersistenceStructureService; | 
  | 54 |  |  import org.kuali.rice.kns.service.SequenceAccessorService; | 
  | 55 |  |  import org.kuali.rice.kns.util.FieldUtils; | 
  | 56 |  |  import org.kuali.rice.kns.util.GlobalVariables; | 
  | 57 |  |  import org.kuali.rice.kns.util.KNSConstants; | 
  | 58 |  |  import org.kuali.rice.kns.util.ObjectUtils; | 
  | 59 |  |  import org.kuali.rice.kns.util.RiceKeyConstants; | 
  | 60 |  |  import org.kuali.rice.kns.util.TypeUtils; | 
  | 61 |  |  import org.kuali.rice.kns.util.UrlFactory; | 
  | 62 |  |  import org.kuali.rice.kns.util.cache.CopiedObject; | 
  | 63 |  |  import org.kuali.rice.kns.web.comparator.CellComparatorHelper; | 
  | 64 |  |  import org.kuali.rice.kns.web.format.DateFormatter; | 
  | 65 |  |  import org.kuali.rice.kns.web.format.Formatter; | 
  | 66 |  |  import org.kuali.rice.kns.web.struts.form.LookupForm; | 
  | 67 |  |  import org.kuali.rice.kns.web.struts.form.MultipleValueLookupForm; | 
  | 68 |  |  import org.kuali.rice.kns.web.ui.Column; | 
  | 69 |  |  import org.kuali.rice.kns.web.ui.Field; | 
  | 70 |  |  import org.kuali.rice.kns.web.ui.ResultRow; | 
  | 71 |  |  import org.kuali.rice.kns.web.ui.Row; | 
  | 72 |  |   | 
  | 73 |  |   | 
  | 74 |  |   | 
  | 75 |  |   | 
  | 76 |  |   | 
  | 77 |  |  public abstract class AbstractLookupableHelperServiceImpl implements LookupableHelperService { | 
  | 78 |  |   | 
  | 79 |  |          protected static final String TITLE_RETURN_URL_PREPENDTEXT_PROPERTY = "title.return.url.value.prependtext"; | 
  | 80 |  |          protected static final String TITLE_ACTION_URL_PREPENDTEXT_PROPERTY = "title.action.url.value.prependtext"; | 
  | 81 |  |          protected static final String ACTION_URLS_CHILDREN_SEPARATOR = " | "; | 
  | 82 |  |          protected static final String ACTION_URLS_CHILDREN_STARTER = " ["; | 
  | 83 |  |          protected static final String ACTION_URLS_CHILDREN_END = "]"; | 
  | 84 |  |          protected static final String ACTION_URLS_SEPARATOR = "  "; | 
  | 85 |  |          protected static final String ACTION_URLS_EMPTY = " "; | 
  | 86 |  |   | 
  | 87 | 0 |          protected static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AbstractLookupableHelperServiceImpl.class); | 
  | 88 |  |   | 
  | 89 |  |          protected Class businessObjectClass; | 
  | 90 |  |          protected Map parameters; | 
  | 91 |  |          protected BusinessObjectDictionaryService businessObjectDictionaryService; | 
  | 92 |  |          protected BusinessObjectMetaDataService businessObjectMetaDataService; | 
  | 93 |  |          protected DataDictionaryService dataDictionaryService; | 
  | 94 |  |          protected PersistenceStructureService persistenceStructureService; | 
  | 95 |  |          protected EncryptionService encryptionService; | 
  | 96 |  |          protected List<String> readOnlyFieldsList; | 
  | 97 |  |          protected String backLocation; | 
  | 98 |  |          protected String docFormKey; | 
  | 99 |  |          protected Map fieldConversions; | 
  | 100 |  |          protected LookupService lookupService; | 
  | 101 |  |          protected List<Row> rows; | 
  | 102 |  |          protected String referencesToRefresh; | 
  | 103 |  |          protected SequenceAccessorService sequenceAccessorService; | 
  | 104 |  |          protected BusinessObjectService businessObjectService; | 
  | 105 |  |          protected LookupResultsService lookupResultsService; | 
  | 106 |  |          protected String docNum; | 
  | 107 |  |   | 
  | 108 |  |           | 
  | 109 |  |   | 
  | 110 |  |   | 
  | 111 |  |           public String getDocNum() { | 
  | 112 | 0 |                   return this.docNum; | 
  | 113 |  |           } | 
  | 114 |  |   | 
  | 115 |  |            | 
  | 116 |  |   | 
  | 117 |  |   | 
  | 118 |  |           public void setDocNum(String docNum) { | 
  | 119 | 0 |                   this.docNum = docNum; | 
  | 120 | 0 |           } | 
  | 121 |  |   | 
  | 122 | 0 |           public AbstractLookupableHelperServiceImpl() { | 
  | 123 | 0 |                   rows = null; | 
  | 124 | 0 |           } | 
  | 125 |  |   | 
  | 126 |  |            | 
  | 127 |  |   | 
  | 128 |  |   | 
  | 129 |  |   | 
  | 130 |  |   | 
  | 131 |  |           public boolean checkForAdditionalFields(Map fieldValues) { | 
  | 132 | 0 |                   return false; | 
  | 133 |  |           } | 
  | 134 |  |   | 
  | 135 |  |            | 
  | 136 |  |   | 
  | 137 |  |   | 
  | 138 |  |           public Class getBusinessObjectClass() { | 
  | 139 | 0 |                   return businessObjectClass; | 
  | 140 |  |           } | 
  | 141 |  |   | 
  | 142 |  |            | 
  | 143 |  |   | 
  | 144 |  |   | 
  | 145 |  |           public void setBusinessObjectClass(Class businessObjectClass) { | 
  | 146 | 0 |                   this.businessObjectClass = businessObjectClass; | 
  | 147 | 0 |                   setRows(); | 
  | 148 | 0 |           } | 
  | 149 |  |   | 
  | 150 |  |            | 
  | 151 |  |   | 
  | 152 |  |   | 
  | 153 |  |           public Map getParameters() { | 
  | 154 | 0 |                   return parameters; | 
  | 155 |  |           } | 
  | 156 |  |   | 
  | 157 |  |            | 
  | 158 |  |   | 
  | 159 |  |   | 
  | 160 |  |           public void setParameters(Map parameters) { | 
  | 161 | 0 |                   this.parameters = parameters; | 
  | 162 | 0 |           } | 
  | 163 |  |   | 
  | 164 |  |            | 
  | 165 |  |   | 
  | 166 |  |   | 
  | 167 |  |   | 
  | 168 |  |           public DataDictionaryService getDataDictionaryService() { | 
  | 169 | 0 |                   return dataDictionaryService != null ? dataDictionaryService : KNSServiceLocator.getDataDictionaryService(); | 
  | 170 |  |           } | 
  | 171 |  |   | 
  | 172 |  |            | 
  | 173 |  |   | 
  | 174 |  |   | 
  | 175 |  |   | 
  | 176 |  |           public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { | 
  | 177 | 0 |                   this.dataDictionaryService = dataDictionaryService; | 
  | 178 | 0 |           } | 
  | 179 |  |   | 
  | 180 |  |            | 
  | 181 |  |   | 
  | 182 |  |   | 
  | 183 |  |   | 
  | 184 |  |           public BusinessObjectDictionaryService getBusinessObjectDictionaryService() { | 
  | 185 | 0 |                   return businessObjectDictionaryService != null ? businessObjectDictionaryService : KNSServiceLocator.getBusinessObjectDictionaryService(); | 
  | 186 |  |           } | 
  | 187 |  |   | 
  | 188 |  |            | 
  | 189 |  |   | 
  | 190 |  |   | 
  | 191 |  |   | 
  | 192 |  |           public void setBusinessObjectDictionaryService(BusinessObjectDictionaryService businessObjectDictionaryService) { | 
  | 193 | 0 |                   this.businessObjectDictionaryService = businessObjectDictionaryService; | 
  | 194 | 0 |           } | 
  | 195 |  |   | 
  | 196 |  |            | 
  | 197 |  |   | 
  | 198 |  |   | 
  | 199 |  |   | 
  | 200 |  |           public BusinessObjectMetaDataService getBusinessObjectMetaDataService() { | 
  | 201 | 0 |                   return businessObjectMetaDataService != null ? businessObjectMetaDataService : KNSServiceLocator.getBusinessObjectMetaDataService(); | 
  | 202 |  |           } | 
  | 203 |  |   | 
  | 204 |  |            | 
  | 205 |  |   | 
  | 206 |  |   | 
  | 207 |  |   | 
  | 208 |  |           public void setBusinessObjectMetaDataService(BusinessObjectMetaDataService businessObjectMetaDataService) { | 
  | 209 | 0 |                   this.businessObjectMetaDataService = businessObjectMetaDataService; | 
  | 210 | 0 |           } | 
  | 211 |  |   | 
  | 212 |  |            | 
  | 213 |  |   | 
  | 214 |  |   | 
  | 215 |  |   | 
  | 216 |  |           protected PersistenceStructureService getPersistenceStructureService() { | 
  | 217 | 0 |                   return persistenceStructureService != null ? persistenceStructureService : KNSServiceLocator.getPersistenceStructureService(); | 
  | 218 |  |           } | 
  | 219 |  |   | 
  | 220 |  |            | 
  | 221 |  |   | 
  | 222 |  |   | 
  | 223 |  |   | 
  | 224 |  |           public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService) { | 
  | 225 | 0 |                   this.persistenceStructureService = persistenceStructureService; | 
  | 226 | 0 |           } | 
  | 227 |  |   | 
  | 228 |  |            | 
  | 229 |  |   | 
  | 230 |  |   | 
  | 231 |  |   | 
  | 232 |  |           protected EncryptionService getEncryptionService() { | 
  | 233 | 0 |                   return encryptionService != null ? encryptionService : KNSServiceLocator.getEncryptionService(); | 
  | 234 |  |           } | 
  | 235 |  |   | 
  | 236 |  |            | 
  | 237 |  |   | 
  | 238 |  |   | 
  | 239 |  |   | 
  | 240 |  |           public void setEncryptionService(EncryptionService encryptionService) { | 
  | 241 | 0 |                   this.encryptionService = encryptionService; | 
  | 242 | 0 |           } | 
  | 243 |  |   | 
  | 244 |  |           protected MaintenanceDocumentDictionaryService maintenanceDocumentDictionaryService; | 
  | 245 |  |   | 
  | 246 |  |           public MaintenanceDocumentDictionaryService getMaintenanceDocumentDictionaryService() { | 
  | 247 | 0 |                   if ( maintenanceDocumentDictionaryService == null ) { | 
  | 248 | 0 |                           maintenanceDocumentDictionaryService = KNSServiceLocator.getMaintenanceDocumentDictionaryService(); | 
  | 249 |  |                   } | 
  | 250 | 0 |                   return maintenanceDocumentDictionaryService; | 
  | 251 |  |           } | 
  | 252 |  |   | 
  | 253 |  |           protected BusinessObjectAuthorizationService businessObjectAuthorizationService; | 
  | 254 |  |   | 
  | 255 |  |           public BusinessObjectAuthorizationService getBusinessObjectAuthorizationService() { | 
  | 256 | 0 |                   if ( businessObjectAuthorizationService == null ) { | 
  | 257 | 0 |                           businessObjectAuthorizationService = KNSServiceLocator.getBusinessObjectAuthorizationService(); | 
  | 258 |  |                   } | 
  | 259 | 0 |                   return businessObjectAuthorizationService; | 
  | 260 |  |           } | 
  | 261 |  |   | 
  | 262 |  |           protected Inquirable kualiInquirable; | 
  | 263 |  |   | 
  | 264 |  |           public Inquirable getKualiInquirable() { | 
  | 265 | 0 |                   if ( kualiInquirable == null ) { | 
  | 266 | 0 |                           kualiInquirable = KNSServiceLocator.getKualiInquirable(); | 
  | 267 |  |                   } | 
  | 268 | 0 |                   return kualiInquirable; | 
  | 269 |  |           } | 
  | 270 |  |   | 
  | 271 |  |           public void setMaintenanceDocumentDictionaryService(MaintenanceDocumentDictionaryService maintenanceDocumentDictionaryService) { | 
  | 272 | 0 |                   this.maintenanceDocumentDictionaryService = maintenanceDocumentDictionaryService; | 
  | 273 | 0 |           } | 
  | 274 |  |   | 
  | 275 |  |           public void setKualiInquirable(Inquirable kualiInquirable) { | 
  | 276 | 0 |                   this.kualiInquirable = kualiInquirable; | 
  | 277 | 0 |           } | 
  | 278 |  |   | 
  | 279 |  |           protected KualiConfigurationService configurationService; | 
  | 280 |  |   | 
  | 281 |  |           public KualiConfigurationService getKualiConfigurationService() { | 
  | 282 | 0 |      if ( configurationService == null ) { | 
  | 283 | 0 |          configurationService = KNSServiceLocator.getKualiConfigurationService(); | 
  | 284 |  |      } | 
  | 285 | 0 |          return configurationService; | 
  | 286 |  |      } | 
  | 287 |  |   | 
  | 288 |  |      public void setParameterService(KualiConfigurationService configurationService) { | 
  | 289 | 0 |          this.configurationService = configurationService; | 
  | 290 | 0 |      } | 
  | 291 |  |   | 
  | 292 |  |      protected ParameterService parameterService; | 
  | 293 |  |   | 
  | 294 |  |      public ParameterService getParameterService() { | 
  | 295 | 0 |          if ( parameterService == null ) { | 
  | 296 | 0 |              parameterService = KNSServiceLocator.getParameterService(); | 
  | 297 |  |                   } | 
  | 298 | 0 |          return parameterService; | 
  | 299 |  |           } | 
  | 300 |  |   | 
  | 301 |  |      public void setParameterService(ParameterService parameterService) { | 
  | 302 | 0 |          this.parameterService = parameterService; | 
  | 303 | 0 |           } | 
  | 304 |  |   | 
  | 305 |  |            | 
  | 306 |  |   | 
  | 307 |  |   | 
  | 308 |  |   | 
  | 309 |  |   | 
  | 310 |  |           public boolean allowsMaintenanceNewOrCopyAction() { | 
  | 311 | 0 |                   boolean allowsNewOrCopy = false; | 
  | 312 |  |   | 
  | 313 | 0 |                   String maintDocTypeName = getMaintenanceDocumentTypeName(); | 
  | 314 | 0 |                   Class boClass = this.getBusinessObjectClass(); | 
  | 315 |  |   | 
  | 316 | 0 |                   if (StringUtils.isNotBlank(maintDocTypeName)) { | 
  | 317 | 0 |                           allowsNewOrCopy = getBusinessObjectAuthorizationService().canCreate(boClass, GlobalVariables.getUserSession().getPerson(), maintDocTypeName); | 
  | 318 |  |                   } | 
  | 319 | 0 |                   return allowsNewOrCopy; | 
  | 320 |  |           } | 
  | 321 |  |   | 
  | 322 |  |           protected boolean allowsMaintenanceEditAction(BusinessObject businessObject) { | 
  | 323 | 0 |                   boolean allowsEdit = false; | 
  | 324 |  |   | 
  | 325 | 0 |                   String maintDocTypeName = getMaintenanceDocumentTypeName(); | 
  | 326 |  |   | 
  | 327 | 0 |                   if (StringUtils.isNotBlank(maintDocTypeName)) { | 
  | 328 | 0 |                           allowsEdit = getBusinessObjectAuthorizationService().canMaintain(businessObject, GlobalVariables.getUserSession().getPerson(), maintDocTypeName); | 
  | 329 |  |                   } | 
  | 330 | 0 |                   return allowsEdit; | 
  | 331 |  |           } | 
  | 332 |  |   | 
  | 333 |  |   | 
  | 334 |  |            | 
  | 335 |  |   | 
  | 336 |  |   | 
  | 337 |  |   | 
  | 338 |  |   | 
  | 339 |  |   | 
  | 340 |  |   | 
  | 341 |  |           final public String getMaintenanceUrl(BusinessObject businessObject, HtmlData htmlData, List pkNames, BusinessObjectRestrictions businessObjectRestrictions) { | 
  | 342 | 0 |                   htmlData.setTitle(getActionUrlTitleText(businessObject, htmlData.getDisplayText(), pkNames, businessObjectRestrictions)); | 
  | 343 | 0 |                   return htmlData.constructCompleteHtmlTag(); | 
  | 344 |  |           } | 
  | 345 |  |   | 
  | 346 |  |            | 
  | 347 |  |   | 
  | 348 |  |   | 
  | 349 |  |   | 
  | 350 |  |   | 
  | 351 |  |   | 
  | 352 |  |   | 
  | 353 |  |           final public String getActionUrls(BusinessObject businessObject, List pkNames, BusinessObjectRestrictions businessObjectRestrictions) { | 
  | 354 | 0 |                   StringBuffer actions = new StringBuffer(); | 
  | 355 | 0 |                   List<HtmlData> htmlDataList = getCustomActionUrls(businessObject, pkNames); | 
  | 356 | 0 |                   for(HtmlData htmlData: htmlDataList){ | 
  | 357 | 0 |                           actions.append(getMaintenanceUrl(businessObject, htmlData, pkNames, businessObjectRestrictions)); | 
  | 358 | 0 |                           if(htmlData.getChildUrlDataList()!=null){ | 
  | 359 | 0 |                                   if(htmlData.getChildUrlDataList().size()>0){ | 
  | 360 | 0 |                                           actions.append(ACTION_URLS_CHILDREN_STARTER); | 
  | 361 | 0 |                                           for(HtmlData childURLData: htmlData.getChildUrlDataList()){ | 
  | 362 | 0 |                                                   actions.append(getMaintenanceUrl(businessObject, childURLData, pkNames, businessObjectRestrictions)); | 
  | 363 | 0 |                                                   actions.append(ACTION_URLS_CHILDREN_SEPARATOR); | 
  | 364 |  |                                           } | 
  | 365 | 0 |                                           if(actions.toString().endsWith(ACTION_URLS_CHILDREN_SEPARATOR)) | 
  | 366 | 0 |                                                   actions.delete(actions.length()-ACTION_URLS_CHILDREN_SEPARATOR.length(), actions.length()); | 
  | 367 | 0 |                                           actions.append(ACTION_URLS_CHILDREN_END); | 
  | 368 |  |                                   } | 
  | 369 |  |                           } | 
  | 370 | 0 |                           actions.append(ACTION_URLS_SEPARATOR); | 
  | 371 |  |                   } | 
  | 372 | 0 |                   if(actions.toString().endsWith(ACTION_URLS_SEPARATOR)) | 
  | 373 | 0 |                           actions.delete(actions.length()-ACTION_URLS_SEPARATOR.length(), actions.length()); | 
  | 374 | 0 |                   return actions.toString(); | 
  | 375 |  |           } | 
  | 376 |  |   | 
  | 377 |  |            | 
  | 378 |  |   | 
  | 379 |  |   | 
  | 380 |  |   | 
  | 381 |  |   | 
  | 382 |  |   | 
  | 383 |  |   | 
  | 384 |  |   | 
  | 385 |  |   | 
  | 386 |  |           public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames){ | 
  | 387 | 0 |                   List<HtmlData> htmlDataList = new ArrayList<HtmlData>(); | 
  | 388 | 0 |          if (allowsMaintenanceEditAction(businessObject)) { | 
  | 389 | 0 |                           htmlDataList.add(getUrlData(businessObject, KNSConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, pkNames)); | 
  | 390 |  |                   } | 
  | 391 | 0 |                   if (allowsMaintenanceNewOrCopyAction()) { | 
  | 392 | 0 |                           htmlDataList.add(getUrlData(businessObject, KNSConstants.MAINTENANCE_COPY_METHOD_TO_CALL, pkNames)); | 
  | 393 |  |                   } | 
  | 394 | 0 |                   if (allowsMaintenanceDeleteAction(businessObject)) { | 
  | 395 | 0 |                           htmlDataList.add(getUrlData(businessObject, KNSConstants.MAINTENANCE_DELETE_METHOD_TO_CALL, pkNames)); | 
  | 396 |  |                   } | 
  | 397 | 0 |                   return htmlDataList; | 
  | 398 |  |           } | 
  | 399 |  |   | 
  | 400 |  |            | 
  | 401 |  |   | 
  | 402 |  |   | 
  | 403 |  |   | 
  | 404 |  |   | 
  | 405 |  |           protected boolean allowsMaintenanceDeleteAction(BusinessObject businessObject) { | 
  | 406 |  |   | 
  | 407 | 0 |                   boolean allowsMaintain = false; | 
  | 408 | 0 |                   boolean allowsDelete = false; | 
  | 409 |  |   | 
  | 410 | 0 |                   String maintDocTypeName = getMaintenanceDocumentTypeName(); | 
  | 411 |  |   | 
  | 412 | 0 |                   if (StringUtils.isNotBlank(maintDocTypeName)) { | 
  | 413 | 0 |                           allowsMaintain = getBusinessObjectAuthorizationService().canMaintain(businessObject, GlobalVariables.getUserSession().getPerson(), maintDocTypeName);             | 
  | 414 |  |                   }      | 
  | 415 |  |   | 
  | 416 | 0 |                   allowsDelete = KNSServiceLocator.getMaintenanceDocumentDictionaryService().getAllowsRecordDeletion(businessObjectClass); | 
  | 417 |  |   | 
  | 418 | 0 |                   return allowsDelete&&allowsMaintain; | 
  | 419 |  |           } | 
  | 420 |  |   | 
  | 421 |  |            | 
  | 422 |  |   | 
  | 423 |  |   | 
  | 424 |  |   | 
  | 425 |  |   | 
  | 426 |  |   | 
  | 427 |  |   | 
  | 428 |  |   | 
  | 429 |  |   | 
  | 430 |  |   | 
  | 431 |  |   | 
  | 432 |  |   | 
  | 433 |  |           protected AnchorHtmlData getUrlData(BusinessObject businessObject, String methodToCall, String displayText, List pkNames){ | 
  | 434 |  |   | 
  | 435 | 0 |                   String href = getActionUrlHref(businessObject, methodToCall, pkNames); | 
  | 436 |  |                    | 
  | 437 | 0 |                   AnchorHtmlData anchorHtmlData = new AnchorHtmlData(href, methodToCall, displayText); | 
  | 438 | 0 |                   return anchorHtmlData; | 
  | 439 |  |           } | 
  | 440 |  |   | 
  | 441 |  |            | 
  | 442 |  |   | 
  | 443 |  |   | 
  | 444 |  |   | 
  | 445 |  |   | 
  | 446 |  |   | 
  | 447 |  |   | 
  | 448 |  |   | 
  | 449 |  |   | 
  | 450 |  |           protected AnchorHtmlData getUrlData(BusinessObject businessObject, String methodToCall, List pkNames){ | 
  | 451 | 0 |                   return getUrlData(businessObject, methodToCall, methodToCall, pkNames); | 
  | 452 |  |           } | 
  | 453 |  |   | 
  | 454 |  |            | 
  | 455 |  |   | 
  | 456 |  |   | 
  | 457 |  |   | 
  | 458 |  |   | 
  | 459 |  |   | 
  | 460 |  |           protected List<HtmlData> getEmptyActionUrls(){ | 
  | 461 | 0 |                   return new ArrayList<HtmlData>(); | 
  | 462 |  |           } | 
  | 463 |  |   | 
  | 464 |  |           protected HtmlData getEmptyAnchorHtmlData(){ | 
  | 465 | 0 |                   return new AnchorHtmlData(); | 
  | 466 |  |           } | 
  | 467 |  |   | 
  | 468 |  |            | 
  | 469 |  |   | 
  | 470 |  |   | 
  | 471 |  |   | 
  | 472 |  |   | 
  | 473 |  |   | 
  | 474 |  |   | 
  | 475 |  |   | 
  | 476 |  |   | 
  | 477 |  |   | 
  | 478 |  |   | 
  | 479 |  |           protected String getActionUrlHref(BusinessObject businessObject, String methodToCall, List pkNames){ | 
  | 480 | 0 |                   Properties parameters = new Properties(); | 
  | 481 | 0 |                   parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, methodToCall); | 
  | 482 |  |           | 
  | 483 | 0 |          parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, businessObject.getClass().getName()); | 
  | 484 | 0 |                   parameters.putAll(getParametersFromPrimaryKey(businessObject, pkNames)); | 
  | 485 | 0 |                   if (StringUtils.isNotBlank(getReturnLocation())) { | 
  | 486 | 0 |                           parameters.put(KNSConstants.RETURN_LOCATION_PARAMETER, getReturnLocation());          | 
  | 487 |  |                   } | 
  | 488 | 0 |                   return UrlFactory.parameterizeUrl(KNSConstants.MAINTENANCE_ACTION, parameters); | 
  | 489 |  |           } | 
  | 490 |  |   | 
  | 491 |  |           protected Properties getParametersFromPrimaryKey(BusinessObject businessObject, List pkNames){ | 
  | 492 | 0 |                   Properties parameters = new Properties(); | 
  | 493 | 0 |                   for (Iterator iter = pkNames.iterator(); iter.hasNext();) { | 
  | 494 | 0 |                           String fieldNm = (String) iter.next(); | 
  | 495 |  |   | 
  | 496 | 0 |                           Object fieldVal = ObjectUtils.getPropertyValue(businessObject, fieldNm); | 
  | 497 | 0 |                           if (fieldVal == null) { | 
  | 498 | 0 |                                   fieldVal = KNSConstants.EMPTY_STRING; | 
  | 499 |  |                           } | 
  | 500 | 0 |                           if (fieldVal instanceof java.sql.Date) { | 
  | 501 | 0 |                                   String formattedString = ""; | 
  | 502 | 0 |                                   if (Formatter.findFormatter(fieldVal.getClass()) != null) { | 
  | 503 | 0 |                                           Formatter formatter = Formatter.getFormatter(fieldVal.getClass()); | 
  | 504 | 0 |                                           formattedString = (String) formatter.format(fieldVal); | 
  | 505 | 0 |                                           fieldVal = formattedString; | 
  | 506 |  |                                   } | 
  | 507 |  |                           } | 
  | 508 |  |   | 
  | 509 |  |                            | 
  | 510 | 0 |                           if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(businessObjectClass, fieldNm)) { | 
  | 511 |  |                                   try { | 
  | 512 | 0 |                                           fieldVal = getEncryptionService().encrypt(fieldVal) + EncryptionService.ENCRYPTION_POST_PREFIX; | 
  | 513 |  |                                   } | 
  | 514 | 0 |                                   catch (GeneralSecurityException e) { | 
  | 515 | 0 |                                           LOG.error("Exception while trying to encrypted value for inquiry framework.", e); | 
  | 516 | 0 |                                           throw new RuntimeException(e); | 
  | 517 | 0 |                                   } | 
  | 518 |  |   | 
  | 519 |  |                           } | 
  | 520 |  |   | 
  | 521 | 0 |                           parameters.put(fieldNm, fieldVal.toString()); | 
  | 522 | 0 |                   } | 
  | 523 | 0 |                   return parameters; | 
  | 524 |  |           } | 
  | 525 |  |   | 
  | 526 |  |            | 
  | 527 |  |   | 
  | 528 |  |   | 
  | 529 |  |   | 
  | 530 |  |   | 
  | 531 |  |   | 
  | 532 |  |   | 
  | 533 |  |   | 
  | 534 |  |   | 
  | 535 |  |   | 
  | 536 |  |   | 
  | 537 |  |           protected String getActionUrlTitleText(BusinessObject businessObject, String displayText, List pkNames, BusinessObjectRestrictions businessObjectRestrictions){ | 
  | 538 | 0 |                   String prependTitleText = displayText+" " | 
  | 539 |  |                   +getDataDictionaryService().getDataDictionary().getBusinessObjectEntry(getBusinessObjectClass().getName()).getObjectLabel() | 
  | 540 |  |                   +" " | 
  | 541 |  |                   +KNSServiceLocator.getKualiConfigurationService().getPropertyString(TITLE_ACTION_URL_PREPENDTEXT_PROPERTY); | 
  | 542 | 0 |                   return HtmlData.getTitleText(prependTitleText, businessObject, pkNames, businessObjectRestrictions); | 
  | 543 |  |           } | 
  | 544 |  |   | 
  | 545 |  |            | 
  | 546 |  |   | 
  | 547 |  |   | 
  | 548 |  |   | 
  | 549 |  |   | 
  | 550 |  |           protected String getMaintenanceDocumentTypeName() { | 
  | 551 | 0 |                   MaintenanceDocumentDictionaryService dd = getMaintenanceDocumentDictionaryService(); | 
  | 552 | 0 |                   String maintDocTypeName = dd.getDocumentTypeName(getBusinessObjectClass()); | 
  | 553 | 0 |                   return maintDocTypeName; | 
  | 554 |  |           } | 
  | 555 |  |   | 
  | 556 |  |            | 
  | 557 |  |   | 
  | 558 |  |   | 
  | 559 |  |   | 
  | 560 |  |   | 
  | 561 |  |           public List<String> getReadOnlyFieldsList() { | 
  | 562 | 0 |                   return readOnlyFieldsList; | 
  | 563 |  |           } | 
  | 564 |  |   | 
  | 565 |  |   | 
  | 566 |  |            | 
  | 567 |  |   | 
  | 568 |  |   | 
  | 569 |  |   | 
  | 570 |  |   | 
  | 571 |  |           public void setReadOnlyFieldsList(List<String> readOnlyFieldsList) { | 
  | 572 | 0 |                   this.readOnlyFieldsList = readOnlyFieldsList; | 
  | 573 | 0 |           } | 
  | 574 |  |   | 
  | 575 | 0 |           protected HashMap<String,Boolean> noLookupResultFieldInquiryCache = new HashMap<String, Boolean>(); | 
  | 576 | 0 |           protected HashMap<Class,Class> inquirableClassCache = new HashMap<Class, Class>(); | 
  | 577 | 0 |           protected HashMap<String,Boolean> forceLookupResultFieldInquiryCache = new HashMap<String, Boolean>(); | 
  | 578 |  |            | 
  | 579 |  |   | 
  | 580 |  |   | 
  | 581 |  |   | 
  | 582 |  |   | 
  | 583 |  |   | 
  | 584 |  |   | 
  | 585 |  |           public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) { | 
  | 586 | 0 |                   HtmlData inquiryUrl = new AnchorHtmlData(); | 
  | 587 |  |   | 
  | 588 | 0 |                   String cacheKey = bo.getClass().getName()+"."+propertyName; | 
  | 589 | 0 |                   Boolean noLookupResultFieldInquiry = noLookupResultFieldInquiryCache.get( cacheKey ); | 
  | 590 | 0 |                   if ( noLookupResultFieldInquiry == null ) { | 
  | 591 | 0 |                           noLookupResultFieldInquiry = getBusinessObjectDictionaryService().noLookupResultFieldInquiry(bo.getClass(), propertyName); | 
  | 592 | 0 |                           if ( noLookupResultFieldInquiry == null ) { | 
  | 593 | 0 |                                   noLookupResultFieldInquiry = Boolean.TRUE; | 
  | 594 |  |                           } | 
  | 595 | 0 |                           noLookupResultFieldInquiryCache.put(cacheKey, noLookupResultFieldInquiry); | 
  | 596 |  |                   } | 
  | 597 | 0 |                   if ( !noLookupResultFieldInquiry ) { | 
  | 598 |  |   | 
  | 599 | 0 |                           Class<Inquirable> inquirableClass = inquirableClassCache.get( bo.getClass() ); | 
  | 600 | 0 |                           if ( !inquirableClassCache.containsKey( bo.getClass() ) ) { | 
  | 601 | 0 |                                   inquirableClass = getBusinessObjectDictionaryService().getInquirableClass(bo.getClass()); | 
  | 602 | 0 |                                   inquirableClassCache.put(bo.getClass(), inquirableClass); | 
  | 603 |  |                           } | 
  | 604 | 0 |                           Inquirable inq = null; | 
  | 605 |  |                           try { | 
  | 606 | 0 |                                   if ( inquirableClass != null ) { | 
  | 607 | 0 |                                           inq = inquirableClass.newInstance(); | 
  | 608 |  |                                   } else { | 
  | 609 | 0 |                                           inq = getKualiInquirable(); | 
  | 610 | 0 |                                           if ( LOG.isDebugEnabled() ) { | 
  | 611 | 0 |                                                   LOG.debug( "Default Inquirable Class: " + inq.getClass() ); | 
  | 612 |  |                                           } | 
  | 613 |  |                                   } | 
  | 614 | 0 |                                   Boolean forceLookupResultFieldInquiry = forceLookupResultFieldInquiryCache.get( cacheKey ); | 
  | 615 | 0 |                                   if ( forceLookupResultFieldInquiry == null ) { | 
  | 616 | 0 |                                           forceLookupResultFieldInquiry = getBusinessObjectDictionaryService().forceLookupResultFieldInquiry(bo.getClass(), propertyName); | 
  | 617 | 0 |                                           if ( forceLookupResultFieldInquiry == null ) { | 
  | 618 | 0 |                                                   forceLookupResultFieldInquiry = Boolean.FALSE; | 
  | 619 |  |                                           } | 
  | 620 | 0 |                                           forceLookupResultFieldInquiryCache.put(cacheKey, forceLookupResultFieldInquiry); | 
  | 621 |  |                                   } | 
  | 622 | 0 |                                   inquiryUrl = inq.getInquiryUrl(bo, propertyName, forceLookupResultFieldInquiry); | 
  | 623 | 0 |                           } catch ( Exception ex ) { | 
  | 624 | 0 |                                   LOG.error("unable to create inquirable to get inquiry URL", ex ); | 
  | 625 | 0 |                           } | 
  | 626 |  |                   } | 
  | 627 |  |   | 
  | 628 | 0 |                   return inquiryUrl; | 
  | 629 |  |           } | 
  | 630 |  |   | 
  | 631 | 0 |           protected CopiedObject<ArrayList<Column>> resultColumns = null; | 
  | 632 |  |   | 
  | 633 |  |            | 
  | 634 |  |   | 
  | 635 |  |   | 
  | 636 |  |           public List<Column> getColumns() { | 
  | 637 | 0 |                   if ( resultColumns == null ) { | 
  | 638 | 0 |                           ArrayList<Column> columns = new ArrayList<Column>(); | 
  | 639 | 0 |                           for (String attributeName : getBusinessObjectDictionaryService().getLookupResultFieldNames(getBusinessObjectClass())) { | 
  | 640 | 0 |                                   Column column = new Column(); | 
  | 641 | 0 |                                   column.setPropertyName(attributeName); | 
  | 642 | 0 |                                   String columnTitle = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), attributeName); | 
  | 643 | 0 |                                   Boolean useShortLabel = getBusinessObjectDictionaryService().getLookupResultFieldUseShortLabel(businessObjectClass, attributeName); | 
  | 644 | 0 |                                   if(useShortLabel != null && useShortLabel){ | 
  | 645 | 0 |                                           columnTitle = getDataDictionaryService().getAttributeShortLabel(getBusinessObjectClass(), attributeName); | 
  | 646 |  |                                   } | 
  | 647 | 0 |                                   if (StringUtils.isBlank(columnTitle)) { | 
  | 648 | 0 |                                           columnTitle = getDataDictionaryService().getCollectionLabel(getBusinessObjectClass(), attributeName); | 
  | 649 |  |                                   } | 
  | 650 | 0 |                                   column.setColumnTitle(columnTitle); | 
  | 651 | 0 |                                   column.setMaxLength(getColumnMaxLength(attributeName)); | 
  | 652 |  |   | 
  | 653 | 0 |                                  if (!businessObjectClass.isInterface()) { | 
  | 654 |  |                                          try { | 
  | 655 | 0 |                                                  column.setFormatter(ObjectUtils.getFormatterWithDataDictionary(getBusinessObjectClass() | 
  | 656 |  |                                                                  .newInstance(), attributeName)); | 
  | 657 | 0 |                                          } catch (InstantiationException e) { | 
  | 658 | 0 |                                                  LOG.info("Unable to get new instance of business object class: " + businessObjectClass.getName(),e); | 
  | 659 |  |                                                   | 
  | 660 | 0 |                                          } catch (IllegalAccessException e) { | 
  | 661 | 0 |                                                  LOG.info("Unable to get new instance of business object class: " + businessObjectClass.getName(),e); | 
  | 662 |  |                                                   | 
  | 663 | 0 |                                          } | 
  | 664 |  |                                  } | 
  | 665 |  |                                    | 
  | 666 | 0 |                                  String alternateDisplayPropertyName = getBusinessObjectDictionaryService() | 
  | 667 |  |                                                  .getLookupFieldAlternateDisplayAttributeName(getBusinessObjectClass(), attributeName); | 
  | 668 | 0 |                                  if (StringUtils.isNotBlank(alternateDisplayPropertyName)) { | 
  | 669 | 0 |                                          column.setAlternateDisplayPropertyName(alternateDisplayPropertyName); | 
  | 670 |  |                                  } | 
  | 671 |  |   | 
  | 672 | 0 |                                  String additionalDisplayPropertyName = getBusinessObjectDictionaryService() | 
  | 673 |  |                                                  .getLookupFieldAdditionalDisplayAttributeName(getBusinessObjectClass(), attributeName); | 
  | 674 | 0 |                                  if (StringUtils.isNotBlank(additionalDisplayPropertyName)) { | 
  | 675 | 0 |                                          column.setAdditionalDisplayPropertyName(additionalDisplayPropertyName); | 
  | 676 |  |                                  } | 
  | 677 |  |                                  else { | 
  | 678 | 0 |                                          boolean translateCodes = getBusinessObjectDictionaryService().tranlateCodesInLookup(getBusinessObjectClass()); | 
  | 679 | 0 |                                          if (translateCodes) { | 
  | 680 | 0 |                                                  FieldUtils.setAdditionalDisplayPropertyForCodes(getBusinessObjectClass(), attributeName, column); | 
  | 681 |  |                                          }         | 
  | 682 |  |                                  } | 
  | 683 |  |                                   | 
  | 684 | 0 |                                  column.setTotal(getBusinessObjectDictionaryService().getLookupResultFieldTotal(getBusinessObjectClass(), attributeName)); | 
  | 685 |  |   | 
  | 686 | 0 |                                  columns.add(column); | 
  | 687 | 0 |                           } | 
  | 688 | 0 |                           resultColumns = ObjectUtils.deepCopyForCaching(columns); | 
  | 689 | 0 |                           return columns; | 
  | 690 |  |                   } | 
  | 691 | 0 |                   return resultColumns.getContent(); | 
  | 692 |  |           } | 
  | 693 |  |   | 
  | 694 | 0 |           protected static Integer RESULTS_DEFAULT_MAX_COLUMN_LENGTH = null; | 
  | 695 |  |   | 
  | 696 |  |           protected int getColumnMaxLength(String attributeName) { | 
  | 697 | 0 |                   Integer fieldDefinedMaxLength = getBusinessObjectDictionaryService().getLookupResultFieldMaxLength(getBusinessObjectClass(), attributeName); | 
  | 698 | 0 |                   if (fieldDefinedMaxLength == null) { | 
  | 699 | 0 |                           if ( RESULTS_DEFAULT_MAX_COLUMN_LENGTH == null ) { | 
  | 700 |  |                                   try { | 
  | 701 | 0 |                                      RESULTS_DEFAULT_MAX_COLUMN_LENGTH = Integer.valueOf( getParameterService().getParameterValue(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.LOOKUP_PARM_DETAIL_TYPE, KNSConstants.RESULTS_DEFAULT_MAX_COLUMN_LENGTH) ); | 
  | 702 | 0 |                                   } catch ( NumberFormatException ex ) { | 
  | 703 | 0 |                                           LOG.error("Lookup field max length parameter not found and unable to parse default set in system parameters (RESULTS_DEFAULT_MAX_COLUMN_LENGTH)."); | 
  | 704 | 0 |                                   } | 
  | 705 |  |                           } | 
  | 706 | 0 |                           return RESULTS_DEFAULT_MAX_COLUMN_LENGTH.intValue(); | 
  | 707 |  |                   } | 
  | 708 | 0 |                   return fieldDefinedMaxLength.intValue(); | 
  | 709 |  |           } | 
  | 710 |  |   | 
  | 711 |  |            | 
  | 712 |  |   | 
  | 713 |  |   | 
  | 714 |  |           public String getBackLocation() { | 
  | 715 | 0 |                   return backLocation; | 
  | 716 |  |           } | 
  | 717 |  |   | 
  | 718 |  |            | 
  | 719 |  |   | 
  | 720 |  |   | 
  | 721 |  |           public void setBackLocation(String backLocation) { | 
  | 722 | 0 |                   this.backLocation = backLocation; | 
  | 723 | 0 |           } | 
  | 724 |  |   | 
  | 725 |  |            | 
  | 726 |  |   | 
  | 727 |  |   | 
  | 728 |  |           public String getReturnLocation() { | 
  | 729 | 0 |                   return backLocation; | 
  | 730 |  |           } | 
  | 731 |  |   | 
  | 732 |  |            | 
  | 733 |  |   | 
  | 734 |  |   | 
  | 735 |  |   | 
  | 736 |  |   | 
  | 737 |  |           final public HtmlData getReturnUrl(BusinessObject businessObject, Map fieldConversions, String lookupImpl, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions){ | 
  | 738 | 0 |                   String href = getReturnHref(businessObject, fieldConversions, lookupImpl, returnKeys); | 
  | 739 | 0 |                   String returnUrlAnchorLabel = | 
  | 740 |  |                           KNSServiceLocator.getKualiConfigurationService().getPropertyString(TITLE_RETURN_URL_PREPENDTEXT_PROPERTY); | 
  | 741 | 0 |                   AnchorHtmlData anchor = new AnchorHtmlData(href, HtmlData.getTitleText(returnUrlAnchorLabel, businessObject, returnKeys, businessObjectRestrictions)); | 
  | 742 | 0 |                   anchor.setDisplayText(returnUrlAnchorLabel); | 
  | 743 | 0 |                   return anchor; | 
  | 744 |  |           } | 
  | 745 |  |   | 
  | 746 |  |            | 
  | 747 |  |   | 
  | 748 |  |   | 
  | 749 |  |   | 
  | 750 |  |   | 
  | 751 |  |   | 
  | 752 |  |   | 
  | 753 |  |   | 
  | 754 |  |   | 
  | 755 |  |   | 
  | 756 |  |           final protected String getReturnHref(BusinessObject businessObject, Map fieldConversions, String lookupImpl, List returnKeys) { | 
  | 757 | 0 |              if (StringUtils.isNotBlank(backLocation)) { | 
  | 758 | 0 |                   return UrlFactory.parameterizeUrl(backLocation, getParameters( | 
  | 759 |  |                                   businessObject, fieldConversions, lookupImpl, returnKeys)); | 
  | 760 |  |              } | 
  | 761 | 0 |              return ""; | 
  | 762 |  |           } | 
  | 763 |  |   | 
  | 764 |  |            | 
  | 765 |  |   | 
  | 766 |  |   | 
  | 767 |  |           public HtmlData getReturnUrl(BusinessObject businessObject, LookupForm lookupForm, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions) { | 
  | 768 | 0 |                   Properties parameters = getParameters( | 
  | 769 |  |                                   businessObject, lookupForm.getFieldConversions(), lookupForm.getLookupableImplServiceName(), returnKeys); | 
  | 770 | 0 |                   if(StringUtils.isEmpty(lookupForm.getHtmlDataType()) || HtmlData.ANCHOR_HTML_DATA_TYPE.equals(lookupForm.getHtmlDataType())) | 
  | 771 | 0 |                           return getReturnAnchorHtmlData(businessObject, parameters, lookupForm, returnKeys, businessObjectRestrictions); | 
  | 772 |  |                   else | 
  | 773 | 0 |                           return getReturnInputHtmlData(businessObject, parameters, lookupForm, returnKeys, businessObjectRestrictions); | 
  | 774 |  |           } | 
  | 775 |  |   | 
  | 776 |  |           protected HtmlData getReturnInputHtmlData(BusinessObject businessObject, Properties parameters, LookupForm lookupForm, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions){ | 
  | 777 | 0 |                   String returnUrlAnchorLabel = | 
  | 778 |  |                           KNSServiceLocator.getKualiConfigurationService().getPropertyString(TITLE_RETURN_URL_PREPENDTEXT_PROPERTY); | 
  | 779 | 0 |                   String name = KNSConstants.MULTIPLE_VALUE_LOOKUP_SELECTED_OBJ_ID_PARAM_PREFIX+lookupForm.getLookupObjectId(); | 
  | 780 | 0 |                   InputHtmlData input = new InputHtmlData(name, InputHtmlData.CHECKBOX_INPUT_TYPE); | 
  | 781 | 0 |                   input.setTitle(HtmlData.getTitleText(returnUrlAnchorLabel, businessObject, returnKeys, businessObjectRestrictions)); | 
  | 782 | 0 |                   if(((MultipleValueLookupForm)lookupForm).getCompositeObjectIdMap()==null || | 
  | 783 |  |                                   ((MultipleValueLookupForm)lookupForm).getCompositeObjectIdMap().get( | 
  | 784 |  |                                                   ((PersistableBusinessObject)businessObject).getObjectId())==null){ | 
  | 785 | 0 |                           input.setChecked(""); | 
  | 786 |  |                   } else{ | 
  | 787 | 0 |                           input.setChecked(InputHtmlData.CHECKBOX_CHECKED_VALUE); | 
  | 788 |  |                   } | 
  | 789 | 0 |                   input.setValue(InputHtmlData.CHECKBOX_CHECKED_VALUE); | 
  | 790 | 0 |                   return input; | 
  | 791 |  |           } | 
  | 792 |  |   | 
  | 793 |  |           protected HtmlData getReturnAnchorHtmlData(BusinessObject businessObject, Properties parameters, LookupForm lookupForm, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions){ | 
  | 794 | 0 |                   String returnUrlAnchorLabel = | 
  | 795 |  |                           KNSServiceLocator.getKualiConfigurationService().getPropertyString(TITLE_RETURN_URL_PREPENDTEXT_PROPERTY); | 
  | 796 | 0 |                   AnchorHtmlData anchor = new AnchorHtmlData( | 
  | 797 |  |                                   getReturnHref(parameters, lookupForm, returnKeys), | 
  | 798 |  |                                   HtmlData.getTitleText(returnUrlAnchorLabel, businessObject, returnKeys, businessObjectRestrictions)); | 
  | 799 | 0 |                   anchor.setDisplayText(returnUrlAnchorLabel); | 
  | 800 | 0 |                   return anchor; | 
  | 801 |  |           } | 
  | 802 |  |   | 
  | 803 |  |           protected String getReturnHref(Properties parameters, LookupForm lookupForm, List returnKeys) { | 
  | 804 | 0 |              if (StringUtils.isNotBlank(backLocation)) { | 
  | 805 | 0 |                   String href = UrlFactory.parameterizeUrl(backLocation, parameters); | 
  | 806 | 0 |                   return addToReturnHref(href, lookupForm); | 
  | 807 |  |              } | 
  | 808 | 0 |              return ""; | 
  | 809 |  |           } | 
  | 810 |  |   | 
  | 811 |  |           protected String addToReturnHref(String href, LookupForm lookupForm){ | 
  | 812 | 0 |                   String lookupAnchor = ""; | 
  | 813 | 0 |                   if (StringUtils.isNotEmpty(lookupForm.getAnchor())) { | 
  | 814 | 0 |                           lookupAnchor = lookupForm.getAnchor(); | 
  | 815 |  |                   } | 
  | 816 | 0 |                   href += "&anchor="+lookupAnchor+"&docNum="+(StringUtils.isEmpty(getDocNum())?"":getDocNum()); | 
  | 817 | 0 |                   return href; | 
  | 818 |  |           } | 
  | 819 |  |   | 
  | 820 |  |           protected Properties getParameters(BusinessObject bo, Map fieldConversions, String lookupImpl, List returnKeys) { | 
  | 821 | 0 |                   Properties parameters = new Properties(); | 
  | 822 | 0 |                   parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, KNSConstants.RETURN_METHOD_TO_CALL); | 
  | 823 | 0 |                   if ( getDocFormKey() != null ) { | 
  | 824 | 0 |                           parameters.put(KNSConstants.DOC_FORM_KEY, getDocFormKey()); | 
  | 825 |  |                   } | 
  | 826 | 0 |                   if ( lookupImpl != null ) { | 
  | 827 | 0 |                           parameters.put(KNSConstants.REFRESH_CALLER, lookupImpl); | 
  | 828 |  |                   } | 
  | 829 | 0 |                   if(getDocNum() != null){ | 
  | 830 | 0 |                           parameters.put(KNSConstants.DOC_NUM, getDocNum()); | 
  | 831 |  |                   } | 
  | 832 |  |   | 
  | 833 | 0 |                   if (getReferencesToRefresh() != null) { | 
  | 834 | 0 |                           parameters.put(KNSConstants.REFERENCES_TO_REFRESH, getReferencesToRefresh()); | 
  | 835 |  |                   } | 
  | 836 |  |   | 
  | 837 | 0 |                   Iterator returnKeysIt = getReturnKeys().iterator(); | 
  | 838 | 0 |                   while (returnKeysIt.hasNext()) { | 
  | 839 | 0 |                           String fieldNm = (String) returnKeysIt.next(); | 
  | 840 |  |   | 
  | 841 | 0 |                           Object fieldVal = ObjectUtils.getPropertyValue(bo, fieldNm); | 
  | 842 | 0 |                           if (fieldVal == null) { | 
  | 843 | 0 |                                   fieldVal = KNSConstants.EMPTY_STRING; | 
  | 844 |  |                           } | 
  | 845 |  |   | 
  | 846 | 0 |                           if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(businessObjectClass, fieldNm)) { | 
  | 847 |  |                                   try { | 
  | 848 | 0 |                                           fieldVal = getEncryptionService().encrypt(fieldVal) + EncryptionService.ENCRYPTION_POST_PREFIX; | 
  | 849 |  |                                   } | 
  | 850 | 0 |                                   catch (GeneralSecurityException e) { | 
  | 851 | 0 |                                           LOG.error("Exception while trying to encrypted value for inquiry framework.", e); | 
  | 852 | 0 |                                           throw new RuntimeException(e); | 
  | 853 | 0 |                                   } | 
  | 854 |  |   | 
  | 855 |  |                           } | 
  | 856 |  |   | 
  | 857 |  |                            | 
  | 858 | 0 |                           if (fieldVal instanceof Date) { | 
  | 859 | 0 |                                   DateFormatter dateFormatter = new DateFormatter(); | 
  | 860 | 0 |                                   fieldVal = dateFormatter.format(fieldVal); | 
  | 861 |  |              } | 
  | 862 |  |   | 
  | 863 | 0 |              if (fieldConversions.containsKey(fieldNm)) { | 
  | 864 | 0 |                  fieldNm = (String) fieldConversions.get(fieldNm); | 
  | 865 |  |                           } | 
  | 866 |  |   | 
  | 867 | 0 |                           parameters.put(fieldNm, fieldVal.toString()); | 
  | 868 | 0 |                   } | 
  | 869 |  |   | 
  | 870 | 0 |                   return parameters; | 
  | 871 |  |           } | 
  | 872 |  |   | 
  | 873 |  |            | 
  | 874 |  |   | 
  | 875 |  |   | 
  | 876 |  |           public List getReturnKeys() { | 
  | 877 |  |                   List returnKeys; | 
  | 878 | 0 |                   if (fieldConversions != null && !fieldConversions.isEmpty()) { | 
  | 879 | 0 |                           returnKeys = new ArrayList(fieldConversions.keySet()); | 
  | 880 |  |                   } | 
  | 881 |  |                   else { | 
  | 882 | 0 |                           returnKeys = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(getBusinessObjectClass()); | 
  | 883 |  |                   } | 
  | 884 |  |   | 
  | 885 | 0 |                   return returnKeys; | 
  | 886 |  |           } | 
  | 887 |  |   | 
  | 888 |  |            | 
  | 889 |  |   | 
  | 890 |  |   | 
  | 891 |  |   | 
  | 892 |  |           public String getDocFormKey() { | 
  | 893 | 0 |                   return docFormKey; | 
  | 894 |  |           } | 
  | 895 |  |   | 
  | 896 |  |            | 
  | 897 |  |   | 
  | 898 |  |   | 
  | 899 |  |   | 
  | 900 |  |           public void setDocFormKey(String docFormKey) { | 
  | 901 | 0 |                   this.docFormKey = docFormKey; | 
  | 902 | 0 |           } | 
  | 903 |  |   | 
  | 904 |  |            | 
  | 905 |  |   | 
  | 906 |  |   | 
  | 907 |  |           public void setFieldConversions(Map fieldConversions) { | 
  | 908 | 0 |                   this.fieldConversions = fieldConversions; | 
  | 909 | 0 |           } | 
  | 910 |  |   | 
  | 911 |  |            | 
  | 912 |  |   | 
  | 913 |  |   | 
  | 914 |  |   | 
  | 915 |  |           protected LookupService getLookupService() { | 
  | 916 | 0 |                   return lookupService != null ? lookupService : KNSServiceLocator.getLookupService(); | 
  | 917 |  |           } | 
  | 918 |  |   | 
  | 919 |  |            | 
  | 920 |  |   | 
  | 921 |  |   | 
  | 922 |  |   | 
  | 923 |  |           public void setLookupService(LookupService lookupService) { | 
  | 924 | 0 |                   this.lookupService = lookupService; | 
  | 925 | 0 |           } | 
  | 926 |  |   | 
  | 927 |  |            | 
  | 928 |  |   | 
  | 929 |  |   | 
  | 930 |  |   | 
  | 931 |  |   | 
  | 932 |  |           public List getDefaultSortColumns() { | 
  | 933 | 0 |                   return getBusinessObjectDictionaryService().getLookupDefaultSortFieldNames(getBusinessObjectClass()); | 
  | 934 |  |           } | 
  | 935 |  |   | 
  | 936 |  |            | 
  | 937 |  |   | 
  | 938 |  |   | 
  | 939 |  |   | 
  | 940 |  |   | 
  | 941 |  |           public void validateSearchParameters(Map fieldValues) { | 
  | 942 | 0 |                   List<String> lookupFieldAttributeList = null; | 
  | 943 | 0 |                   if(getBusinessObjectMetaDataService().isLookupable(getBusinessObjectClass())) { | 
  | 944 | 0 |                           lookupFieldAttributeList = getBusinessObjectMetaDataService().getLookupableFieldNames(getBusinessObjectClass()); | 
  | 945 |  |                   } | 
  | 946 | 0 |                   if (lookupFieldAttributeList == null) { | 
  | 947 | 0 |                           throw new RuntimeException("Lookup not defined for business object " + getBusinessObjectClass()); | 
  | 948 |  |                   } | 
  | 949 | 0 |                   for (Iterator iter = lookupFieldAttributeList.iterator(); iter.hasNext();) { | 
  | 950 | 0 |                           String attributeName = (String) iter.next(); | 
  | 951 | 0 |                           if (fieldValues.containsKey(attributeName)) { | 
  | 952 |  |                                    | 
  | 953 | 0 |                                   String attributeLabel = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), attributeName); | 
  | 954 |  |   | 
  | 955 | 0 |                                   String attributeValue = (String) fieldValues.get(attributeName); | 
  | 956 |  |   | 
  | 957 |  |                                    | 
  | 958 | 0 |                                   if (StringUtils.isBlank(attributeValue)) { | 
  | 959 | 0 |                                           if ((getBusinessObjectDictionaryService().getLookupAttributeRequired(getBusinessObjectClass(), attributeName)).booleanValue()) { | 
  | 960 | 0 |                          GlobalVariables.getMessageMap().putError(attributeName, RiceKeyConstants.ERROR_REQUIRED, attributeLabel); | 
  | 961 |  |                      } | 
  | 962 |  |                  } | 
  | 963 | 0 |                  validateSearchParameterWildcardAndOperators(attributeName, attributeValue); | 
  | 964 |  |              } | 
  | 965 | 0 |          } | 
  | 966 |  |   | 
  | 967 | 0 |          if (GlobalVariables.getMessageMap().hasErrors()) { | 
  | 968 | 0 |              throw new ValidationException("errors in search criteria"); | 
  | 969 |  |                                           } | 
  | 970 | 0 |                                   } | 
  | 971 |  |   | 
  | 972 |  |      protected void validateSearchParameterWildcardAndOperators(String attributeName, String attributeValue) { | 
  | 973 | 0 |              if (StringUtils.isBlank(attributeValue)) | 
  | 974 | 0 |                      return; | 
  | 975 |  |   | 
  | 976 |  |               | 
  | 977 | 0 |              boolean found = false; | 
  | 978 | 0 |                                                   for (int i = 0; i < KNSConstants.QUERY_CHARACTERS.length; i++) { | 
  | 979 | 0 |                                                           String queryCharacter = KNSConstants.QUERY_CHARACTERS[i]; | 
  | 980 |  |   | 
  | 981 | 0 |                                                           if (attributeValue.contains(queryCharacter)) { | 
  | 982 | 0 |                  found = true; | 
  | 983 |  |              } | 
  | 984 |  |                                                           } | 
  | 985 | 0 |          if (!found) | 
  | 986 | 0 |                  return; | 
  | 987 |  |   | 
  | 988 | 0 |              String attributeLabel = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), attributeName); | 
  | 989 | 0 |              if (getBusinessObjectDictionaryService().isLookupFieldTreatWildcardsAndOperatorsAsLiteral(businessObjectClass, attributeName)) { | 
  | 990 | 0 |                      BusinessObject example = null; | 
  | 991 |  |                      try { | 
  | 992 | 0 |                              example = (BusinessObject) businessObjectClass.newInstance(); | 
  | 993 |  |                                                   } | 
  | 994 | 0 |                      catch (Exception e) { | 
  | 995 | 0 |                              LOG.error("Exception caught instantiating " + businessObjectClass.getName(), e); | 
  | 996 | 0 |                              throw new RuntimeException("Cannot instantiate " + businessObjectClass.getName(), e); | 
  | 997 | 0 |                                           } | 
  | 998 |  |   | 
  | 999 | 0 |                      Class propertyType = ObjectUtils.getPropertyType(example, attributeName, getPersistenceStructureService()); | 
  | 1000 | 0 |                      if (TypeUtils.isIntegralClass(propertyType) || TypeUtils.isDecimalClass(propertyType) || TypeUtils.isTemporalClass(propertyType)) { | 
  | 1001 | 0 |                              GlobalVariables.getMessageMap().putError(attributeName, RiceKeyConstants.ERROR_WILDCARDS_AND_OPERATORS_NOT_ALLOWED_ON_FIELD, attributeLabel); | 
  | 1002 |  |                                   } | 
  | 1003 | 0 |                      if (TypeUtils.isStringClass(propertyType)) { | 
  | 1004 | 0 |                              GlobalVariables.getMessageMap().putInfo(attributeName, RiceKeyConstants.INFO_WILDCARDS_AND_OPERATORS_TREATED_LITERALLY, attributeLabel); | 
  | 1005 |  |                           } | 
  | 1006 | 0 |                   } | 
  | 1007 |  |              else { | 
  | 1008 | 0 |                      if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(businessObjectClass, attributeName)) { | 
  | 1009 | 0 |                          if (!attributeValue.endsWith(EncryptionService.ENCRYPTION_POST_PREFIX)) { | 
  | 1010 |  |                                   | 
  | 1011 |  |   | 
  | 1012 |  |                                   | 
  | 1013 |  |                                   | 
  | 1014 |  |   | 
  | 1015 | 0 |                      GlobalVariables.getMessageMap().putError(attributeName, RiceKeyConstants.ERROR_SECURE_FIELD, attributeLabel); | 
  | 1016 |  |                   } | 
  | 1017 |  |           } | 
  | 1018 |  |           } | 
  | 1019 | 0 |           } | 
  | 1020 |  |   | 
  | 1021 |  |           | 
  | 1022 |  |   | 
  | 1023 |  |   | 
  | 1024 |  |   | 
  | 1025 |  |          protected void setRows() { | 
  | 1026 | 0 |                  List<String> lookupFieldAttributeList = null; | 
  | 1027 | 0 |                  if (getBusinessObjectMetaDataService().isLookupable(getBusinessObjectClass())) { | 
  | 1028 | 0 |                          lookupFieldAttributeList = getBusinessObjectMetaDataService().getLookupableFieldNames( | 
  | 1029 |  |                                          getBusinessObjectClass()); | 
  | 1030 |  |                  } | 
  | 1031 | 0 |                  if (lookupFieldAttributeList == null) { | 
  | 1032 | 0 |                          throw new RuntimeException("Lookup not defined for business object " + getBusinessObjectClass()); | 
  | 1033 |  |                  } | 
  | 1034 |  |   | 
  | 1035 |  |                   | 
  | 1036 | 0 |                  List fields = new ArrayList(); | 
  | 1037 |  |                  try { | 
  | 1038 | 0 |                          fields = FieldUtils.createAndPopulateFieldsForLookup(lookupFieldAttributeList, getReadOnlyFieldsList(), | 
  | 1039 |  |                                          getBusinessObjectClass()); | 
  | 1040 | 0 |                  } catch (InstantiationException e) { | 
  | 1041 | 0 |                          throw new RuntimeException("Unable to create instance of business object class" + e.getMessage()); | 
  | 1042 | 0 |                  } catch (IllegalAccessException e) { | 
  | 1043 | 0 |                          throw new RuntimeException("Unable to create instance of business object class" + e.getMessage()); | 
  | 1044 | 0 |                  } | 
  | 1045 |  |   | 
  | 1046 | 0 |                  int numCols = getBusinessObjectDictionaryService().getLookupNumberOfColumns(this.getBusinessObjectClass()); | 
  | 1047 |  |                   | 
  | 1048 | 0 |                  this.rows = FieldUtils.wrapFields(fields, numCols); | 
  | 1049 | 0 |          } | 
  | 1050 |  |   | 
  | 1051 |  |           public List<Row> getRows() { | 
  | 1052 | 0 |                   return rows; | 
  | 1053 |  |           } | 
  | 1054 |  |   | 
  | 1055 |  |           public abstract List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues); | 
  | 1056 |  |            | 
  | 1057 |  |            | 
  | 1058 |  |   | 
  | 1059 |  |   | 
  | 1060 |  |   | 
  | 1061 |  |   | 
  | 1062 |  |   | 
  | 1063 |  |   | 
  | 1064 |  |           public List<? extends BusinessObject> getSearchResultsUnbounded(Map<String, String> fieldValues) { | 
  | 1065 | 0 |                   throw new UnsupportedOperationException("Lookupable helper services do not always support getSearchResultsUnbounded"); | 
  | 1066 |  |           } | 
  | 1067 |  |   | 
  | 1068 |  |           | 
  | 1069 |  |   | 
  | 1070 |  |   | 
  | 1071 |  |   | 
  | 1072 |  |   | 
  | 1073 |  |   | 
  | 1074 |  |   | 
  | 1075 |  |   | 
  | 1076 |  |          public Collection performLookup(LookupForm lookupForm, Collection resultTable, boolean bounded) { | 
  | 1077 | 0 |                  Map lookupFormFields = lookupForm.getFieldsForLookup(); | 
  | 1078 |  |   | 
  | 1079 | 0 |                  setBackLocation((String) lookupForm.getFieldsForLookup().get(KNSConstants.BACK_LOCATION)); | 
  | 1080 | 0 |                  setDocFormKey((String) lookupForm.getFieldsForLookup().get(KNSConstants.DOC_FORM_KEY)); | 
  | 1081 |  |                  Collection displayList; | 
  | 1082 |  |   | 
  | 1083 | 0 |                  preprocessDateFields(lookupFormFields); | 
  | 1084 |  |   | 
  | 1085 | 0 |                  Map fieldsForLookup = new HashMap(lookupForm.getFieldsForLookup()); | 
  | 1086 |  |                   | 
  | 1087 | 0 |                  if (bounded) { | 
  | 1088 | 0 |                          displayList = getSearchResults(lookupForm.getFieldsForLookup()); | 
  | 1089 |  |                  } else { | 
  | 1090 | 0 |                          displayList = getSearchResultsUnbounded(lookupForm.getFieldsForLookup()); | 
  | 1091 |  |                  } | 
  | 1092 |  |   | 
  | 1093 | 0 |                  boolean hasReturnableRow = false; | 
  | 1094 |  |   | 
  | 1095 | 0 |                  List returnKeys = getReturnKeys(); | 
  | 1096 | 0 |                  List pkNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(getBusinessObjectClass()); | 
  | 1097 | 0 |                  Person user = GlobalVariables.getUserSession().getPerson(); | 
  | 1098 |  |   | 
  | 1099 |  |                   | 
  | 1100 |  |                   | 
  | 1101 | 0 |                  for (Iterator iter = displayList.iterator(); iter.hasNext();) { | 
  | 1102 | 0 |                          BusinessObject element = (BusinessObject) iter.next(); | 
  | 1103 |  |   | 
  | 1104 | 0 |                          final String lookupId = KNSServiceLocator.getLookupResultsService().getLookupId(element); | 
  | 1105 | 0 |                          if (lookupId != null) { | 
  | 1106 | 0 |                                  lookupForm.setLookupObjectId(lookupId); | 
  | 1107 |  |                          } | 
  | 1108 |  |   | 
  | 1109 | 0 |                          BusinessObjectRestrictions businessObjectRestrictions = getBusinessObjectAuthorizationService() | 
  | 1110 |  |                                          .getLookupResultRestrictions(element, user); | 
  | 1111 |  |   | 
  | 1112 | 0 |                          HtmlData returnUrl = getReturnUrl(element, lookupForm, returnKeys, businessObjectRestrictions); | 
  | 1113 | 0 |                          String actionUrls = getActionUrls(element, pkNames, businessObjectRestrictions); | 
  | 1114 |  |                           | 
  | 1115 | 0 |                          if ("".equals(actionUrls)) { | 
  | 1116 | 0 |                                  actionUrls = ACTION_URLS_EMPTY; | 
  | 1117 |  |                          } | 
  | 1118 |  |   | 
  | 1119 | 0 |                          List<Column> columns = getColumns(); | 
  | 1120 | 0 |                          for (Iterator iterator = columns.iterator(); iterator.hasNext();) { | 
  | 1121 | 0 |                                  Column col = (Column) iterator.next(); | 
  | 1122 |  |                                   | 
  | 1123 | 0 |                                  String propValue = ObjectUtils.getFormattedPropertyValue(element, col.getPropertyName(), col.getFormatter()); | 
  | 1124 | 0 |                                  Class propClass = getPropertyClass(element, col.getPropertyName()); | 
  | 1125 |  |   | 
  | 1126 | 0 |                                  col.setComparator(CellComparatorHelper.getAppropriateComparatorForPropertyClass(propClass)); | 
  | 1127 | 0 |                                  col.setValueComparator(CellComparatorHelper.getAppropriateValueComparatorForPropertyClass(propClass)); | 
  | 1128 |  |   | 
  | 1129 | 0 |                                  String propValueBeforePotientalMasking = propValue; | 
  | 1130 | 0 |                                  propValue = maskValueIfNecessary(element.getClass(), col.getPropertyName(), propValue, | 
  | 1131 |  |                                                  businessObjectRestrictions); | 
  | 1132 | 0 |                                  col.setPropertyValue(propValue); | 
  | 1133 |  |   | 
  | 1134 |  |                                   | 
  | 1135 | 0 |                                  if (StringUtils.equals(propValueBeforePotientalMasking, propValue)) { | 
  | 1136 | 0 |                                          if (StringUtils.isNotBlank(col.getAlternateDisplayPropertyName())) { | 
  | 1137 | 0 |                                                  String alternatePropertyValue = ObjectUtils.getFormattedPropertyValue(element, col | 
  | 1138 |  |                                                                  .getAlternateDisplayPropertyName(), null); | 
  | 1139 | 0 |                                                  col.setPropertyValue(alternatePropertyValue); | 
  | 1140 |  |                                          } | 
  | 1141 |  |   | 
  | 1142 | 0 |                                          if (StringUtils.isNotBlank(col.getAdditionalDisplayPropertyName())) { | 
  | 1143 | 0 |                                                  String additionalPropertyValue = ObjectUtils.getFormattedPropertyValue(element, col | 
  | 1144 |  |                                                                  .getAdditionalDisplayPropertyName(), null); | 
  | 1145 | 0 |                                                  col.setPropertyValue(col.getPropertyValue() + " *-* " + additionalPropertyValue); | 
  | 1146 | 0 |                                          } | 
  | 1147 |  |                                  } | 
  | 1148 |  |                                  else { | 
  | 1149 | 0 |                                          col.setTotal(false); | 
  | 1150 |  |                                  } | 
  | 1151 |  |                                   | 
  | 1152 | 0 |                                  if (col.isTotal()) { | 
  | 1153 | 0 |                                          Object unformattedPropValue = ObjectUtils.getPropertyValue(element, col.getPropertyName()); | 
  | 1154 | 0 |                                          col.setUnformattedPropertyValue(unformattedPropValue); | 
  | 1155 |  |                                  } | 
  | 1156 |  |   | 
  | 1157 | 0 |                                  if (StringUtils.isNotBlank(propValue)) { | 
  | 1158 | 0 |                                          col.setColumnAnchor(getInquiryUrl(element, col.getPropertyName())); | 
  | 1159 |  |                                  } | 
  | 1160 | 0 |                          } | 
  | 1161 |  |   | 
  | 1162 | 0 |                          ResultRow row = new ResultRow(columns, returnUrl.constructCompleteHtmlTag(), actionUrls); | 
  | 1163 | 0 |                          row.setRowId(returnUrl.getName()); | 
  | 1164 | 0 |                          row.setReturnUrlHtmlData(returnUrl); | 
  | 1165 |  |   | 
  | 1166 |  |                           | 
  | 1167 |  |                           | 
  | 1168 |  |                           | 
  | 1169 |  |                           | 
  | 1170 | 0 |                          if (getBusinessObjectDictionaryService().isExportable(getBusinessObjectClass())) { | 
  | 1171 | 0 |                                  row.setBusinessObject(element); | 
  | 1172 |  |                          } | 
  | 1173 |  |   | 
  | 1174 | 0 |                          if (lookupId != null) { | 
  | 1175 | 0 |                                  row.setObjectId(lookupId); | 
  | 1176 |  |                          } | 
  | 1177 |  |   | 
  | 1178 | 0 |                          boolean rowReturnable = isResultReturnable(element); | 
  | 1179 | 0 |                          row.setRowReturnable(rowReturnable); | 
  | 1180 | 0 |                          if (rowReturnable) { | 
  | 1181 | 0 |                                  hasReturnableRow = true; | 
  | 1182 |  |                          } | 
  | 1183 | 0 |                          resultTable.add(row); | 
  | 1184 | 0 |                  } | 
  | 1185 |  |   | 
  | 1186 | 0 |                  lookupForm.setHasReturnableRow(hasReturnableRow); | 
  | 1187 |  |   | 
  | 1188 | 0 |                  return displayList; | 
  | 1189 |  |          } | 
  | 1190 |  |   | 
  | 1191 |  |           | 
  | 1192 |  |   | 
  | 1193 |  |   | 
  | 1194 |  |   | 
  | 1195 |  |   | 
  | 1196 |  |   | 
  | 1197 |  |   | 
  | 1198 |  |   | 
  | 1199 |  |   | 
  | 1200 |  |   | 
  | 1201 |  |          protected Class getPropertyClass(BusinessObject element, String propertyName) { | 
  | 1202 | 0 |                  Class propClass = null; | 
  | 1203 |  |   | 
  | 1204 |  |                  try { | 
  | 1205 | 0 |                          propClass = ObjectUtils.getPropertyType(element, propertyName, getPersistenceStructureService()); | 
  | 1206 |  |   | 
  | 1207 | 0 |                  } catch (Exception e) { | 
  | 1208 | 0 |                          throw new RuntimeException("Cannot access PropertyType for property " + "'" + propertyName + "' " | 
  | 1209 |  |                                          + " on an instance of '" + element.getClass().getName() + "'.", e); | 
  | 1210 | 0 |                  } | 
  | 1211 |  |   | 
  | 1212 | 0 |                  return propClass; | 
  | 1213 |  |          } | 
  | 1214 |  |   | 
  | 1215 |  |            | 
  | 1216 |  |   | 
  | 1217 |  |   | 
  | 1218 |  |   | 
  | 1219 |  |   | 
  | 1220 |  |   | 
  | 1221 |  |           protected Map<String,String> preprocessDateFields(Map lookupFormFields) { | 
  | 1222 | 0 |                   Map<String,String> fieldsToUpdate = new HashMap<String,String>(); | 
  | 1223 | 0 |                   Set<String> fieldsForLookup = lookupFormFields.keySet(); | 
  | 1224 | 0 |                   for (String propName : fieldsForLookup) { | 
  | 1225 | 0 |                           if(propName.startsWith(KNSConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX)) { | 
  | 1226 | 0 |                                   String fromDateValue = (String)lookupFormFields.get(propName); | 
  | 1227 | 0 |                                   String dateFieldName = StringUtils.remove(propName, KNSConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX); | 
  | 1228 | 0 |                                   String dateValue = (String)lookupFormFields.get(dateFieldName); | 
  | 1229 | 0 |                                   String newPropValue = dateValue; | 
  | 1230 | 0 |                                   if(StringUtils.isNotEmpty(fromDateValue) && StringUtils.isNotEmpty(dateValue)) { | 
  | 1231 | 0 |                                          newPropValue = fromDateValue + KNSConstants.BETWEEN_OPERATOR + dateValue; | 
  | 1232 | 0 |                                   } else if(StringUtils.isNotEmpty(fromDateValue) && StringUtils.isEmpty(dateValue)) { | 
  | 1233 | 0 |                                           newPropValue = ">="+fromDateValue; | 
  | 1234 | 0 |                                   } else if(StringUtils.isNotEmpty(dateValue) && StringUtils.isEmpty(fromDateValue)) { | 
  | 1235 | 0 |                                           newPropValue = "<="+dateValue; | 
  | 1236 |  |                                   }  | 
  | 1237 |  |   | 
  | 1238 | 0 |                                   fieldsToUpdate.put(dateFieldName, newPropValue); | 
  | 1239 | 0 |                           } | 
  | 1240 |  |                   } | 
  | 1241 |  |                    | 
  | 1242 | 0 |                   Set<String> keysToUpdate = fieldsToUpdate.keySet(); | 
  | 1243 | 0 |                   for (String updateKey : keysToUpdate) { | 
  | 1244 | 0 |                           lookupFormFields.put(updateKey, fieldsToUpdate.get(updateKey)); | 
  | 1245 |  |                   } | 
  | 1246 | 0 |                   return fieldsToUpdate; | 
  | 1247 |  |           } | 
  | 1248 |  |   | 
  | 1249 |  |           protected String maskValueIfNecessary(Class businessObjectClass, String propertyName, String propertyValue, BusinessObjectRestrictions businessObjectRestrictions) { | 
  | 1250 | 0 |                   String maskedPropertyValue = propertyValue; | 
  | 1251 | 0 |                   if (businessObjectRestrictions != null) { | 
  | 1252 | 0 |                           FieldRestriction fieldRestriction = businessObjectRestrictions.getFieldRestriction(propertyName); | 
  | 1253 | 0 |                           if (fieldRestriction != null && (fieldRestriction.isMasked() || fieldRestriction.isPartiallyMasked())) { | 
  | 1254 | 0 |                                   maskedPropertyValue = fieldRestriction.getMaskFormatter().maskValue(propertyValue); | 
  | 1255 |  |                           } | 
  | 1256 |  |                   } | 
  | 1257 | 0 |                   return maskedPropertyValue; | 
  | 1258 |  |           } | 
  | 1259 |  |   | 
  | 1260 |  |   | 
  | 1261 |  |           protected void setReferencesToRefresh(String referencesToRefresh) { | 
  | 1262 | 0 |                   this.referencesToRefresh = referencesToRefresh; | 
  | 1263 | 0 |           } | 
  | 1264 |  |   | 
  | 1265 |  |           public String getReferencesToRefresh() { | 
  | 1266 | 0 |                   return referencesToRefresh; | 
  | 1267 |  |           } | 
  | 1268 |  |   | 
  | 1269 |  |           protected SequenceAccessorService getSequenceAccessorService() { | 
  | 1270 | 0 |                   return sequenceAccessorService != null ? sequenceAccessorService : KNSServiceLocator.getSequenceAccessorService(); | 
  | 1271 |  |           } | 
  | 1272 |  |   | 
  | 1273 |  |           public void setSequenceAccessorService(SequenceAccessorService sequenceAccessorService) { | 
  | 1274 | 0 |                   this.sequenceAccessorService = sequenceAccessorService; | 
  | 1275 | 0 |           } | 
  | 1276 |  |   | 
  | 1277 |  |           public BusinessObjectService getBusinessObjectService() { | 
  | 1278 | 0 |                   return businessObjectService != null ? businessObjectService : KNSServiceLocator.getBusinessObjectService(); | 
  | 1279 |  |           } | 
  | 1280 |  |   | 
  | 1281 |  |           public void setBusinessObjectService(BusinessObjectService businessObjectService) { | 
  | 1282 | 0 |                   this.businessObjectService = businessObjectService; | 
  | 1283 | 0 |           } | 
  | 1284 |  |   | 
  | 1285 |  |           protected LookupResultsService getLookupResultsService() { | 
  | 1286 | 0 |                   return lookupResultsService != null ? lookupResultsService : KNSServiceLocator.getLookupResultsService(); | 
  | 1287 |  |           } | 
  | 1288 |  |   | 
  | 1289 |  |           public void setLookupResultsService(LookupResultsService lookupResultsService) { | 
  | 1290 | 0 |                   this.lookupResultsService = lookupResultsService; | 
  | 1291 | 0 |           } | 
  | 1292 |  |   | 
  | 1293 |  |            | 
  | 1294 |  |   | 
  | 1295 |  |   | 
  | 1296 |  |   | 
  | 1297 |  |           public boolean isSearchUsingOnlyPrimaryKeyValues() { | 
  | 1298 |  |                    | 
  | 1299 | 0 |                   return false; | 
  | 1300 |  |           } | 
  | 1301 |  |   | 
  | 1302 |  |            | 
  | 1303 |  |   | 
  | 1304 |  |   | 
  | 1305 |  |   | 
  | 1306 |  |   | 
  | 1307 |  |   | 
  | 1308 |  |           public String getPrimaryKeyFieldLabels() { | 
  | 1309 | 0 |                   return KNSConstants.NOT_AVAILABLE_STRING; | 
  | 1310 |  |           } | 
  | 1311 |  |   | 
  | 1312 |  |            | 
  | 1313 |  |   | 
  | 1314 |  |   | 
  | 1315 |  |           public boolean isResultReturnable(BusinessObject object) { | 
  | 1316 | 0 |                   return true; | 
  | 1317 |  |           } | 
  | 1318 |  |   | 
  | 1319 |  |            | 
  | 1320 |  |   | 
  | 1321 |  |   | 
  | 1322 |  |   | 
  | 1323 |  |   | 
  | 1324 |  |   | 
  | 1325 |  |           public void performClear(LookupForm lookupForm) { | 
  | 1326 | 0 |                   for (Iterator iter = this.getRows().iterator(); iter.hasNext();) { | 
  | 1327 | 0 |                           Row row = (Row) iter.next(); | 
  | 1328 | 0 |                           for (Iterator iterator = row.getFields().iterator(); iterator.hasNext();) { | 
  | 1329 | 0 |                                   Field field = (Field) iterator.next(); | 
  | 1330 | 0 |                                   if (field.isSecure()) { | 
  | 1331 | 0 |                                           field.setSecure(false); | 
  | 1332 | 0 |                                           field.setDisplayMaskValue(null); | 
  | 1333 | 0 |                                           field.setEncryptedValue(null); | 
  | 1334 |  |                                   } | 
  | 1335 |  |   | 
  | 1336 | 0 |                                  if (!field.getFieldType().equals(Field.RADIO)) { | 
  | 1337 | 0 |                                          field.setPropertyValue(field.getDefaultValue()); | 
  | 1338 |  |                                  } | 
  | 1339 | 0 |                          } | 
  | 1340 | 0 |                   } | 
  | 1341 | 0 |           } | 
  | 1342 |  |   | 
  | 1343 |  |            | 
  | 1344 |  |   | 
  | 1345 |  |   | 
  | 1346 |  |   | 
  | 1347 |  |           public boolean shouldDisplayHeaderNonMaintActions() { | 
  | 1348 | 0 |                   return true; | 
  | 1349 |  |           } | 
  | 1350 |  |   | 
  | 1351 |  |            | 
  | 1352 |  |   | 
  | 1353 |  |   | 
  | 1354 |  |           public boolean shouldDisplayLookupCriteria() { | 
  | 1355 | 0 |                   return true; | 
  | 1356 |  |           } | 
  | 1357 |  |   | 
  | 1358 |  |            | 
  | 1359 |  |   | 
  | 1360 |  |   | 
  | 1361 |  |           public String getSupplementalMenuBar() { | 
  | 1362 | 0 |                   return new String(); | 
  | 1363 |  |           } | 
  | 1364 |  |   | 
  | 1365 |  |            | 
  | 1366 |  |   | 
  | 1367 |  |   | 
  | 1368 |  |           public String getTitle() { | 
  | 1369 | 0 |                   return getBusinessObjectDictionaryService().getLookupTitle(getBusinessObjectClass()); | 
  | 1370 |  |           } | 
  | 1371 |  |   | 
  | 1372 |  |            | 
  | 1373 |  |   | 
  | 1374 |  |   | 
  | 1375 |  |           public boolean performCustomAction(boolean ignoreErrors) { | 
  | 1376 | 0 |                   return false;                 | 
  | 1377 |  |           } | 
  | 1378 |  |   | 
  | 1379 |  |            | 
  | 1380 |  |   | 
  | 1381 |  |   | 
  | 1382 |  |           public Field getExtraField() { | 
  | 1383 | 0 |                   return null; | 
  | 1384 |  |           } | 
  | 1385 |  |   | 
  | 1386 |  |           public boolean allowsNewOrCopyAction(String documentTypeName){ | 
  | 1387 | 0 |                   throw new UnsupportedOperationException("Function not supported."); | 
  | 1388 |  |           } | 
  | 1389 |  |   | 
  | 1390 |  |            | 
  | 1391 |  |   | 
  | 1392 |  |   | 
  | 1393 |  |   | 
  | 1394 |  |   | 
  | 1395 |  |           public void applyFieldAuthorizationsFromNestedLookups(Field field) { | 
  | 1396 | 0 |                   if(!Field.MULTI_VALUE_FIELD_TYPES.contains(field.getFieldType())) { | 
  | 1397 | 0 |                           if (field.getPropertyValue() != null && field.getPropertyValue().endsWith(EncryptionService.ENCRYPTION_POST_PREFIX)) { | 
  | 1398 | 0 |                                   if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(businessObjectClass, field.getPropertyName())) { | 
  | 1399 | 0 |                                           AttributeSecurity attributeSecurity = getDataDictionaryService().getAttributeSecurity(businessObjectClass.getName(), field.getPropertyName()); | 
  | 1400 | 0 |                                           Person user = GlobalVariables.getUserSession().getPerson(); | 
  | 1401 |  |                                           String decryptedValue; | 
  | 1402 |  |                                           try { | 
  | 1403 | 0 |                                                   String cipherText = StringUtils.removeEnd(field.getPropertyValue(), EncryptionService.ENCRYPTION_POST_PREFIX); | 
  | 1404 | 0 |                                                   decryptedValue = getEncryptionService().decrypt(cipherText); | 
  | 1405 | 0 |                                           } catch (GeneralSecurityException e) { | 
  | 1406 | 0 |                                                   throw new RuntimeException("Error decrypting value for business object " + businessObjectClass + " attribute " + field.getPropertyName(), e); | 
  | 1407 | 0 |                                           } | 
  | 1408 | 0 |                                           if (attributeSecurity.isMask() && !getBusinessObjectAuthorizationService().canFullyUnmaskField(user, | 
  | 1409 |  |                                                          businessObjectClass, field.getPropertyName(),null)) { | 
  | 1410 | 0 |                                                   MaskFormatter maskFormatter = attributeSecurity.getMaskFormatter(); | 
  | 1411 | 0 |                                                   field.setEncryptedValue(field.getPropertyValue()); | 
  | 1412 | 0 |                                                   field.setDisplayMaskValue(maskFormatter.maskValue(decryptedValue)); | 
  | 1413 | 0 |                                                   field.setSecure(true); | 
  | 1414 | 0 |                                           } | 
  | 1415 | 0 |                                           else if (attributeSecurity.isPartialMask() && !getBusinessObjectAuthorizationService().canPartiallyUnmaskField(user, | 
  | 1416 |  |                                                          businessObjectClass, field.getPropertyName(),null)) { | 
  | 1417 | 0 |                                                   MaskFormatter maskFormatter = attributeSecurity.getPartialMaskFormatter(); | 
  | 1418 | 0 |                                                   field.setEncryptedValue(field.getPropertyValue()); | 
  | 1419 | 0 |                                                   field.setDisplayMaskValue(maskFormatter.maskValue(decryptedValue)); | 
  | 1420 | 0 |                                                   field.setSecure(true); | 
  | 1421 | 0 |                                           } | 
  | 1422 |  |                                           else { | 
  | 1423 | 0 |                                                   field.setPropertyValue(LookupUtils.forceUppercase(businessObjectClass, field.getPropertyName(), decryptedValue)); | 
  | 1424 |  |                                           } | 
  | 1425 | 0 |                                   } | 
  | 1426 |  |                                   else { | 
  | 1427 | 0 |                                           throw new RuntimeException("Field " + field.getPersonNameAttributeName() + " was encrypted on " + businessObjectClass.getName() + | 
  | 1428 |  |                                           " lookup was encrypted when it should not have been encrypted according to the data dictionary."); | 
  | 1429 |  |                                   } | 
  | 1430 |  |                           } | 
  | 1431 |  |                   } else { | 
  | 1432 | 0 |                          if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(businessObjectClass, field.getPropertyName())) { | 
  | 1433 | 0 |                                  LOG.error("Cannot handle multiple value field types that have field authorizations, please implement custom lookupable helper service"); | 
  | 1434 | 0 |                                  throw new RuntimeException("Cannot handle multiple value field types that have field authorizations."); | 
  | 1435 |  |                          } | 
  | 1436 |  |                   } | 
  | 1437 | 0 |           } | 
  | 1438 |  |   | 
  | 1439 |  |           | 
  | 1440 |  |   | 
  | 1441 |  |   | 
  | 1442 |  |   | 
  | 1443 |  |   | 
  | 1444 |  |   | 
  | 1445 |  |   | 
  | 1446 |  |   | 
  | 1447 |  |   | 
  | 1448 |  |   | 
  | 1449 |  |          public void applyConditionalLogicForFieldDisplay() { | 
  | 1450 | 0 |                  Set<String> readOnlyFields = getConditionallyReadOnlyPropertyNames(); | 
  | 1451 | 0 |                  Set<String> requiredFields = getConditionallyRequiredPropertyNames(); | 
  | 1452 | 0 |                  Set<String> hiddenFields = getConditionallyHiddenPropertyNames(); | 
  | 1453 |  |   | 
  | 1454 | 0 |                  for (Iterator iter = this.getRows().iterator(); iter.hasNext();) { | 
  | 1455 | 0 |                          Row row = (Row) iter.next(); | 
  | 1456 | 0 |                          for (Iterator iterator = row.getFields().iterator(); iterator.hasNext();) { | 
  | 1457 | 0 |                                  Field field = (Field) iterator.next(); | 
  | 1458 |  |   | 
  | 1459 | 0 |                                  if (readOnlyFields != null && readOnlyFields.contains(field.getPropertyName())) { | 
  | 1460 | 0 |                                          field.setReadOnly(true); | 
  | 1461 |  |                                  } | 
  | 1462 |  |   | 
  | 1463 | 0 |                                  if (requiredFields != null && requiredFields.contains(field.getPropertyName())) { | 
  | 1464 | 0 |                                          field.setFieldRequired(true); | 
  | 1465 |  |                                  } | 
  | 1466 |  |   | 
  | 1467 | 0 |                                  if (hiddenFields != null && hiddenFields.contains(field.getPropertyName())) { | 
  | 1468 | 0 |                                          field.setFieldType(Field.HIDDEN); | 
  | 1469 |  |                                  } | 
  | 1470 | 0 |                          } | 
  | 1471 | 0 |                  } | 
  | 1472 | 0 |          } | 
  | 1473 |  |           | 
  | 1474 |  |           | 
  | 1475 |  |   | 
  | 1476 |  |   | 
  | 1477 |  |   | 
  | 1478 |  |   | 
  | 1479 |  |          public Set<String> getConditionallyReadOnlyPropertyNames() { | 
  | 1480 | 0 |                  return new HashSet<String>(); | 
  | 1481 |  |          } | 
  | 1482 |  |   | 
  | 1483 |  |           | 
  | 1484 |  |   | 
  | 1485 |  |   | 
  | 1486 |  |   | 
  | 1487 |  |   | 
  | 1488 |  |          public Set<String> getConditionallyRequiredPropertyNames() { | 
  | 1489 | 0 |                  return new HashSet<String>(); | 
  | 1490 |  |          } | 
  | 1491 |  |   | 
  | 1492 |  |           | 
  | 1493 |  |   | 
  | 1494 |  |   | 
  | 1495 |  |   | 
  | 1496 |  |   | 
  | 1497 |  |          public Set<String> getConditionallyHiddenPropertyNames() { | 
  | 1498 | 0 |                  return new HashSet<String>(); | 
  | 1499 |  |          } | 
  | 1500 |  |            | 
  | 1501 |  |           | 
  | 1502 |  |   | 
  | 1503 |  |   | 
  | 1504 |  |   | 
  | 1505 |  |   | 
  | 1506 |  |   | 
  | 1507 |  |   | 
  | 1508 |  |   | 
  | 1509 |  |          protected String getCurrentSearchFieldValue(String propertyName) { | 
  | 1510 | 0 |                  String currentValue = null; | 
  | 1511 |  |   | 
  | 1512 | 0 |                  boolean fieldFound = false; | 
  | 1513 | 0 |                  for (Iterator iter = this.getRows().iterator(); iter.hasNext();) { | 
  | 1514 | 0 |                          Row row = (Row) iter.next(); | 
  | 1515 | 0 |                          for (Iterator iterator = row.getFields().iterator(); iterator.hasNext();) { | 
  | 1516 | 0 |                                  Field field = (Field) iterator.next(); | 
  | 1517 |  |   | 
  | 1518 | 0 |                                  if (StringUtils.equalsIgnoreCase(propertyName, field.getPropertyName())) { | 
  | 1519 | 0 |                                          if (Field.MULTI_VALUE_FIELD_TYPES.contains(field.getFieldType())) { | 
  | 1520 | 0 |                                                  currentValue = StringUtils.join(field.getPropertyValues(), ";"); | 
  | 1521 |  |                                          } else { | 
  | 1522 | 0 |                                                  currentValue = field.getPropertyValue(); | 
  | 1523 |  |                                          } | 
  | 1524 | 0 |                                          fieldFound = true; | 
  | 1525 |  |                                  } | 
  | 1526 |  |   | 
  | 1527 | 0 |                                  if (fieldFound) { | 
  | 1528 | 0 |                                          break; | 
  | 1529 |  |                                  } | 
  | 1530 | 0 |                          } | 
  | 1531 |  |   | 
  | 1532 | 0 |                          if (fieldFound) { | 
  | 1533 | 0 |                                  break; | 
  | 1534 |  |                          } | 
  | 1535 | 0 |                  } | 
  | 1536 |  |   | 
  | 1537 | 0 |                  return currentValue; | 
  | 1538 |  |          } | 
  | 1539 |  |  } |