|
24 | 24 | import java.util.List; |
25 | 25 | import java.util.Map; |
26 | 26 |
|
27 | | -import javax.annotation.PostConstruct; |
28 | 27 | import javax.ejb.Local; |
29 | 28 | import javax.inject.Inject; |
30 | 29 | import javax.naming.ConfigurationException; |
@@ -55,9 +54,6 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> |
55 | 54 | protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch; |
56 | 55 | protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch; |
57 | 56 | protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch; |
58 | | - protected SearchBuilder<StoragePoolVO> HostSearch; |
59 | | - protected SearchBuilder<StoragePoolHostVO> HostPoolSearch; |
60 | | - protected SearchBuilder<StoragePoolDetailVO> TagPoolSearch; |
61 | 57 |
|
62 | 58 | @Inject |
63 | 59 | protected StoragePoolDetailsDao _detailsDao; |
@@ -120,26 +116,6 @@ public PrimaryDataStoreDaoImpl() { |
120 | 116 |
|
121 | 117 | } |
122 | 118 |
|
123 | | - @PostConstruct |
124 | | - void init() { |
125 | | - HostSearch = createSearchBuilder(); |
126 | | - TagPoolSearch = _detailsDao.createSearchBuilder(); |
127 | | - HostPoolSearch = _hostDao.createSearchBuilder(); |
128 | | - // Search for pools on the host |
129 | | - HostPoolSearch.and("hostId", HostPoolSearch.entity().getHostId(), Op.EQ); |
130 | | - // Set criteria for pools |
131 | | - HostSearch.and("scope", HostSearch.entity().getScope(), Op.EQ); |
132 | | - HostSearch.and("removed", HostSearch.entity().getRemoved(), Op.NULL); |
133 | | - HostSearch.and("status", HostSearch.entity().getStatus(), Op.EQ); |
134 | | - HostSearch.join("hostJoin", HostPoolSearch, HostSearch.entity().getId(), HostPoolSearch.entity().getPoolId(), JoinBuilder.JoinType.INNER); |
135 | | - // Set criteria for tags |
136 | | - TagPoolSearch.and("name", TagPoolSearch.entity().getName(), Op.EQ); |
137 | | - TagPoolSearch.and("value", TagPoolSearch.entity().getValue(), Op.EQ); |
138 | | - |
139 | | - HostSearch.join("tagJoin", TagPoolSearch, HostSearch.entity().getId(), TagPoolSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER); |
140 | | - HostSearch.done(); |
141 | | - } |
142 | | - |
143 | 119 | @Override |
144 | 120 | public List<StoragePoolVO> findPoolByName(String name) { |
145 | 121 | SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create(); |
@@ -345,11 +321,29 @@ public List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Lo |
345 | 321 |
|
346 | 322 | @Override |
347 | 323 | public List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[] tags) { |
| 324 | + SearchBuilder<StoragePoolVO> hostSearch = createSearchBuilder(); |
| 325 | + SearchBuilder<StoragePoolHostVO> hostPoolSearch = _hostDao.createSearchBuilder(); |
| 326 | + SearchBuilder<StoragePoolDetailVO> tagPoolSearch = _detailsDao.createSearchBuilder();; |
348 | 327 |
|
349 | | - SearchCriteria<StoragePoolVO> sc = HostSearch.create(); |
| 328 | + // Search for pools on the host |
| 329 | + hostPoolSearch.and("hostId", hostPoolSearch.entity().getHostId(), Op.EQ); |
| 330 | + // Set criteria for pools |
| 331 | + hostSearch.and("scope", hostSearch.entity().getScope(), Op.EQ); |
| 332 | + hostSearch.and("removed", hostSearch.entity().getRemoved(), Op.NULL); |
| 333 | + hostSearch.and("status", hostSearch.entity().getStatus(), Op.EQ); |
| 334 | + hostSearch.join("hostJoin", hostPoolSearch, hostSearch.entity().getId(), hostPoolSearch.entity().getPoolId(), JoinBuilder.JoinType.INNER); |
| 335 | + |
| 336 | + if (!(tags == null || tags.length == 0 )) { |
| 337 | + tagPoolSearch.and("name", tagPoolSearch.entity().getName(), Op.EQ); |
| 338 | + tagPoolSearch.and("value", tagPoolSearch.entity().getValue(), Op.EQ); |
| 339 | + hostSearch.join("tagJoin", tagPoolSearch, hostSearch.entity().getId(), tagPoolSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER); |
| 340 | + } |
| 341 | + |
| 342 | + SearchCriteria<StoragePoolVO> sc = hostSearch.create(); |
350 | 343 | sc.setJoinParameters("hostJoin", "hostId", hostId ); |
351 | 344 | sc.setParameters("scope", ScopeType.HOST.toString()); |
352 | 345 | sc.setParameters("status", Status.Up.toString()); |
| 346 | + |
353 | 347 | if (!(tags == null || tags.length == 0 )) { |
354 | 348 | Map<String, String> details = tagsToDetails(tags); |
355 | 349 | for (Map.Entry<String, String> detail : details.entrySet()) { |
|
0 commit comments