class BrowseAssetsSqlBuilder extends BrowseMetadataNodeSqlBuilderSupport {

  @Override
  protected String buildWhereClause(final List<String> bucketIds, final QueryOptions queryOptions) {
    List<String> whereClauses = new ArrayList<>();
    if (!bucketIds.isEmpty()) {
      whereClauses.add("(" + bucketIds.stream()
          .map((bucket) -> MetadataNodeEntityAdapter.P_BUCKET + " = " + bucket)
          .collect(Collectors.joining(" OR ")) + ")");
    }
    if (queryOptions.getContentAuth()) {
      whereClauses.add("contentAuth(@this.name, @this.format, :browsedRepository) == true");
    }

    return whereClause(Joiner.on(" AND ").join(whereClauses), queryOptions.getFilter() != null,
        queryOptions.getLastId() != null);
  }

  @Inject  BrowseAssetsSqlBuilder(final AssetEntityAdapter assetEntityAdapter);

}