/**
   * Creates a searchable attribute value for the given property name out of the document XML
   *
   * @param propertyName the name of the property to return
   * @param businessObjectClass the class of the business object maintained
   * @param document the document XML
   * @return a generated SearchableAttributeValue, or null if a value could not be created
   */
  protected DocumentAttribute parseSearchableAttributeValueForPrimaryKey(
      String propertyName,
      Class<? extends BusinessObject> businessObjectClass,
      MaintenanceDocument document) {

    Maintainable maintainable = document.getNewMaintainableObject();
    PersistableBusinessObject bo = maintainable.getBusinessObject();

    final Object propertyValue = ObjectUtils.getPropertyValue(bo, propertyName);
    if (propertyValue == null) return null;

    final WorkflowAttributePropertyResolutionService propertyResolutionService =
        KNSServiceLocator.getWorkflowAttributePropertyResolutionService();
    DocumentAttribute value =
        propertyResolutionService.buildSearchableAttribute(
            businessObjectClass, propertyName, propertyValue);
    return value;
  }
  protected DocumentAttribute generateSearchableAttributeFromChange(Object changeToPersist) {
    List<String> primaryKeyNames =
        KRADServiceLocatorWeb.getLegacyDataAdapter()
            .listPrimaryKeyFieldNames(changeToPersist.getClass());

    for (Object primaryKeyNameAsObject : primaryKeyNames) {
      String primaryKeyName = (String) primaryKeyNameAsObject;
      Object value = ObjectUtils.getPropertyValue(changeToPersist, primaryKeyName);

      if (value != null) {
        final WorkflowAttributePropertyResolutionService propertyResolutionService =
            KNSServiceLocator.getWorkflowAttributePropertyResolutionService();
        DocumentAttribute saValue =
            propertyResolutionService.buildSearchableAttribute(
                (Class) changeToPersist.getClass(), primaryKeyName, value);
        return saValue;
      }
    }
    return null;
  }