use of com.cloud.storage.StoragePoolTagVO in project cloudstack by apache.
the class StoragePoolTagsDaoImpl method getStoragePoolTags.
@Override
public List<String> getStoragePoolTags(long poolId) {
SearchCriteria<StoragePoolTagVO> sc = StoragePoolSearch.create();
sc.setParameters("poolId", poolId);
List<StoragePoolTagVO> results = search(sc, null);
List<String> storagePoolTags = new ArrayList<String>(results.size());
for (StoragePoolTagVO result : results) {
storagePoolTags.add(result.getTag());
}
return storagePoolTags;
}
use of com.cloud.storage.StoragePoolTagVO in project cloudstack by apache.
the class StoragePoolTagsDaoImpl method deleteTags.
@Override
public void deleteTags(long poolId) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
SearchCriteria<StoragePoolTagVO> sc = StoragePoolSearch.create();
sc.setParameters("poolId", poolId);
expunge(sc);
txn.commit();
}
use of com.cloud.storage.StoragePoolTagVO in project cloudstack by apache.
the class QueryManagerImpl method searchForStorageTagsInternal.
private Pair<List<StoragePoolTagVO>, Integer> searchForStorageTagsInternal(ListStorageTagsCmd cmd) {
Filter searchFilter = new Filter(StoragePoolTagVO.class, "id", Boolean.TRUE, null, null);
SearchBuilder<StoragePoolTagVO> sb = _storageTagDao.createSearchBuilder();
// select distinct
sb.select(null, Func.DISTINCT, sb.entity().getId());
SearchCriteria<StoragePoolTagVO> sc = sb.create();
// search storage tag details by ids
Pair<List<StoragePoolTagVO>, Integer> uniqueTagPair = _storageTagDao.searchAndCount(sc, searchFilter);
Integer count = uniqueTagPair.second();
if (count.intValue() == 0) {
return uniqueTagPair;
}
List<StoragePoolTagVO> uniqueTags = uniqueTagPair.first();
Long[] vrIds = new Long[uniqueTags.size()];
int i = 0;
for (StoragePoolTagVO v : uniqueTags) {
vrIds[i++] = v.getId();
}
List<StoragePoolTagVO> vrs = _storageTagDao.searchByIds(vrIds);
return new Pair<List<StoragePoolTagVO>, Integer>(vrs, count);
}
use of com.cloud.storage.StoragePoolTagVO in project cloudstack by apache.
the class StoragePoolTagsDaoImpl method persist.
@Override
public void persist(long poolId, List<String> storagePoolTags) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
SearchCriteria<StoragePoolTagVO> sc = StoragePoolSearch.create();
sc.setParameters("poolId", poolId);
expunge(sc);
for (String tag : storagePoolTags) {
tag = tag.trim();
if (tag.length() > 0) {
StoragePoolTagVO vo = new StoragePoolTagVO(poolId, tag);
persist(vo);
}
}
txn.commit();
}
Aggregations