/** See Store.refresh. */ void refresh(final PersistCatalog newCatalog) { catalog = newCatalog; entityFormat = newCatalog.getFormat(entityFormat.getClassName()); if (keyAssigner != null) { keyAssigner.refresh(newCatalog); } }
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(); }
/** * Returns the format for the given entity and validates it, throwing an exception if it is * invalid for this binding. */ private Format getValidFormat(Object entity) throws RefreshException { /* A null entity is not allowed. */ if (entity == null) { throw new IllegalArgumentException("An entity may not be null"); } /* * Get the format. getFormat throws IllegalArgumentException if the * class is not persistent. */ Format format; if (rawAccess) { if (!(entity instanceof RawObject)) { throw new IllegalArgumentException("Entity must be a RawObject"); } format = (Format) ((RawObject) entity).getType(); } else { format = catalog.getFormat(entity.getClass(), true /*checkEntitySubclassIndexes*/); } /* Check that the entity class/subclass is valid for this binding. */ if (format.getEntityFormat() != entityFormat) { throw new IllegalArgumentException( "The entity class (" + format.getClassName() + ") must be this entity class or a subclass of it: " + entityFormat.getClassName()); } return format; }
@Override public EntityMetadata getEntityMetadata(String className) { EntityMetadata metadata = null; Format format = catalog.getFormat(className); if (format != null && format.isCurrentVersion()) { metadata = format.getEntityMetadata(); } return metadata; }