Search in sources :

Example 1 with Framework

use of org.codice.ddf.commands.catalog.facade.Framework in project ddf by codice.

the class ReplicateCommand method executeWithSubject.

@Override
protected Object executeWithSubject() throws Exception {
    if (batchSize > MAX_BATCH_SIZE || batchSize < 1) {
        console.println("Batch Size must be between 1 and " + MAX_BATCH_SIZE + ".");
        return null;
    }
    final CatalogFacade catalog = getCatalog();
    final CatalogFacade framework = new Framework(catalogFramework);
    Set<String> sourceIds = framework.getSourceIds();
    while (true) {
        if (StringUtils.isBlank(sourceId) || !sourceIds.contains(sourceId)) {
            console.println("Please enter the Source ID you would like to replicate:");
            for (String id : sourceIds) {
                console.println("\t" + id);
            }
        } else {
            break;
        }
        sourceId = session.readLine("ID:  ", null);
    }
    start = System.currentTimeMillis();
    console.println("Starting replication.");
    duplicateInBatches(framework, catalog, getFilter(), sourceId);
    console.println();
    long end = System.currentTimeMillis();
    String completed = String.format(" %d record(s) replicated; %d record(s) failed; completed in %3.3f seconds.", ingestedCount.get(), failedCount.get(), (end - start) / MS_PER_SECOND);
    LOGGER.debug("Replication Complete: {}", completed);
    console.println(completed);
    return null;
}
Also used : CatalogFacade(org.codice.ddf.commands.catalog.facade.CatalogFacade) Framework(org.codice.ddf.commands.catalog.facade.Framework)

Aggregations

CatalogFacade (org.codice.ddf.commands.catalog.facade.CatalogFacade)1 Framework (org.codice.ddf.commands.catalog.facade.Framework)1