Search in sources :

Example 1 with BucketItemEntityRowMapper

use of org.apache.nifi.registry.db.mapper.BucketItemEntityRowMapper in project nifi-registry by apache.

the class DatabaseMetadataService method getBucketItems.

@Override
public List<BucketItemEntity> getBucketItems(final Set<String> bucketIds) {
    if (bucketIds == null || bucketIds.isEmpty()) {
        return Collections.emptyList();
    }
    final StringBuilder sqlBuilder = new StringBuilder("SELECT " + "item.id as ID, " + "item.name as NAME, " + "item.description as DESCRIPTION, " + "item.created as CREATED, " + "item.modified as MODIFIED, " + "item.item_type as ITEM_TYPE, " + "b.id as BUCKET_ID, " + "b.name as BUCKET_NAME " + "FROM " + "bucket_item item, bucket b " + "WHERE " + "item.bucket_id = b.id " + "AND " + "item.bucket_id IN (");
    for (int i = 0; i < bucketIds.size(); i++) {
        if (i > 0) {
            sqlBuilder.append(", ");
        }
        sqlBuilder.append("?");
    }
    sqlBuilder.append(")");
    final List<BucketItemEntity> items = jdbcTemplate.query(sqlBuilder.toString(), bucketIds.toArray(), new BucketItemEntityRowMapper());
    return getItemsWithCounts(items);
}
Also used : BucketItemEntity(org.apache.nifi.registry.db.entity.BucketItemEntity) BucketItemEntityRowMapper(org.apache.nifi.registry.db.mapper.BucketItemEntityRowMapper)

Example 2 with BucketItemEntityRowMapper

use of org.apache.nifi.registry.db.mapper.BucketItemEntityRowMapper in project nifi-registry by apache.

the class DatabaseMetadataService method getBucketItems.

// ----------------- BucketItems ---------------------------------
@Override
public List<BucketItemEntity> getBucketItems(final String bucketIdentifier) {
    final String sql = "SELECT " + "item.id as ID, " + "item.name as NAME, " + "item.description as DESCRIPTION, " + "item.created as CREATED, " + "item.modified as MODIFIED, " + "item.item_type as ITEM_TYPE, " + "b.id as BUCKET_ID, " + "b.name as BUCKET_NAME " + "FROM " + "bucket_item item, bucket b " + "WHERE " + "item.bucket_id = b.id " + "AND " + "item.bucket_id = ?";
    final List<BucketItemEntity> items = jdbcTemplate.query(sql, new Object[] { bucketIdentifier }, new BucketItemEntityRowMapper());
    return getItemsWithCounts(items);
}
Also used : BucketItemEntity(org.apache.nifi.registry.db.entity.BucketItemEntity) BucketItemEntityRowMapper(org.apache.nifi.registry.db.mapper.BucketItemEntityRowMapper)

Aggregations

BucketItemEntity (org.apache.nifi.registry.db.entity.BucketItemEntity)2 BucketItemEntityRowMapper (org.apache.nifi.registry.db.mapper.BucketItemEntityRowMapper)2