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