/** * Get a {@link NameIndex} based on {@linkplain #getSchemaModel this instance's schema model}. * * @return a name index on this instance's schema model */ public NameIndex getNameIndex() { if (this.nameIndex == null) this.nameIndex = new NameIndex(this.getSchemaModel()); return this.nameIndex; }
/** * Create a new {@link SnapshotJTransaction} based on the provided key/value store. * * <p> * The key/value store will be initialized if necessary (i.e., {@code kvstore} may be empty), otherwise it will be * validated against the schema information associated with this instance. * * <p> * The returned {@link SnapshotJTransaction} does not support {@link SnapshotJTransaction#commit commit()} or * {@link SnapshotJTransaction#rollback rollback()}, and can be used indefinitely. * * @param kvstore key/value store, empty or having content compatible with this transaction's {@link Permazen} * @param allowNewSchema whether creating a new schema version in {@code kvstore} is allowed * @param validationMode the {@link ValidationMode} to use for the snapshot transaction * @return snapshot transaction based on {@code kvstore} * @throws io.permazen.core.SchemaMismatchException if {@code kvstore} contains incompatible or missing schema information * @throws io.permazen.core.InconsistentDatabaseException if inconsistent or invalid meta-data is detected in the database * @throws IllegalArgumentException if {@code kvstore} is null */ public SnapshotJTransaction createSnapshotTransaction(KVStore kvstore, boolean allowNewSchema, ValidationMode validationMode) { final SnapshotTransaction stx = this.db.createSnapshotTransaction(kvstore, this.getSchemaModel(), this.configuredVersion, allowNewSchema); return new SnapshotJTransaction(this, stx, validationMode); }
/** * Create a new transaction using an already-opened {@link KVTransaction}. * * <p> * This does not invoke {@link JTransaction#setCurrent JTransaction.setCurrent()}: the caller is responsible * for doing that if necessary. However, this method does arrange for * {@link JTransaction#setCurrent JTransaction.setCurrent}{@code (null)} to be invoked as soon as the * returned transaction is committed (or rolled back), assuming {@link JTransaction#getCurrent} returns the * {@link JTransaction} returned here at that time. * * @param kvt already opened key/value store transaction * @param allowNewSchema whether creating a new schema version is allowed * @param validationMode the {@link ValidationMode} to use for the new transaction * @return the newly created transaction * @throws io.permazen.core.InvalidSchemaException if the schema does not match what's recorded in the * database for the schema version provided to the constructor * @throws io.permazen.core.InvalidSchemaException if the schema version provided to the constructor * is not recorded in the database and {@code allowNewSchema} is false * @throws io.permazen.core.InvalidSchemaException if the schema version provided to the constructor * is not recorded in the database and {@code allowNewSchema} is true, but the schema is incompatible * with one or more previous schemas alread recorded in the database (i.e., the same storage ID is used * incompatibly between schema versions) * @throws io.permazen.core.InconsistentDatabaseException if inconsistent or invalid meta-data is detected in the database * @throws IllegalArgumentException if {@code kvt} or {@code validationMode} is null */ public JTransaction createTransaction(KVTransaction kvt, boolean allowNewSchema, ValidationMode validationMode) { return this.createTransaction( this.db.createTransaction(kvt, this.getSchemaModel(), this.configuredVersion, allowNewSchema), validationMode); }
/** * Create a new transaction with key/value transaction options. * * <p> * This does not invoke {@link JTransaction#setCurrent JTransaction.setCurrent()}: the caller is responsible * for doing that if necessary. However, this method does arrange for * {@link JTransaction#setCurrent JTransaction.setCurrent}{@code (null)} to be invoked as soon as the * returned transaction is committed (or rolled back), assuming {@link JTransaction#getCurrent} returns the * {@link JTransaction} returned here at that time. * * @param allowNewSchema whether creating a new schema version is allowed * @param validationMode the {@link ValidationMode} to use for the new transaction * @param kvoptions optional {@link io.permazen.kv.KVDatabase}-specific transaction options; may be null * @return the newly created transaction * @throws io.permazen.core.InvalidSchemaException if the schema does not match what's recorded in the * database for the schema version provided to the constructor * @throws io.permazen.core.InvalidSchemaException if the schema version provided to the constructor * is not recorded in the database and {@code allowNewSchema} is false * @throws io.permazen.core.InvalidSchemaException if the schema version provided to the constructor * is not recorded in the database and {@code allowNewSchema} is true, but the schema is incompatible * with one or more previous schemas alread recorded in the database (i.e., the same storage ID is used * incompatibly between schema versions) * @throws io.permazen.core.InconsistentDatabaseException if inconsistent or invalid meta-data is detected in the database * @throws IllegalArgumentException if {@code validationMode} is null */ public JTransaction createTransaction(boolean allowNewSchema, ValidationMode validationMode, Map<String, ?> kvoptions) { return this.createTransaction( this.db.createTransaction(this.getSchemaModel(), this.configuredVersion, allowNewSchema, kvoptions), validationMode); }
this.db.validateSchema(this.getSchemaModel());
GUISession(GUIConfig guiConfig) { super(guiConfig.getPermazen()); this.guiConfig = guiConfig; this.setReadOnly(this.guiConfig.isReadOnly()); this.setSchemaModel(this.guiConfig.getPermazen().getSchemaModel()); this.setSchemaVersion(this.guiConfig.getSchemaVersion()); this.setAllowNewSchema(this.guiConfig.isAllowNewSchema()); this.loadFunctionsFromClasspath(); }