Search in sources :

Example 1 with RepositorySearchRequestBuilder

use of com.b2international.snowowl.core.repository.RepositorySearchRequestBuilder in project snow-owl by b2ihealthcare.

the class RepositoriesCommand method run.

@Override
public void run(CommandLineStream out) {
    RepositorySearchRequestBuilder req = RepositoryRequests.prepareSearch();
    if (!Strings.isNullOrEmpty(repositoryId)) {
        req.one().filterById(repositoryId);
    } else {
        req.all();
    }
    final Repositories repositories = req.buildAsync().execute(getBus()).getSync();
    final int maxDiagLength = ImmutableList.copyOf(repositories).stream().map(RepositoryInfo::diagnosis).map(Strings::nullToEmpty).map(diag -> diag.length()).max(Ints::compare).orElse(16);
    final int maxLength = Math.max(maxDiagLength + 36, 52);
    printSeparator(out, maxLength);
    printHeader(out, "id", "health", Strings.padEnd("diagnosis", maxDiagLength, ' '));
    printSeparator(out, maxLength);
    repositories.forEach(repository -> {
        printLine(out, repository, RepositoryInfo::id, RepositoryInfo::health, repo -> Strings.isNullOrEmpty(repo.diagnosis()) ? "-" : null);
        printSeparator(out, maxLength);
    });
}
Also used : Repositories(com.b2international.snowowl.core.Repositories) RepositorySearchRequestBuilder(com.b2international.snowowl.core.repository.RepositorySearchRequestBuilder) RepositoryInfo(com.b2international.snowowl.core.RepositoryInfo)

Aggregations

Repositories (com.b2international.snowowl.core.Repositories)1 RepositoryInfo (com.b2international.snowowl.core.RepositoryInfo)1 RepositorySearchRequestBuilder (com.b2international.snowowl.core.repository.RepositorySearchRequestBuilder)1