예제 #1
0
파일: Store.java 프로젝트: nologic/nabs
  public EvolveStats evolve(EvolveConfig config) throws DatabaseException {

    checkOpen();
    List<Format> toEvolve = new ArrayList<Format>();
    Set<String> configToEvolve = config.getClassesToEvolve();
    if (configToEvolve.isEmpty()) {
      catalog.getEntityFormats(toEvolve);
    } else {
      for (String name : configToEvolve) {
        Format format = catalog.getFormat(name);
        if (format == null) {
          throw new IllegalArgumentException("Class to evolve is not persistent: " + name);
        }
        if (!format.isEntity()) {
          throw new IllegalArgumentException("Class to evolve is not an entity class: " + name);
        }
        toEvolve.add(format);
      }
    }

    EvolveEvent event = EvolveInternal.newEvent();
    for (Format format : toEvolve) {
      if (format.getEvolveNeeded()) {
        evolveIndex(format, event, config.getEvolveListener());
        format.setEvolveNeeded(false);
        catalog.flush();
      }
    }

    return event.getStats();
  }
  /** Creates a key binding for a given entity class. */
  public PersistEntityBinding(
      final PersistCatalog catalogParam, final String entityClassName, final boolean rawAccess) {
    catalog = catalogParam;

    try {
      entityFormat = getOrCreateFormat(catalog, entityClassName, rawAccess);
    } catch (RefreshException e) {
      /* Must assign catalog field in constructor. */
      catalog = e.refresh();
      try {
        entityFormat = getOrCreateFormat(catalog, entityClassName, rawAccess);
      } catch (RefreshException e2) {
        throw DbCompat.unexpectedException(e2);
      }
    }
    if (!entityFormat.isEntity()) {
      throw new IllegalArgumentException("Not an entity class: " + entityClassName);
    }
    this.rawAccess = rawAccess;
  }