|
16 | 16 | // under the License. |
17 | 17 | package com.cloud.storage.dao; |
18 | 18 |
|
19 | | -import java.util.HashMap; |
20 | | -import java.util.List; |
21 | | -import java.util.Map; |
22 | | - |
23 | 19 | import javax.ejb.Local; |
24 | 20 |
|
25 | 21 | import org.apache.cloudstack.framework.config.ConfigKey; |
|
28 | 24 | import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO; |
29 | 25 | import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; |
30 | 26 |
|
31 | | -import com.cloud.utils.db.GenericDaoBase; |
32 | | -import com.cloud.utils.db.SearchBuilder; |
33 | | -import com.cloud.utils.db.SearchCriteria; |
34 | | -import com.cloud.utils.db.TransactionLegacy; |
| 27 | +import com.cloud.dc.dao.ResourceDetailDaoBase; |
35 | 28 |
|
36 | 29 | @Local(value = StoragePoolDetailsDao.class) |
37 | | -public class StoragePoolDetailsDaoImpl extends GenericDaoBase<StoragePoolDetailVO, Long> implements StoragePoolDetailsDao, ScopedConfigStorage { |
38 | | - |
39 | | - protected final SearchBuilder<StoragePoolDetailVO> PoolSearch; |
40 | | - |
41 | | - protected StoragePoolDetailsDaoImpl() { |
42 | | - super(); |
43 | | - PoolSearch = createSearchBuilder(); |
44 | | - PoolSearch.and("pool", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ); |
45 | | - PoolSearch.and("name", PoolSearch.entity().getName(), SearchCriteria.Op.EQ); |
46 | | - PoolSearch.done(); |
47 | | - } |
48 | | - |
49 | | - @Override |
50 | | - public void update(long poolId, Map<String, String> details) { |
51 | | - TransactionLegacy txn = TransactionLegacy.currentTxn(); |
52 | | - SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create(); |
53 | | - sc.setParameters("pool", poolId); |
54 | | - |
55 | | - txn.start(); |
56 | | - expunge(sc); |
57 | | - for (Map.Entry<String, String> entry : details.entrySet()) { |
58 | | - StoragePoolDetailVO detail = new StoragePoolDetailVO(poolId, entry.getKey(), entry.getValue()); |
59 | | - persist(detail); |
60 | | - } |
61 | | - txn.commit(); |
62 | | - } |
63 | | - |
64 | | - @Override |
65 | | - public Map<String, String> getDetails(long poolId) { |
66 | | - SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create(); |
67 | | - sc.setParameters("pool", poolId); |
68 | | - |
69 | | - List<StoragePoolDetailVO> details = listBy(sc); |
70 | | - Map<String, String> detailsMap = new HashMap<String, String>(); |
71 | | - for (StoragePoolDetailVO detail : details) { |
72 | | - detailsMap.put(detail.getName(), detail.getValue()); |
73 | | - } |
74 | | - |
75 | | - return detailsMap; |
76 | | - } |
77 | | - |
78 | | - @Override |
79 | | - public StoragePoolDetailVO findDetail(long poolId, String name) { |
80 | | - SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create(); |
81 | | - sc.setParameters("pool", poolId); |
82 | | - sc.setParameters("name", name); |
| 30 | +public class StoragePoolDetailsDaoImpl extends ResourceDetailDaoBase<StoragePoolDetailVO> implements StoragePoolDetailsDao, ScopedConfigStorage { |
83 | 31 |
|
84 | | - return findOneIncludingRemovedBy(sc); |
| 32 | + public StoragePoolDetailsDaoImpl() { |
85 | 33 | } |
86 | 34 |
|
87 | 35 | @Override |
|
0 commit comments