use of org.vitrivr.cineast.standalone.config.IngestConfig in project cineast by vitrivr.
the class SessionExtractionContainer method initalizeExtraction.
private static void initalizeExtraction() {
ExtractionDispatcher dispatcher = new ExtractionDispatcher();
try {
JacksonJsonProvider reader = new JacksonJsonProvider();
IngestConfig context = reader.toObject(configFile, IngestConfig.class);
provider = new SessionContainerProvider();
if (dispatcher.initialize(provider, context)) {
dispatcher.registerListener(provider);
dispatcher.start();
} else {
System.err.println(String.format("Could not start session with configuration file '%s'. Does the file exist?", configFile.toString()));
}
dispatcher.start();
} catch (IOException e) {
System.err.println(String.format("Could not start session with configuration file '%s' due to a IO error.", configFile.toString()));
e.printStackTrace();
}
}
use of org.vitrivr.cineast.standalone.config.IngestConfig in project cineast by vitrivr.
the class ExtractionCommand method run.
@Override
public void run() {
final ExtractionDispatcher dispatcher = new ExtractionDispatcher();
final File file = new File(this.extractionConfig);
if (file.exists()) {
try {
final JacksonJsonProvider reader = new JacksonJsonProvider();
final IngestConfig context = reader.toObject(file, IngestConfig.class);
// Check if the config specifies an IIIF job
if (context != null) {
InputConfig inputConfig = context.getInput();
IIIFConfig iiifConfig = inputConfig.getIiif();
if (iiifConfig != null) {
String directoryPath;
String iiifConfigPath = inputConfig.getPath();
/* If the user hasn't asked to save the images once extraction is complete or if the user has not specified a download directory for the IIIF images, then save the images in a new "iiif-media-{@link System#currentTimeMillis}" subfolder.
This folder can act as the temp directory during extraction and can either be deleted or retained post extraction based on the value set in {@link IIIFConfig#keepImagesPostExtraction} */
if (!iiifConfig.isKeepImagesPostExtraction() || iiifConfigPath == null || iiifConfigPath.isEmpty()) {
directoryPath = file.getAbsoluteFile().toPath().getParent() + "/iiif-media-" + System.currentTimeMillis();
inputConfig.setPath(directoryPath);
} else {
directoryPath = iiifConfigPath;
}
prepareIIIFExtractionJob(iiifConfig, directoryPath);
}
}
final ExtractionContainerProvider provider = ExtractionContainerProviderFactory.tryCreatingTreeWalkPathProvider(file, context);
if (dispatcher.initialize(provider, context)) {
/* Only attempt to optimize Cottontail entities if we were extracting into Cottontail, otherwise an unavoidable error message would be displayed when extracting elsewhere. */
if (!doNotFinalize && context != null && context.getDatabase().getSelector() == DataSource.COTTONTAIL && context.getDatabase().getWriter() == DataSource.COTTONTAIL) {
dispatcher.registerListener(new ExtractionCompleteListener() {
@Override
public void extractionComplete() {
OptimizeEntitiesCommand.optimizeAllCottontailEntities();
}
});
}
dispatcher.registerListener((ExtractionCompleteListener) provider);
dispatcher.start();
dispatcher.block();
} else {
System.err.printf("Could not start handleExtraction with configuration file '%s'. Does the file exist?%n", file);
}
} catch (IOException e) {
System.err.printf("Could not start handleExtraction with configuration file '%s' due to a IO error.%n", file);
e.printStackTrace();
} catch (ClassCastException e) {
System.err.println("Could not register completion listener for extraction.");
} finally {
if (postExtractionIIIFCleanup != null) {
postExtractionIIIFCleanup.run();
}
}
} else {
System.err.printf("Could not start handleExtraction with configuration file '%s'; the file does not exist!%n", file);
}
}
use of org.vitrivr.cineast.standalone.config.IngestConfig in project cineast by vitrivr.
the class DatabaseSetupCommand method extractionConfigPersistentOperators.
private HashSet<PersistentOperator> extractionConfigPersistentOperators(String extractionConfig) {
final HashSet<PersistentOperator> persistentOperators = new HashSet<>();
final File file = new File(extractionConfig);
if (file.exists()) {
final JacksonJsonProvider reader = new JacksonJsonProvider();
final IngestConfig context = reader.toObject(file, IngestConfig.class);
for (ExtractorConfig extractor : context.getExtractors()) {
persistentOperators.add(extractor.getExtractor());
}
} else {
System.err.println(String.format("Could not setup database based upon extraction config '%s'; the file does not exist!", file.toString()));
}
return persistentOperators;
}
Aggregations