/**
   * @see
   *     org.kuali.rice.krad.service.PersistenceStructureService#getBusinessObjectAttributeClass(java.lang.Class,
   *     java.lang.String)
   */
  public Class<? extends PersistableBusinessObjectExtension> getBusinessObjectAttributeClass(
      Class<? extends PersistableBusinessObject> clazz, String attributeName) {
    String baseAttributeName = attributeName;
    String subAttributeString = null;
    if (attributeName.contains(".")) {
      baseAttributeName = attributeName.substring(0, attributeName.indexOf('.'));
      subAttributeString = attributeName.substring(attributeName.indexOf('.') + 1);
    }

    // Legacy OJB
    Class attributeClassLegacy = null;
    ClassDescriptor classDescriptor = null;
    try {
      classDescriptor = this.getClassDescriptor(clazz);
    } catch (ClassNotPersistableException e) {
      LOG.warn("Class descriptor for " + clazz.getName() + "was not found");
    }

    ObjectReferenceDescriptor refDescriptor = null;
    if (classDescriptor != null) {
      refDescriptor = classDescriptor.getObjectReferenceDescriptorByName(baseAttributeName);
    }

    if (refDescriptor != null) {
      attributeClassLegacy = refDescriptor.getItemClass();
    }

    // recurse if necessary
    if (subAttributeString != null) {
      attributeClassLegacy =
          getBusinessObjectAttributeClass(attributeClassLegacy, subAttributeString);
    }

    return attributeClassLegacy;
  }
  @Override
  public List<DataObjectRelationship> getRelationshipsTo(Class persistableClass)
      throws ClassNotPersistableException {
    if (!isPersistable(persistableClass)) {
      throw new ClassNotPersistableException(persistableClass.getName() + " is not persistable");
    }

    final List<DataObjectRelationship> relationships = new ArrayList<>();

    @SuppressWarnings("unchecked")
    final Set<Map.Entry<String, ClassDescriptor>> entries =
        (Set<Map.Entry<String, ClassDescriptor>>)
            getDescriptorRepository().getDescriptorTable().entrySet();
    for (Map.Entry<String, ClassDescriptor> entry : entries) {
      @SuppressWarnings("unchecked")
      final Collection<ObjectReferenceDescriptor> references =
          entry.getValue().getObjectReferenceDescriptors();
      if (references != null) {
        for (ObjectReferenceDescriptor reference : references) {
          if (reference.getItemClass().equals(persistableClass)) {
            final DataObjectRelationship relationship =
                new DataObjectRelationship(
                    entry.getValue().getClassOfObject(),
                    reference.getAttributeName(),
                    reference.getItemClass());
            final Map<String, String> pToC = new HashMap<>();
            for (int i = 0; i < reference.getForeignKeyFields().size(); i++) {
              final String fkField = (String) reference.getForeignKeyFields().get(i);
              pToC.put(
                  fkField,
                  getDescriptorRepository()
                      .getDescriptorFor(reference.getItemClass())
                      .getPkFields()[i]
                      .getAttributeName());
            }
            relationship.setParentToChildReferences(pToC);
            relationships.add(relationship);
          }
        }
      }
    }

    return relationships;
  }