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);
});
}
Aggregations