| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  package org.kuali.rice.kns.web.ui; | 
  | 17 |  |   | 
  | 18 |  |  import org.apache.commons.lang.StringUtils; | 
  | 19 |  |  import org.kuali.rice.core.api.util.ClassLoaderUtils; | 
  | 20 |  |  import org.kuali.rice.core.api.util.KeyValue; | 
  | 21 |  |  import org.kuali.rice.core.web.format.Formatter; | 
  | 22 |  |  import org.kuali.rice.kns.datadictionary.CollectionDefinitionI; | 
  | 23 |  |  import org.kuali.rice.kns.datadictionary.FieldDefinition; | 
  | 24 |  |  import org.kuali.rice.kns.datadictionary.FieldDefinitionI; | 
  | 25 |  |  import org.kuali.rice.kns.datadictionary.MaintainableCollectionDefinition; | 
  | 26 |  |  import org.kuali.rice.kns.datadictionary.MaintainableFieldDefinition; | 
  | 27 |  |  import org.kuali.rice.kns.datadictionary.MaintainableItemDefinition; | 
  | 28 |  |  import org.kuali.rice.kns.datadictionary.MaintainableSectionDefinition; | 
  | 29 |  |  import org.kuali.rice.kns.lookup.LookupUtils; | 
  | 30 |  |  import org.kuali.rice.kns.maintenance.Maintainable; | 
  | 31 |  |  import org.kuali.rice.kns.service.KNSServiceLocator; | 
  | 32 |  |  import org.kuali.rice.kns.service.MaintenanceDocumentDictionaryService; | 
  | 33 |  |  import org.kuali.rice.kns.util.FieldUtils; | 
  | 34 |  |  import org.kuali.rice.kns.util.MaintenanceUtils; | 
  | 35 |  |  import org.kuali.rice.krad.bo.BusinessObject; | 
  | 36 |  |  import org.kuali.rice.krad.datadictionary.control.ControlDefinition; | 
  | 37 |  |  import org.kuali.rice.krad.keyvalues.KeyValuesFinder; | 
  | 38 |  |  import org.kuali.rice.krad.keyvalues.PersistableBusinessObjectValuesFinder; | 
  | 39 |  |  import org.kuali.rice.krad.service.BusinessObjectDictionaryService; | 
  | 40 |  |  import org.kuali.rice.krad.service.DataDictionaryService; | 
  | 41 |  |  import org.kuali.rice.krad.service.KRADServiceLocator; | 
  | 42 |  |  import org.kuali.rice.krad.service.KRADServiceLocatorWeb; | 
  | 43 |  |  import org.kuali.rice.krad.service.PersistenceStructureService; | 
  | 44 |  |  import org.kuali.rice.krad.util.KRADConstants; | 
  | 45 |  |  import org.kuali.rice.krad.util.ObjectUtils; | 
  | 46 |  |   | 
  | 47 |  |  import java.util.ArrayList; | 
  | 48 |  |  import java.util.Collection; | 
  | 49 |  |  import java.util.List; | 
  | 50 |  |  import java.util.Set; | 
  | 51 |  |   | 
  | 52 |  |  @Deprecated | 
  | 53 | 0 |  public class FieldBridge { | 
  | 54 | 0 |      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(FieldBridge.class); | 
  | 55 |  |      private static DataDictionaryService dataDictionaryService; | 
  | 56 |  |      private static PersistenceStructureService persistenceStructureService; | 
  | 57 |  |      private static BusinessObjectDictionaryService businessObjectDictionaryService; | 
  | 58 |  |      private static MaintenanceDocumentDictionaryService maintenanceDocumentDictionaryService; | 
  | 59 |  |   | 
  | 60 |  |       | 
  | 61 |  |   | 
  | 62 |  |   | 
  | 63 |  |   | 
  | 64 |  |   | 
  | 65 |  |   | 
  | 66 |  |      public static final void setupField(Field field, FieldDefinitionI definition, Set<String> conditionallyRequiredMaintenanceFields) { | 
  | 67 | 0 |          if (definition instanceof MaintainableFieldDefinition) { | 
  | 68 | 0 |              MaintainableFieldDefinition maintainableFieldDefinition = ((MaintainableFieldDefinition) definition); | 
  | 69 |  |               | 
  | 70 | 0 |              field.setFieldRequired(maintainableFieldDefinition.isRequired()); | 
  | 71 | 0 |              field.setReadOnly(maintainableFieldDefinition.isUnconditionallyReadOnly()); | 
  | 72 | 0 |              if (maintainableFieldDefinition.isLookupReadOnly()) { | 
  | 73 | 0 |                      field.setFieldType(Field.LOOKUP_READONLY); | 
  | 74 |  |              } | 
  | 75 |  |   | 
  | 76 |  |               | 
  | 77 | 0 |              if (StringUtils.isNotBlank(maintainableFieldDefinition.getWebUILeaveFieldFunction())) { | 
  | 78 | 0 |                  field.setWebOnBlurHandler(maintainableFieldDefinition.getWebUILeaveFieldFunction()); | 
  | 79 |  |              } | 
  | 80 |  |   | 
  | 81 | 0 |              if (StringUtils.isNotBlank(maintainableFieldDefinition.getWebUILeaveFieldCallbackFunction())) { | 
  | 82 | 0 |                  field.setWebOnBlurHandlerCallback(maintainableFieldDefinition.getWebUILeaveFieldCallbackFunction()); | 
  | 83 |  |              } | 
  | 84 |  |   | 
  | 85 | 0 |              if (maintainableFieldDefinition.getWebUILeaveFieldFunctionParameters()!=null) { | 
  | 86 | 0 |                  field.setWebUILeaveFieldFunctionParameters(maintainableFieldDefinition.getWebUILeaveFieldFunctionParameters()); | 
  | 87 |  |              } | 
  | 88 |  |               | 
  | 89 | 0 |                          if (StringUtils.isNotBlank(maintainableFieldDefinition.getAlternateDisplayAttributeName())) { | 
  | 90 | 0 |                                  field.setAlternateDisplayPropertyName(maintainableFieldDefinition.getAlternateDisplayAttributeName()); | 
  | 91 |  |                          } | 
  | 92 |  |   | 
  | 93 | 0 |                          if (StringUtils.isNotBlank(maintainableFieldDefinition.getAdditionalDisplayAttributeName())) { | 
  | 94 | 0 |                                  field.setAdditionalDisplayPropertyName(maintainableFieldDefinition.getAdditionalDisplayAttributeName()); | 
  | 95 |  |                          } | 
  | 96 |  |               | 
  | 97 | 0 |              if (conditionallyRequiredMaintenanceFields != null && conditionallyRequiredMaintenanceFields.contains(field.getPropertyName())) { | 
  | 98 | 0 |                      field.setFieldRequired(true); | 
  | 99 |  |              } | 
  | 100 |  |               | 
  | 101 | 0 |              if (((MaintainableFieldDefinition) definition).isTriggerOnChange()) { | 
  | 102 | 0 |                      field.setTriggerOnChange(true); | 
  | 103 |  |              } | 
  | 104 |  |          } | 
  | 105 | 0 |      } | 
  | 106 |  |   | 
  | 107 |  |       | 
  | 108 |  |   | 
  | 109 |  |   | 
  | 110 |  |   | 
  | 111 |  |   | 
  | 112 |  |   | 
  | 113 |  |   | 
  | 114 |  |   | 
  | 115 |  |   | 
  | 116 |  |      public static final void populateFieldFromBusinessObject(Field field, BusinessObject bo) { | 
  | 117 | 0 |          if (bo == null) { | 
  | 118 | 0 |              throw new RuntimeException("Inquiry Business object is null."); | 
  | 119 |  |          } | 
  | 120 |  |   | 
  | 121 | 0 |          field.setReadOnly(true);  | 
  | 122 |  |   | 
  | 123 | 0 |          Formatter formatter = field.getFormatter(); | 
  | 124 | 0 |          String propertyName = field.getPropertyName(); | 
  | 125 |  |   | 
  | 126 |  |           | 
  | 127 | 0 |                  ControlDefinition fieldControl = getDataDictionaryService().getAttributeControlDefinition(bo.getClass(), | 
  | 128 |  |                                  propertyName); | 
  | 129 |  |          try { | 
  | 130 | 0 |              Object prop = ObjectUtils.getPropertyValue(bo, field.getPropertyName()); | 
  | 131 |  |   | 
  | 132 |  |                           | 
  | 133 |  |                           | 
  | 134 | 0 |                          String propValue = KRADConstants.EMPTY_STRING; | 
  | 135 | 0 |                          if (fieldControl != null && fieldControl.isSelect() | 
  | 136 |  |                                          && StringUtils.isBlank(field.getAdditionalDisplayPropertyName()) | 
  | 137 |  |                                          && StringUtils.isBlank(field.getAlternateDisplayPropertyName())) { | 
  | 138 | 0 |                                  Class<? extends KeyValuesFinder> keyValuesFinderName = ClassLoaderUtils.getClass(fieldControl.getValuesFinderClass(), KeyValuesFinder.class); | 
  | 139 | 0 |                  KeyValuesFinder finder = keyValuesFinderName.newInstance(); | 
  | 140 |  |   | 
  | 141 | 0 |                  propValue = lookupFinderValue(fieldControl, prop, finder); | 
  | 142 | 0 |              } else { | 
  | 143 | 0 |                                  propValue = ObjectUtils.getFormattedPropertyValue(bo, field.getPropertyName(), formatter); | 
  | 144 |  |                      } | 
  | 145 | 0 |                          field.setPropertyValue(propValue); | 
  | 146 |  |                           | 
  | 147 |  |                           | 
  | 148 |  |                           | 
  | 149 | 0 |                          if (StringUtils.isNotBlank(field.getAlternateDisplayPropertyName())) { | 
  | 150 | 0 |                                  String alternatePropertyValue = ObjectUtils.getFormattedPropertyValueUsingDataDictionary(bo, field | 
  | 151 |  |                                                  .getAlternateDisplayPropertyName()); | 
  | 152 | 0 |                                  field.setAlternateDisplayPropertyValue(alternatePropertyValue); | 
  | 153 |  |                  } | 
  | 154 |  |   | 
  | 155 | 0 |                          if (StringUtils.isNotBlank(field.getAdditionalDisplayPropertyName())) { | 
  | 156 | 0 |                                  String additionalPropertyValue = ObjectUtils.getFormattedPropertyValueUsingDataDictionary(bo, field | 
  | 157 |  |                                                  .getAdditionalDisplayPropertyName()); | 
  | 158 | 0 |                                  field.setAdditionalDisplayPropertyValue(additionalPropertyValue); | 
  | 159 |  |              } | 
  | 160 |  |   | 
  | 161 |  |                           | 
  | 162 |  |                           | 
  | 163 | 0 |              if ( fieldControl != null && fieldControl.isKualiUser() ) { | 
  | 164 |  |                       | 
  | 165 |  |                      try { | 
  | 166 | 0 |                              if ( StringUtils.isNotBlank(field.getUniversalIdAttributeName()) ) { | 
  | 167 | 0 |                                      Object principalId = ObjectUtils.getNestedValue(bo, field.getUniversalIdAttributeName()); | 
  | 168 | 0 |                                      if ( principalId != null ) { | 
  | 169 | 0 |                                              field.setUniversalIdValue(principalId.toString()); | 
  | 170 |  |                                      } | 
  | 171 |  |                              } | 
  | 172 | 0 |                              if ( StringUtils.isNotBlank(field.getPersonNameAttributeName()) ) { | 
  | 173 | 0 |                                      Object personName = ObjectUtils.getNestedValue(bo, field.getPersonNameAttributeName()); | 
  | 174 | 0 |                                      if ( personName != null ) { | 
  | 175 | 0 |                                              field.setPersonNameValue( personName.toString() ); | 
  | 176 |  |                                      } | 
  | 177 |  |                              } | 
  | 178 | 0 |                      } catch ( Exception ex ) { | 
  | 179 | 0 |                              LOG.warn( "Unable to get principal ID or person name property in FieldBridge.", ex ); | 
  | 180 | 0 |                      } | 
  | 181 |  |              } | 
  | 182 | 0 |              FieldUtils.setInquiryURL(field, bo, propertyName); | 
  | 183 | 0 |                  } catch (InstantiationException e) { | 
  | 184 | 0 |              LOG.error("Unable to get instance of KeyValuesFinder: " + e.getMessage()); | 
  | 185 | 0 |              throw new RuntimeException("Unable to get instance of KeyValuesFinder: " + e.getMessage()); | 
  | 186 | 0 |                  } catch (ClassNotFoundException e) { | 
  | 187 | 0 |                          LOG.error("Unable to get instance of KeyValuesFinder: " + e.getMessage()); | 
  | 188 | 0 |              throw new RuntimeException("Unable to get instance of KeyValuesFinder: " + e.getMessage()); | 
  | 189 | 0 |                  } catch (IllegalAccessException e) { | 
  | 190 | 0 |              LOG.error("Unable to set columns: " + e.getMessage()); | 
  | 191 | 0 |              throw new RuntimeException("Unable to set columns: " + e.getMessage()); | 
  | 192 | 0 |          } | 
  | 193 |  |   | 
  | 194 | 0 |      } | 
  | 195 |  |   | 
  | 196 |  |       | 
  | 197 |  |   | 
  | 198 |  |   | 
  | 199 |  |   | 
  | 200 |  |   | 
  | 201 |  |   | 
  | 202 |  |   | 
  | 203 |  |      private static String lookupFinderValue(ControlDefinition fieldControl, Object prop, KeyValuesFinder finder) { | 
  | 204 | 0 |          String propValue = null; | 
  | 205 |  |   | 
  | 206 |  |           | 
  | 207 | 0 |          if (finder instanceof PersistableBusinessObjectValuesFinder) { | 
  | 208 | 0 |              ((PersistableBusinessObjectValuesFinder) finder).setBusinessObjectClass(ClassLoaderUtils.getClass(fieldControl.getBusinessObjectClass())); | 
  | 209 | 0 |              ((PersistableBusinessObjectValuesFinder) finder).setKeyAttributeName(fieldControl.getKeyAttribute()); | 
  | 210 | 0 |              ((PersistableBusinessObjectValuesFinder) finder).setLabelAttributeName(fieldControl.getLabelAttribute()); | 
  | 211 | 0 |              if (fieldControl.getIncludeBlankRow() != null) { | 
  | 212 | 0 |                      ((PersistableBusinessObjectValuesFinder) finder).setIncludeBlankRow(fieldControl.getIncludeBlankRow()); | 
  | 213 |  |              } | 
  | 214 | 0 |              ((PersistableBusinessObjectValuesFinder) finder).setIncludeKeyInDescription(fieldControl.getIncludeKeyInLabel()); | 
  | 215 |  |          } | 
  | 216 | 0 |          List<KeyValue> keyValues = finder.getKeyValues(); | 
  | 217 | 0 |          propValue = getPropertyValueFromList(prop, keyValues); | 
  | 218 | 0 |          if(propValue==null) { | 
  | 219 | 0 |                          propValue = lookupInactiveFinderValue(prop, finder); | 
  | 220 |  |                  } | 
  | 221 | 0 |          return propValue; | 
  | 222 |  |      } | 
  | 223 |  |       | 
  | 224 |  |      private static String lookupInactiveFinderValue(Object property, KeyValuesFinder finder){ | 
  | 225 | 0 |              List<KeyValue> keyValues = finder.getKeyValues(false); | 
  | 226 | 0 |              return getPropertyValueFromList(property, keyValues); | 
  | 227 |  |               | 
  | 228 |  |      } | 
  | 229 |  |       | 
  | 230 |  |      private static String getPropertyValueFromList(Object property, List<KeyValue> keyValues){ | 
  | 231 | 0 |              String propertyValue = null; | 
  | 232 | 0 |          if (property != null) { | 
  | 233 | 0 |              for (Object element2 : keyValues) { | 
  | 234 | 0 |                  KeyValue element = (KeyValue) element2; | 
  | 235 | 0 |                  if (element.getKey().toString().equals(property.toString())) { | 
  | 236 | 0 |                      propertyValue = element.getValue(); | 
  | 237 | 0 |                      break; | 
  | 238 |  |                  } | 
  | 239 | 0 |              } | 
  | 240 |  |          } | 
  | 241 | 0 |          return propertyValue; | 
  | 242 |  |      } | 
  | 243 |  |       | 
  | 244 |  |       | 
  | 245 |  |   | 
  | 246 |  |   | 
  | 247 |  |   | 
  | 248 |  |   | 
  | 249 |  |   | 
  | 250 |  |   | 
  | 251 |  |   | 
  | 252 |  |   | 
  | 253 |  |   | 
  | 254 |  |   | 
  | 255 |  |   | 
  | 256 |  |      protected static boolean isMaintenanceFieldLevelHelpEnabled(Maintainable m, MaintainableFieldDefinition fieldDefinition) { | 
  | 257 | 0 |          if ( fieldDefinition != null ) { | 
  | 258 | 0 |              if ( fieldDefinition.isShowFieldLevelHelp() != null && fieldDefinition.isShowFieldLevelHelp() ) { | 
  | 259 | 0 |                  return true; | 
  | 260 |  |              } | 
  | 261 |  |          } | 
  | 262 | 0 |          return false; | 
  | 263 |  |      } | 
  | 264 |  |   | 
  | 265 |  |       | 
  | 266 |  |   | 
  | 267 |  |   | 
  | 268 |  |   | 
  | 269 |  |   | 
  | 270 |  |   | 
  | 271 |  |   | 
  | 272 |  |   | 
  | 273 |  |   | 
  | 274 |  |   | 
  | 275 |  |   | 
  | 276 |  |   | 
  | 277 |  |   | 
  | 278 |  |      protected static boolean isMaintenanceFieldLevelHelpDisabled(Maintainable m, MaintainableFieldDefinition fieldDefinition) { | 
  | 279 | 0 |          if ( fieldDefinition != null ) { | 
  | 280 | 0 |              if ( fieldDefinition.isShowFieldLevelHelp() != null && !fieldDefinition.isShowFieldLevelHelp() ) { | 
  | 281 | 0 |                  return true; | 
  | 282 |  |              } | 
  | 283 |  |          } | 
  | 284 | 0 |          return false; | 
  | 285 |  |      } | 
  | 286 |  |   | 
  | 287 |  |       | 
  | 288 |  |   | 
  | 289 |  |   | 
  | 290 |  |   | 
  | 291 |  |   | 
  | 292 |  |   | 
  | 293 |  |   | 
  | 294 |  |   | 
  | 295 |  |   | 
  | 296 |  |   | 
  | 297 |  |   | 
  | 298 |  |   | 
  | 299 |  |   | 
  | 300 |  |   | 
  | 301 |  |   | 
  | 302 |  |   | 
  | 303 |  |   | 
  | 304 |  |      public static final Field toField(MaintainableItemDefinition id, MaintainableSectionDefinition sd, BusinessObject o, Maintainable m, Section s, List<String> displayedFieldNames, Set<String> conditionallyRequiredMaintenanceFields) throws InstantiationException, IllegalAccessException { | 
  | 305 | 0 |          Field field = new Field(); | 
  | 306 |  |   | 
  | 307 |  |           | 
  | 308 | 0 |          if (id instanceof MaintainableFieldDefinition) { | 
  | 309 | 0 |              MaintainableFieldDefinition maintainableFieldDefinition = (MaintainableFieldDefinition) id; | 
  | 310 | 0 |              field = FieldUtils.getPropertyField(o.getClass(), maintainableFieldDefinition.getName(), false); | 
  | 311 |  |   | 
  | 312 | 0 |                          boolean translateCodes = getMaintenanceDocumentDictionaryService().translateCodes(o.getClass()); | 
  | 313 | 0 |                          if (translateCodes) { | 
  | 314 | 0 |                                  FieldUtils.setAdditionalDisplayPropertyForCodes(o.getClass(), field.getPropertyName(), field); | 
  | 315 |  |                          } | 
  | 316 |  |   | 
  | 317 | 0 |              setupField(field, maintainableFieldDefinition, conditionallyRequiredMaintenanceFields); | 
  | 318 |  |   | 
  | 319 | 0 |              MaintenanceUtils.setFieldQuickfinder(o, field.getPropertyName(), maintainableFieldDefinition, field, displayedFieldNames, m); | 
  | 320 | 0 |              MaintenanceUtils.setFieldDirectInquiry(o, field.getPropertyName(), maintainableFieldDefinition, field, displayedFieldNames); | 
  | 321 |  |   | 
  | 322 |  |               | 
  | 323 |  |               | 
  | 324 |  |               | 
  | 325 |  |   | 
  | 326 |  |   | 
  | 327 |  |   | 
  | 328 |  |   | 
  | 329 |  |   | 
  | 330 |  |   | 
  | 331 |  |   | 
  | 332 |  |   | 
  | 333 |  |   | 
  | 334 |  |   | 
  | 335 |  |   | 
  | 336 |  |   | 
  | 337 |  |   | 
  | 338 |  |   | 
  | 339 |  |   | 
  | 340 |  |   | 
  | 341 |  |   | 
  | 342 |  |   | 
  | 343 |  |   | 
  | 344 |  |   | 
  | 345 |  |   | 
  | 346 |  |   | 
  | 347 |  |   | 
  | 348 |  |   | 
  | 349 |  |   | 
  | 350 |  |   | 
  | 351 |  |   | 
  | 352 |  |   | 
  | 353 |  |   | 
  | 354 |  |   | 
  | 355 | 0 |              field.setFieldLevelHelpEnabled(isMaintenanceFieldLevelHelpEnabled(m, maintainableFieldDefinition)); | 
  | 356 | 0 |              field.setFieldLevelHelpDisabled(isMaintenanceFieldLevelHelpDisabled(m, maintainableFieldDefinition)); | 
  | 357 | 0 |              field.setFieldLevelHelpUrl(maintainableFieldDefinition.getFieldLevelHelpUrl()); | 
  | 358 |  |          } | 
  | 359 |  |   | 
  | 360 | 0 |          return field; | 
  | 361 |  |   | 
  | 362 |  |      } | 
  | 363 |  |   | 
  | 364 |  |       | 
  | 365 |  |   | 
  | 366 |  |   | 
  | 367 |  |   | 
  | 368 |  |   | 
  | 369 |  |   | 
  | 370 |  |   | 
  | 371 |  |   | 
  | 372 |  |   | 
  | 373 |  |   | 
  | 374 |  |   | 
  | 375 |  |   | 
  | 376 |  |   | 
  | 377 |  |   | 
  | 378 |  |   | 
  | 379 |  |   | 
  | 380 |  |      public static final List<Field> getNewFormFields(CollectionDefinitionI collectionDefinition, BusinessObject o, Maintainable m, List<String> displayedFieldNames, Set<String> conditionallyRequiredMaintenanceFields, StringBuffer containerRowErrorKey, String parents, boolean hideAdd, int numberOfColumns) { | 
  | 381 | 0 |          LOG.debug( "getNewFormFields" ); | 
  | 382 | 0 |          String collName = collectionDefinition.getName(); | 
  | 383 |  |   | 
  | 384 | 0 |          List<Field> collFields = new ArrayList<Field>(); | 
  | 385 |  |          Collection<? extends FieldDefinitionI> collectionFields; | 
  | 386 |  |           | 
  | 387 | 0 |          BusinessObject collBO = null; | 
  | 388 |  |          try { | 
  | 389 | 0 |              collectionFields = collectionDefinition.getFields(); | 
  | 390 | 0 |              collBO = m.getNewCollectionLine(parents + collName); | 
  | 391 |  |   | 
  | 392 | 0 |              if ( LOG.isDebugEnabled() ) { | 
  | 393 | 0 |                  LOG.debug( "newBO for add line: " + collBO ); | 
  | 394 |  |              } | 
  | 395 |  |   | 
  | 396 | 0 |              for ( FieldDefinitionI fieldDefinition : collectionFields  ) { | 
  | 397 |  |                   | 
  | 398 | 0 |                  Field collField = FieldUtils.getPropertyField(collectionDefinition.getBusinessObjectClass(), fieldDefinition.getName(), false); | 
  | 399 |  |   | 
  | 400 | 0 |                  if (fieldDefinition instanceof MaintainableFieldDefinition) { | 
  | 401 | 0 |                      setupField(collField, fieldDefinition, conditionallyRequiredMaintenanceFields); | 
  | 402 |  |                  } | 
  | 403 |  |                   | 
  | 404 | 0 |                  String[] nameParts = StringUtils.split(collField.getPropertyName(), "."); | 
  | 405 | 0 |                  String fieldErrorKey = KRADConstants.MAINTENANCE_NEW_MAINTAINABLE + KRADConstants.ADD_PREFIX + "."; | 
  | 406 | 0 |                  fieldErrorKey += collName + "."; | 
  | 407 | 0 |                  for (int i = 0; i < nameParts.length; i++) { | 
  | 408 | 0 |                      fieldErrorKey += nameParts[i]; | 
  | 409 | 0 |                      containerRowErrorKey.append(fieldErrorKey); | 
  | 410 | 0 |                      if (i < nameParts.length) { | 
  | 411 | 0 |                          fieldErrorKey += "."; | 
  | 412 | 0 |                          containerRowErrorKey.append(","); | 
  | 413 |  |                      } | 
  | 414 |  |                  } | 
  | 415 |  |   | 
  | 416 |  |                   | 
  | 417 | 0 |                  BusinessObject collectionBoInstance = collectionDefinition.getBusinessObjectClass().newInstance(); | 
  | 418 | 0 |                  FieldUtils.setInquiryURL(collField, collectionBoInstance, fieldDefinition.getName()); | 
  | 419 | 0 |                  if (collectionDefinition instanceof MaintainableCollectionDefinition) { | 
  | 420 | 0 |                      MaintenanceUtils.setFieldQuickfinder(collectionBoInstance, parents+collectionDefinition.getName(), true, 0, fieldDefinition.getName(), collField, displayedFieldNames, m, (MaintainableFieldDefinition) fieldDefinition); | 
  | 421 | 0 |                      MaintenanceUtils | 
  | 422 |  |                              .setFieldDirectInquiry(collectionBoInstance, parents + collectionDefinition.getName(), true, | 
  | 423 |  |                                      0, fieldDefinition.getName(), collField, displayedFieldNames, m, | 
  | 424 |  |                                      (MaintainableFieldDefinition) fieldDefinition); | 
  | 425 |  |                  } | 
  | 426 |  |                  else { | 
  | 427 | 0 |                      LookupUtils.setFieldQuickfinder(collectionBoInstance, parents+collectionDefinition.getName(), true, 0, fieldDefinition.getName(), collField, displayedFieldNames, m); | 
  | 428 | 0 |                      LookupUtils.setFieldDirectInquiry(collectionBoInstance, fieldDefinition.getName(), collField); | 
  | 429 |  |                  } | 
  | 430 |  |   | 
  | 431 | 0 |                  collFields.add(collField); | 
  | 432 | 0 |              } | 
  | 433 |  |   | 
  | 434 | 0 |          } catch (InstantiationException e) { | 
  | 435 | 0 |              LOG.error("Unable to create instance of object class" + e.getMessage()); | 
  | 436 | 0 |              throw new RuntimeException("Unable to create instance of object class" + e.getMessage()); | 
  | 437 | 0 |          } catch (IllegalAccessException e) { | 
  | 438 | 0 |              LOG.error("Unable to create instance of object class" + e.getMessage()); | 
  | 439 | 0 |              throw new RuntimeException("Unable to create instance of object class" + e.getMessage()); | 
  | 440 | 0 |          } | 
  | 441 |  |   | 
  | 442 |  |           | 
  | 443 | 0 |          collFields = FieldUtils.populateFieldsFromBusinessObject(collFields,collBO); | 
  | 444 |  |   | 
  | 445 |  |           | 
  | 446 |  |           | 
  | 447 | 0 |          for ( Field field : collFields ) { | 
  | 448 |  |               | 
  | 449 | 0 |              field.setPropertyName(KRADConstants.MAINTENANCE_ADD_PREFIX + parents + collectionDefinition.getName() + "." + field.getPropertyName()); | 
  | 450 |  |          } | 
  | 451 | 0 |          LOG.debug("Error Key for section " + collectionDefinition.getName() + " : " + containerRowErrorKey.toString()); | 
  | 452 |  |   | 
  | 453 |  |           | 
  | 454 | 0 |          collFields = constructContainerField(collectionDefinition, parents, o, hideAdd, numberOfColumns, collName, collFields); | 
  | 455 |  |   | 
  | 456 | 0 |          return collFields; | 
  | 457 |  |      } | 
  | 458 |  |   | 
  | 459 |  |       | 
  | 460 |  |   | 
  | 461 |  |   | 
  | 462 |  |   | 
  | 463 |  |   | 
  | 464 |  |   | 
  | 465 |  |   | 
  | 466 |  |   | 
  | 467 |  |   | 
  | 468 |  |   | 
  | 469 |  |   | 
  | 470 |  |   | 
  | 471 |  |   | 
  | 472 |  |      public static List<Field> constructContainerField(CollectionDefinitionI collectionDefinition, String parents, BusinessObject o, boolean hideAdd, int numberOfColumns, String collName, List<Field> collFields) { | 
  | 473 |  |           | 
  | 474 | 0 |          String collectionLabel = getDataDictionaryService().getCollectionLabel(o.getClass(), collectionDefinition.getName()); | 
  | 475 |  |   | 
  | 476 |  |           | 
  | 477 | 0 |          String collectionElementLabel = collectionDefinition.getSummaryTitle(); | 
  | 478 | 0 |          if(StringUtils.isEmpty(collectionElementLabel)){ | 
  | 479 | 0 |              collectionElementLabel = getDataDictionaryService().getCollectionElementLabel(o.getClass().getName(), collectionDefinition.getName(),collectionDefinition.getBusinessObjectClass()); | 
  | 480 |  |          } | 
  | 481 |  |   | 
  | 482 |  |           | 
  | 483 |  |          Field containerField; | 
  | 484 | 0 |          containerField = FieldUtils.constructContainerField(collName, collectionLabel, collFields, numberOfColumns); | 
  | 485 | 0 |          if(StringUtils.isNotEmpty(collectionElementLabel)) { | 
  | 486 | 0 |              containerField.setContainerElementName(collectionElementLabel); | 
  | 487 |  |          } | 
  | 488 | 0 |          collFields = new ArrayList(); | 
  | 489 | 0 |          collFields.add(containerField); | 
  | 490 |  |   | 
  | 491 |  |           | 
  | 492 | 0 |          if(!hideAdd  && collectionDefinition.getIncludeAddLine()) { | 
  | 493 | 0 |              Field field = new Field(); | 
  | 494 |  |   | 
  | 495 | 0 |              String addButtonName = KRADConstants.DISPATCH_REQUEST_PARAMETER + "." + KRADConstants.ADD_LINE_METHOD + "." + parents + collectionDefinition.getName() + "." + KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL + collectionDefinition.getBusinessObjectClass().getName() + KRADConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL; | 
  | 496 | 0 |              field.setPropertyName(addButtonName); | 
  | 497 | 0 |              field.setFieldType(Field.IMAGE_SUBMIT); | 
  | 498 | 0 |              field.setPropertyValue("images/tinybutton-add1.gif"); | 
  | 499 |  |               | 
  | 500 | 0 |              containerField.getContainerRows().add(new Row(field)); | 
  | 501 |  |          } | 
  | 502 |  |   | 
  | 503 | 0 |          if (collectionDefinition instanceof MaintainableCollectionDefinition) { | 
  | 504 | 0 |              if (FieldUtils.isCollectionMultipleLookupEnabled((MaintainableCollectionDefinition) collectionDefinition)) { | 
  | 505 | 0 |                  FieldUtils.modifyFieldToSupportMultipleValueLookups(containerField, parents, (MaintainableCollectionDefinition) collectionDefinition); | 
  | 506 |  |              } | 
  | 507 |  |          } | 
  | 508 |  |   | 
  | 509 | 0 |          return collFields; | 
  | 510 |  |      } | 
  | 511 |  |   | 
  | 512 |  |       | 
  | 513 |  |   | 
  | 514 |  |   | 
  | 515 |  |   | 
  | 516 |  |   | 
  | 517 |  |      public static final List<Field> getNewFormFields(MaintainableCollectionDefinition collectionDefinition, BusinessObject o, Maintainable m, List<String> displayedFieldNames, Set<String> conditionallyRequiredMaintenanceFields, StringBuffer containerRowErrorKey, int numberOfColumns) { | 
  | 518 | 0 |          String parent = ""; | 
  | 519 | 0 |          return getNewFormFields(collectionDefinition, o, m, displayedFieldNames, conditionallyRequiredMaintenanceFields, containerRowErrorKey, parent, false, numberOfColumns); | 
  | 520 |  |      } | 
  | 521 |  |   | 
  | 522 |  |       | 
  | 523 |  |   | 
  | 524 |  |   | 
  | 525 |  |   | 
  | 526 |  |   | 
  | 527 |  |   | 
  | 528 |  |   | 
  | 529 |  |   | 
  | 530 |  |   | 
  | 531 |  |      public static Field toField(FieldDefinition d, BusinessObject o, Section s) { | 
  | 532 | 0 |          Field field = FieldUtils.getPropertyField(o.getClass(), d.getAttributeName(), false); | 
  | 533 |  |           | 
  | 534 | 0 |          FieldUtils.setInquiryURL(field, o, field.getPropertyName()); | 
  | 535 |  |   | 
  | 536 | 0 |                  String alternateDisplayPropertyName = getBusinessObjectDictionaryService() | 
  | 537 |  |                                  .getInquiryFieldAlternateDisplayAttributeName(o.getClass(), d.getAttributeName()); | 
  | 538 | 0 |                  if (StringUtils.isNotBlank(alternateDisplayPropertyName)) { | 
  | 539 | 0 |                          field.setAlternateDisplayPropertyName(alternateDisplayPropertyName); | 
  | 540 |  |                  } | 
  | 541 |  |   | 
  | 542 | 0 |                  String additionalDisplayPropertyName = getBusinessObjectDictionaryService() | 
  | 543 |  |                                  .getInquiryFieldAdditionalDisplayAttributeName(o.getClass(), d.getAttributeName()); | 
  | 544 | 0 |                  if (StringUtils.isNotBlank(additionalDisplayPropertyName)) { | 
  | 545 | 0 |                          field.setAdditionalDisplayPropertyName(additionalDisplayPropertyName); | 
  | 546 |  |                  } | 
  | 547 |  |                  else { | 
  | 548 | 0 |                          boolean translateCodes = getBusinessObjectDictionaryService().tranlateCodesInInquiry(o.getClass()); | 
  | 549 | 0 |                          if (translateCodes) { | 
  | 550 | 0 |                                  FieldUtils.setAdditionalDisplayPropertyForCodes(o.getClass(), d.getAttributeName(), field); | 
  | 551 |  |                          } | 
  | 552 |  |                  } | 
  | 553 |  |   | 
  | 554 | 0 |          populateFieldFromBusinessObject(field, o); | 
  | 555 |  |   | 
  | 556 | 0 |          return field; | 
  | 557 |  |      } | 
  | 558 |  |   | 
  | 559 |  |          public static DataDictionaryService getDataDictionaryService() { | 
  | 560 | 0 |              if (dataDictionaryService == null) { | 
  | 561 | 0 |                      dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService(); | 
  | 562 |  |              } | 
  | 563 | 0 |                  return dataDictionaryService; | 
  | 564 |  |          } | 
  | 565 |  |   | 
  | 566 |  |          public static PersistenceStructureService getPersistenceStructureService() { | 
  | 567 | 0 |              if (persistenceStructureService == null) { | 
  | 568 | 0 |                      persistenceStructureService = KRADServiceLocator.getPersistenceStructureService(); | 
  | 569 |  |              } | 
  | 570 | 0 |                  return persistenceStructureService; | 
  | 571 |  |          } | 
  | 572 |  |   | 
  | 573 |  |          public static BusinessObjectDictionaryService getBusinessObjectDictionaryService() { | 
  | 574 | 0 |              if (businessObjectDictionaryService == null) { | 
  | 575 | 0 |                      businessObjectDictionaryService = KRADServiceLocatorWeb.getBusinessObjectDictionaryService(); | 
  | 576 |  |              } | 
  | 577 | 0 |                  return businessObjectDictionaryService;  | 
  | 578 |  |          } | 
  | 579 |  |           | 
  | 580 |  |          public static MaintenanceDocumentDictionaryService getMaintenanceDocumentDictionaryService() { | 
  | 581 | 0 |              if (maintenanceDocumentDictionaryService == null) { | 
  | 582 | 0 |                      maintenanceDocumentDictionaryService = KNSServiceLocator.getMaintenanceDocumentDictionaryService(); | 
  | 583 |  |              } | 
  | 584 | 0 |                  return maintenanceDocumentDictionaryService;  | 
  | 585 |  |          } | 
  | 586 |  |   | 
  | 587 |  |  } | 
  | 588 |  |   |