Exemplo n.º 1
0
  public List<EntityHierarchyImpl> groupEntityHierarchies() {
    while (!extendsQueue.isEmpty()) {
      // set up a pass over the queue
      int numberOfMappingsProcessed = 0;
      Iterator<ExtendsQueueEntry> iterator = extendsQueue.iterator();
      while (iterator.hasNext()) {
        final ExtendsQueueEntry entry = iterator.next();
        final SubclassEntityContainer container = subEntityContainerMap.get(entry.entityItExtends);
        if (container != null) {
          // we now have this entity's super, attach it and remove entry from extends queue
          container.add(entry.subClassEntitySource);
          iterator.remove();
          numberOfMappingsProcessed++;
        }
      }

      if (numberOfMappingsProcessed == 0) {

        // todo : we could log the waiting dependencies...
        throw currentMappingDocument
            .getMappingLocalBindingContext()
            .makeMappingException("Unable to process extends dependencies in hbm files");
      }
    }

    return entityHierarchies;
  }
Exemplo n.º 2
0
 private void processSubclassElement(SubEntityElement element) {
   // we have to see if this things super-type has been found yet, and if not add it to the
   // extends queue
   final String entityItExtends =
       currentMappingDocument
           .getMappingLocalBindingContext()
           .qualifyClassName(element.getExtends());
   final SubclassEntityContainer container = subEntityContainerMap.get(entityItExtends);
   final SubclassEntitySourceImpl subClassEntitySource =
       createSubClassEntitySource(element, (EntitySource) container);
   final String entityName = subClassEntitySource.getEntityName();
   subEntityContainerMap.put(entityName, subClassEntitySource);
   processSubElements(element, subClassEntitySource);
   if (container != null) {
     // we already have this entity's super, attach it and continue
     container.add(subClassEntitySource);
   } else {
     // we do not yet have the super and have to wait, so add it fto the extends queue
     extendsQueue.add(new ExtendsQueueEntry(subClassEntitySource, entityItExtends));
   }
 }
Exemplo n.º 3
0
  private void processElements(
      List<? extends SubEntityElement> subElements, SubclassEntityContainer container) {
    for (final SubEntityElement subElement : subElements) {
      final SubclassEntitySourceImpl subclassEntitySource =
          createSubClassEntitySource(subElement, (EntitySource) container);
      container.add(subclassEntitySource);
      final String subEntityName = subclassEntitySource.getEntityName();
      subEntityContainerMap.put(subEntityName, subclassEntitySource);

      // Re-run the sub element to handle, as an example, subclasses
      // within a subclass.
      processSubElements(subElement, subclassEntitySource);
    }
  }