use of com.torodb.core.transaction.metainf.MutableMetaDatabase in project torodb by torodb.
the class SqlWriteTorodTransaction method createCollection.
@Override
public void createCollection(String db, String collection) throws RollbackException, UserException {
MutableMetaDatabase metaDb = getOrCreateMetaDatabase(db);
getOrCreateMetaCollection(metaDb, collection);
}
use of com.torodb.core.transaction.metainf.MutableMetaDatabase in project torodb by torodb.
the class SqlWriteTorodTransaction method getOrCreateMetaDatabase.
@Nonnull
protected MutableMetaDatabase getOrCreateMetaDatabase(String dbName) {
MutableMetaSnapshot metaSnapshot = getInternalTransaction().getMetaSnapshot();
MutableMetaDatabase metaDb = metaSnapshot.getMetaDatabaseByName(dbName);
if (metaDb == null) {
metaDb = createMetaDatabase(dbName);
}
return metaDb;
}
use of com.torodb.core.transaction.metainf.MutableMetaDatabase in project torodb by torodb.
the class SqlWriteTorodTransaction method getMetaDatabaseOrThrowException.
@Nonnull
protected MutableMetaDatabase getMetaDatabaseOrThrowException(@Nonnull String dbName) throws DatabaseNotFoundException {
MutableMetaSnapshot metaSnapshot = getInternalTransaction().getMetaSnapshot();
MutableMetaDatabase metaDb = metaSnapshot.getMetaDatabaseByName(dbName);
if (metaDb == null) {
throw new DatabaseNotFoundException(dbName);
}
return metaDb;
}
use of com.torodb.core.transaction.metainf.MutableMetaDatabase in project torodb by torodb.
the class SqlWriteTorodTransaction method dropCollection.
@Override
public void dropCollection(String db, String collection) throws RollbackException, UserException {
MutableMetaDatabase metaDb = getMetaDatabaseOrThrowException(db);
MutableMetaCollection metaColl = getMetaCollectionOrThrowException(metaDb, collection);
getInternalTransaction().getBackendTransaction().dropCollection(metaDb, metaColl);
metaDb.removeMetaCollectionByName(collection);
}
use of com.torodb.core.transaction.metainf.MutableMetaDatabase in project torodb by torodb.
the class SqlWriteTorodTransaction method createMetaDatabase.
private MutableMetaDatabase createMetaDatabase(String dbName) {
Preconditions.checkState(!isClosed());
MutableMetaSnapshot metaSnapshot = getInternalTransaction().getMetaSnapshot();
MutableMetaDatabase metaDb = metaSnapshot.addMetaDatabase(dbName, getConnection().getServer().getIdentifierFactory().toDatabaseIdentifier(metaSnapshot, dbName));
getInternalTransaction().getBackendTransaction().addDatabase(metaDb);
return metaDb;
}
Aggregations