Search in sources :

Example 1 with EntityCreator

use of org.vitrivr.cineast.core.db.setup.EntityCreator in project cineast by vitrivr.

the class DropTableCommand method dropTable.

public static void dropTable(String tableName) {
    final EntityCreator ec = Config.sharedConfig().getDatabase().getEntityCreatorSupplier().get();
    if (ec != null) {
        System.out.println("Dropping " + tableName);
        ec.dropEntity(tableName);
        System.out.println("...done");
        /* Closes the EntityCreator. */
        ec.close();
    }
}
Also used : EntityCreator(org.vitrivr.cineast.core.db.setup.EntityCreator)

Example 2 with EntityCreator

use of org.vitrivr.cineast.core.db.setup.EntityCreator in project cineast by vitrivr.

the class DatabaseSetupCommand method doSetup.

/**
 * Performs necessary setup on database, i.e. creating the required tables.
 */
public void doSetup() {
    final EntityCreator ec = Config.sharedConfig().getDatabase().getEntityCreatorSupplier().get();
    if (ec != null) {
        HashSet<PersistentOperator> persistentOperators;
        if (this.extractionConfig == null) {
            persistentOperators = this.configPersistentOperators();
        } else {
            persistentOperators = this.extractionConfigPersistentOperators(this.extractionConfig);
        }
        if (this.clean) {
            this.dropAllEntities(ec, persistentOperators);
        }
        print("Setting up basic entities...");
        ec.createMultiMediaObjectsEntity();
        ec.createMetadataEntity();
        ec.createSegmentMetadataEntity();
        ec.createSegmentEntity();
        ec.createTagEntity();
        print("...done");
        print("Setting up retriever classes...");
        for (PersistentOperator r : persistentOperators) {
            print("Creating entity for " + r.getClass().getSimpleName());
            r.initalizePersistentLayer(() -> ec);
        }
        print("...done");
        print("Setup complete!");
        /* Closes the EntityCreator. */
        ec.close();
    }
}
Also used : EntityCreator(org.vitrivr.cineast.core.db.setup.EntityCreator) PersistentOperator(org.vitrivr.cineast.core.db.PersistentOperator)

Example 3 with EntityCreator

use of org.vitrivr.cineast.core.db.setup.EntityCreator in project cineast by vitrivr.

the class DataImportHandler method createEntityOnDemand.

protected static void createEntityOnDemand(EntityDefinition def, String taskName) {
    LOGGER.debug("Creating entity: " + def);
    EntityCreator ec = Config.sharedConfig().getDatabase().getEntityCreatorSupplier().get();
    if (ec.existsEntity(def.getEntityName())) {
        LOGGER.warn("Entity already exists, ignoring");
        return;
    }
    if (ec.createEntity(def)) {
        LOGGER.info("Successfully created entity " + def);
    } else {
        LOGGER.error("Could not create entity " + def + " please see the log");
    }
}
Also used : EntityCreator(org.vitrivr.cineast.core.db.setup.EntityCreator)

Example 4 with EntityCreator

use of org.vitrivr.cineast.core.db.setup.EntityCreator in project cineast by vitrivr.

the class DataImportHandler method cleanOnDemand.

/**
 * Drops the entity if called. This is in order to have clean imports.
 *
 * @param entityName The entity name to drop
 * @param taskName   The task name during which this dropping occurs. Only for logging purposes
 */
protected static void cleanOnDemand(String entityName, String taskName) {
    final EntityCreator ec = Config.sharedConfig().getDatabase().getEntityCreatorSupplier().get();
    /* Beware, this drops the table */
    CreateEntity createEntity = null;
    CottontailWrapper cottontail = null;
    if (Config.sharedConfig().getDatabase().getSelector() != DataSource.COTTONTAIL || Config.sharedConfig().getDatabase().getWriter() != DataSource.COTTONTAIL) {
        LOGGER.warn("Other database than Cottontail DB in use. Using inconvenient database restore");
    } else {
        LOGGER.info("Storing entity ({}) details for re-setup", entityName);
        cottontail = new CottontailWrapper(Config.sharedConfig().getDatabase().getHost(), Config.sharedConfig().getDatabase().getPort());
    // entityDefinition = cottontail.entityDetailsBlocking(CottontailMessageBuilder.entity(entityName));
    }
    LOGGER.info("{} - Dropping table for entity {}...", taskName, entityName);
    ec.dropEntity(entityName);
    LOGGER.info("{} - Finished dropping table for entity {}", taskName, entityName);
    if (createEntity == null) {
        LOGGER.warn("Calling command: setup -- This may take a while");
        DatabaseSetupCommand setupCmd = new DatabaseSetupCommand();
        setupCmd.doSetup();
    } else {
        cottontail.client.create(createEntity);
        LOGGER.info("Re-created entity: {}", createEntity.getBuilder().getDefinition().getEntity().getName());
    }
}
Also used : CreateEntity(org.vitrivr.cottontail.client.language.ddl.CreateEntity) EntityCreator(org.vitrivr.cineast.core.db.setup.EntityCreator) CottontailWrapper(org.vitrivr.cineast.core.db.cottontaildb.CottontailWrapper) DatabaseSetupCommand(org.vitrivr.cineast.standalone.cli.DatabaseSetupCommand)

Aggregations

EntityCreator (org.vitrivr.cineast.core.db.setup.EntityCreator)4 PersistentOperator (org.vitrivr.cineast.core.db.PersistentOperator)1 CottontailWrapper (org.vitrivr.cineast.core.db.cottontaildb.CottontailWrapper)1 DatabaseSetupCommand (org.vitrivr.cineast.standalone.cli.DatabaseSetupCommand)1 CreateEntity (org.vitrivr.cottontail.client.language.ddl.CreateEntity)1